### Help with finding average

closed account (z8q4izwU)
Hello, Im having problems getting the right answer for finding the average high and low temperature on a project. It runs but i know the answer is wrong but cant figure out what i wrote wrong. The answer i get is the average high: 136627563.00 and the low: -23765427..... If anyone has any ideas it would help alot.

Thanks Gary

Heres the input data i have in the file....

27 38
29 42
35 50
45 61
54 71
64 79
69 84
68 83
61 75
50 64
42 54
32 32

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152`` ``````#include #include #include const int NO_OF_MONTHS = 12; const int rows = 12; //make # of rows/cols a constant int const int cols = 2; using namespace std; void getData( int listTemp[rows][cols]); void averageHigh( int listTemp[rows][cols]); void averageLow(int listTemp[rows][cols]); void indexHighTemp(int listTemp[rows][cols]); void indexLowTemp( int listTemp[cols][cols]); ifstream infile; ofstream outfile; int main() { // ofstream outfile; double average; int listTemp[rows][cols]; infile.open("data.txt"); //open infile if (!infile) { cout << "Error opening data.txt " << endl; return 1; } cout<> listTemp[x][j] >> listTemp[x][j]; // outfile << listTemp[x][j] << " "< highestIndex) highestIndex = listTemp[0][x]; } cout << "The index high temperature is " << highestIndex < listTemp[0][x]) lowestIndex = listTemp[0][x]; } cout << "The index low temperature is " << lowestIndex << endl<
closed account (z8q4izwU)
The low should be: 48

The high should be: 61

But my answers are no where near that.
Topic archived. No new replies allowed.