File I/O Exercise: (optional)
Your lab instructor will guide you through the steps necessary to set up this project in their desktop IDE as part of their lab seminar. Video instructions for people using our other supported Desktop IDEs can be found here:
Using the lab samples as a starting point, write a program in the file called ex1_lab4.cpp
(provided in your replit team project).
Your code will:
- Read 10 float values from an input file called
ex1_input.txt
.
(you have to create theex1_input.txt
file and make up 10 numbers yourself) - Output the sum and the average of the 10 float values to an output file
ex1_output.txt
tidily and with labels. - Use
if
statements to see if the input and output files opened successfully before reading or writing with them. - Compile and run this C++ program.
When you are done:
- Observe the results in
ex1_output.txt
. Check with your lab instructor if you aren't sure if they are correct. - Take a screenshot of your IDE and console window after running the program - there should be no output there.
- For this exercise, you will have:
ex1_lab4.cpp
,ex1_input.txt
andex1_output.txt
files. Complete all the exercises in this lab before uploading the zip file produced by replit.