Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will search a input file of numbers of type int and write t

ID: 3690769 • Letter: W

Question

Write a program that will search a input file of numbers of type int and write the largest and the smallest numbers to a output file. The input file contains nothing but numbers of type int separated by blanks or line breaks. (Save both files to MyDocuments folder) Write a program that will search a input file of numbers of type int and write the largest and the smallest numbers to a output file. The input file contains nothing but numbers of type int separated by blanks or line breaks. (Save both files to MyDocuments folder) Write a program that will search a input file of numbers of type int and write the largest and the smallest numbers to a output file. The input file contains nothing but numbers of type int separated by blanks or line breaks. (Save both files to MyDocuments folder)

Explanation / Answer

Hi below i have written the code for your reference,The program first generates a set of numbers and writes them to an output file called "int_rand.dat". It then opens the same file and seaches for the smallest and largest values in the file. Notice that instead of functions I wrote macros to search for smallest and largest values, you could of course replace them with functions. #include #include // ifstream, ofstream #include // eof() #include // clrscr() #include // randomize() #define MIN(a, b) a b ? a : b // macro to find max of two values int main() { ifstream inFile; // create input file object ofstream outFile; // create output file object int num1, num2; int smallest, largest; /*** program topic ***/ clrscr(); cout num2) // get another value while not eof num1 = MAX(num1, num2); // test values for largest largest = num1; // assign the largest value inFile.close(); // close file /*** output the results to the screen ***/ cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote