Hello,
I want to calculate the average, median, mode and range of some numbers. It's supposed to read the numbers from a file.
The file got:
Code:
int numbers[]={53,2,3,5,59,7,11,13,17,41,53,41,19,23,29,31,53,7,37,53,41,43,47,53}
I am stuck with the average.....
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main() {
int average;
int median;
int mode;
int range;
int numbers;
ifstream inFile;
inFile.open("C:\Users\Sven\Desktop\data_for_proj1.txt");
if (!inFile) {
cout << "Unable to open file";
exit(1); // terminate with error
}
average = numbers /24;
inFile.close();
cout << "The average is: " << average << endl;
return 0;
}
Gives me an error for the "while {" line. No idea if this would work. anyway. Any input is appreciated.
EDIT:
I just edited the while out. Now it should be better...I guess. But it still gives me tis error:
29:17 C:\Users...........Lab_16.cpp incomplete universal character name \U
29:17 C:\Users\..........Lab_16.cpp [Warning] unknown escape sequence '\S'