CSCI 216
Spring 2015
Project
#1
Date Due: 26
January 2015
Purpose: to review the C you learned in 116 and
to refamiliarize yourself with how to use Visual
Studio
Program objective: This program is to do some simple file
processing.
Instructions: Write
a simple C++ program to ask the user for a file name. Open the file and read the first and the last
number in the file. Print the two
numbers, and then print the average of the two numbers. Sample output might look like:
What file should I
use? data1.txt
There are 10000
numbers in the file
The first number is
195650
The last number is
887747
The average of the
two is 541698.5
Press any key to
continue
Append the
output to the end of the program source as a comment, print out the resultant
program listing, and turn it in by class time on the due date. Sample data files to try include dat1a.txt,
data1.txt,
data2.txt,
and data3.txt.
You should
check to make sure that the file opened properly, and exit printing an error
message if it didn’t. You should also
remember to close the file when you are done reading from it.