Answer to Question #19839 in C++ for Ryan Bentz
I am confused how to get this problem started and written.
Problem: Search a file of numbers of type int and write the largest and smallest to the
screen. The file is space and newline delimited integers. Instructor supplies the data file.
Here is what the beginning of your source file should look like.
//Task: read up to EOF, keep largest, smallest, output to
//initialize largest to -maxint
//and initialize smallest to maxint, this requires climits
//open file, check for OK status
//while (not EOF on input)
// get an int
//if (input > largest)
// largest = input;
//if (input < smallest)
// smallest = input;
//output largest, smallest, with appropriate labeling.
//Discussion: you can either do some research on your system,
//use climits, or you can choose a largest value larger
//than the largest in your file, and analogously for
//smallest. If your compiler uses two byte integers, then
//the initial value for finding the smallest will be
//2^15 - 1 = 32,767, and the negative of this for finding
//the largest. If your compiler uses 4 byte integers, the
//value for smallest is 231 - 1 = 2,147,483,647, and the
//negative of this for largest.
//Note that we do no error checking for bad character in the //file, nor make any attempt to recover from errors.
//With some versions of g++ under Linux, there appear to be
//bugs that will cause difficulty with setting the INT_MIN
//value. Use -INT_MAX instead.
#include // for streams
#include // for files
#include // for exit
#include // for INT_MAX etc.
using namespace std;
THE REST IS FOR YOU! 1
Unfortunately, your question requires a lot of work and cannot be done for free.
Submit it with all requirements as an assignment to our control panel and we'll assist you.
Learn more about our help with Assignments: