Write the largest and smallest number in the other file? PP1
Posted on 2005-04-27
Topic. Write a program that will search a file of numbers ot type int and write the largest and the smallest numbesr to the screen. The file contains nothing but numbers of type int separated by blanks or line breaks.
This is my program.
using namespace std;
void max(ifstream& read, int& maximum_number);
void min(ifstream& get, int& minimum_number);
if (in_stream.fail( ))
cout<<"Input file opening failed.\n";
if (out_stream.fail( ))
cout<<"Output file opening failed.\n";
out_stream<<"The largest number is "<<maximum_number<<endl;
out_stream<<"The smallest number is "<<minimum_number<<endl;
void max(ifstream& read, int& maximum_number)
maximum_number = next;
void min(ifstream& get, int& minimum_number)
This program is working find, except they gave the result
The largest number is 25
The smallest number is -2099024616
The largest number is right, but the smallest number is wrong.
This is my infile_pp1.txt
Can someone help me to looking for why this is not work with minimum number.