Code Error Help C++

#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
#include <iomanip> // std::setprecision
using namespace std;
int main ()
{
int ROW = 7;
int COLUMN = 2;
int temperature[ROW][COLUMN];
double totalAvg = 0;
double highTempavg = 0;
double lowTempavg = 0;
for (int i = 0; i < ROW; ++i)
{
cout << "Enter High temperature for day " << (i+1) << ": ";
cin >> temperature[i][0];
cout << "Enter Low temperature for day " << (i+1) << ": ";
cin >> temperature[i][1];
highTempavg = highTempavg + temperature[i][0];
lowTempavg = lowTempavg + temperature[i][1];
totalAvg = totalAvg + temperature[i][0] + temperature[i][1];
}
cout << "\nAverage high temperature: " << highTempavg/ROW << endl;
cout << "Average low temperature: " << lowTempavg/ROW << endl;
cout << "Average temperature: " << setprecision (3) << totalAvg/(ROW*COLUMN) << endl;
return 0;
}


Error 1 error C2057: expected constant expression c:\cpp8\chap 12\intermediate23 project\intermediate23 project\intermediate23.cpp 11 1 Intermediate23 Project

Error 3 error C2087: 'temperature' : missing subscript c:\cpp8\chap 12\intermediate23 project\intermediate23 project\intermediate23.cpp 11 1 Intermediate23 Project

Error 4 error C2133: 'temperature' : unknown size c:\cpp8\chap 12\intermediate23 project\intermediate23 project\intermediate23.cpp 11 1 Intermediate23 Project

Error 2 error C2466: cannot allocate an array of constant size 0 c:\cpp8\chap 12\intermediate23 project\intermediate23 project\intermediate23.cpp 11 1 Intermediate23 Project

5 IntelliSense: expression must have a constant value c:\Cpp8\Chap 12\Intermediate23 Project\Intermediate23 Project\Intermediate23.cpp 11 17 Intermediate23 Project

6 IntelliSense: expression must have a constant value c:\Cpp8\Chap 12\Intermediate23 Project\Intermediate23 Project\Intermediate23.cpp 11 22 Intermediate23 Project


I cannot figure out this error and why this code won't debug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
#include <iomanip> // std::setprecision
using namespace std;
int main ()
{
int ROW = 7;
int COLUMN = 2;
int temperature[ROW][COLUMN];
double totalAvg = 0;
double highTempavg = 0;
double lowTempavg = 0;
for (int i = 0; i < ROW; ++i)
{
cout << "Enter High temperature for day " << (i+1) << ": ";
cin >> temperature[i][0];
cout << "Enter Low temperature for day " << (i+1) << ": ";
cin >> temperature[i][1];
highTempavg = highTempavg + temperature[i][0];
lowTempavg = lowTempavg + temperature[i][1];
totalAvg = totalAvg + temperature[i][0] + temperature[i][1];
}
cout << "\nAverage high temperature: " << highTempavg/ROW << endl;
cout << "Average low temperature: " << lowTempavg/ROW << endl;
cout << "Average temperature: " << setprecision (3) << totalAvg/(ROW*COLUMN) << endl;
return 0;
}


It should be :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
#include <iomanip> // std::setprecision
using namespace std;
int main ()
{
const int ROW = 7;
const int COLUMN = 2;
int temperature[ROW][COLUMN];
double totalAvg = 0;
double highTempavg = 0;
double lowTempavg = 0;
for (int i = 0; i < ROW; ++i)
{
cout << "Enter High temperature for day " << (i+1) << ": ";
cin >> temperature[i][0];
cout << "Enter Low temperature for day " << (i+1) << ": ";
cin >> temperature[i][1];
highTempavg = highTempavg + temperature[i][0];
lowTempavg = lowTempavg + temperature[i][1];
totalAvg = totalAvg + temperature[i][0] + temperature[i][1];
}
cout << "\nAverage high temperature: " << highTempavg/ROW << endl;
cout << "Average low temperature: " << lowTempavg/ROW << endl;
cout << "Average temperature: " << setprecision (3) << totalAvg/(ROW*COLUMN) << endl;
return 0;
}
Topic archived. No new replies allowed.