-
Function definition
I am truely stumped please help me!
The program will search a file of numbers of type int and write the largest and the smallest numbers to the screen.
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#include <iomanip.h>
void order(int one,int two,int three,int four, int five);
int main()
{
ifstream high2low;
high2low.open("numfile.txt");
if(high2low.fail())
{
cout <<"Input file opening failed.\n";
exit(1);
}
int first, second, third, fourth, fifth;
high2low >> first >>second >>third>>fourth>>fifth;
order(first, second, third, fourth, fifth);
cout << first<<endl;
cout << second<<endl;
cout << third<<endl;
cout << fourth<<endl;
cout << fifth<<endl;
high2low.close();
return 0;
}
void order(int one,int two,int three,int four, int five)
{
int greatest,next;
greatest =
if(one>greatest)
}
-
the 1st will always be greatest until you test the others, so assign it to the variable named greatest. then test the others (its easier if they are in an array). so we have...
greatest= first;
if( second > greatest )
{
greatest = second;
}
etc.
etc.
repeat a similar thing for the lowest value