This program is supposed to read 10 integers from an input file, save the largest and smallest integer to an outfile, and compute the even and odd integers and save the sums to an outfile. (The contents of the file named input.dat are: 45 23 12 8 -67 56 87 -33 50 15) I've created the two files input.dat and result.dat correctly, but the program is not reading the numbers from the file.
Also, I keep getting an error message for line 43 that says "overloaded function differs only by return type" and "redefinition; different basic types".
This is the umpteenth I've rewritten everything. I'm proud of getting this far, but what all is wrong?
The code is:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int findLargeSmall (int, int&, int&);
int findTotals (int, int&, int&, int&);
int main () {
int count = 0, current = 0, large = 0, small = 0, total = 0, totalOdd = 0, totalEven = 0;
ifstream inFile;
ofstream outFile;
inFile.open ("myInput.dat");
outFile.open ("result.dat");
while (count <= 10) {
inFile >> current;
findLargeSmall (current, large, small);
findTotals (current, total, totalOdd, totalEven);
count++;
outFile << total << totalOdd << totalEven << large << small;
}
return 0;
}
void findLargeSmall (int current, int& large, int& small ) {
if (large < current)
large = current;
else;
if (small > current)
small = current;
else;
}
void findTotals (int current, int& total, int& totalOdd, int& totalEven) {
total += current;
if (current %2 == 0)
totalEven += current;
else totalOdd += current;
}