Search a file of numbers of type int and write the largest and smallest
to the screen. The file contains int values delimited by white space or
Your assignment is to write a program
that searches a file of numbers of type int and write the largest and
smallest to the screen.
To do this you will need to:
1. Declare an array of characters to hold the file name input by
char fileName ;
2. Check that the file can be opened and exit it not.
3. Process the file, one integer at a time (while(not EOF)),
keeping track of the smallest and largest values seen so far. Output
the smallest and largest values once all of the integers in the file
have been processed.
INPUT AND OUTPUT:
The program must prompt the user to input a file name.
The program must open and read a file containing int values delimited
by white space or newline characters. The program will output the
smallest and largest values in the file.
Here are sample contents of a data file, called data1
How it should look when you run the program:
firstname.lastname@example.org:(~/cs1500/solo6) g++ solo6.cpp
Enter a file
name. This Program limits file names to a maximum of 12
file = -4444
file = 55555555
Here is the list of things you have to turn in:
- At the start of class on the due
date place the following item on the "counter" in
front of me:
- a hardcopy (printed listing) of your program (the C++ source
- Before midnight on the the due
date upload the following to the Homework Submission
- A copy of the source code (C++ code) (be sure your name is
in the comment section at the beginning of the program), named sprog6.cpp
- and a (filtered) script showing a test run of the program,
For the due dates, see the class schedule