99 799
Assignments Done
98.4%
Successfully Done
In June 2021

# Answer to Question #19839 in C++ for Ryan Bentz

Question #19839
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.
//File: ch6prob1

//Task: read up to EOF, keep largest, smallest, output to

// screen

//Outline:

//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 &gt; largest)

// largest = input;

//if (input &lt; 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.

//

//Problem Notes:

//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;

int main()

THE REST IS FOR YOU!
1
Expert's answer
2012-11-30T04:46:40-0500
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.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

#### Comments

No comments. Be the first!

### Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS