I need this code to be modular with function prototypes, definitions and call #include #include #include using namespace std; int main() { ifstream inFile; inFile.open ("numbers.txt"); double highest; double number; if (inFile.fail()) { cout << "Error opening file." <> current ) { double highest = current; while( inFile >> current ) { if( current > highest ) highest = current; } cout << "The highest number is " << highest; } else { cout << "Failed to read any number from file!" <
I need this code to be modular with function prototypes, definitions and call
#include<iostream>
#include<fstream>
#include<cstdlib>
using namespace std;
int main()
{
ifstream inFile;
inFile.open ("numbers.txt");
double highest;
double number;
if (inFile.fail())
{
cout << "Error opening file." <<endl;
exit (1);
}
double current ;
if( inFile >> current )
{
double highest = current;
while( inFile >> current )
{
if( current > highest ) highest = current;
}
cout << "The highest number is " << highest;
}
else
{
cout << "Failed to read any number from file!" <<endl;
return 1 ;
} }
the numbers in the file are:
78
85
2
45
12
99
65
9
15
65
Step by step
Solved in 2 steps with 1 images