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 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
using namespace std;
const int NUMROWS = 10;
const int NUMCOLUMNS = 7;
int numColumns;
int numRows;
int matrix [numRows][numColumns]; //error: Variable length array delcaration not allowed at file scope
void sumRows(int matrix[][numColumns],int numRows);
int main()
{
const int MAX_ARRAY_SIZE = 10;
string name[MAX_ARRAY_SIZE] = {"Johnson", "Aniston", "Cooper", "Gupta", "Blair", "Clark", "Kennedy", "Bronson", "Sunnyu", "Smith"};
for (int i=0; i < MAX_ARRAY_SIZE; i++)
int studentGrades[NUMROWS][NUMCOLUMNS] = {{85 83 77 91 76}, {80 90 95 93 48}, {78 81 11 90 73}, {92 83 30 69 87}, {23 45 96 38 59}, {60 85 45 39 67}, {77 31 52 74 83}, {93 94 89 77 97}, {79 85 28 93 82}, {85 72 49 75 63}}; //error: Expected "}"
system("pause");
return 0;
}
void sumRows(int matrix[][numColumns],int numRows);
{
int row;
int column;
int sum;
for(row = 0; row < numrows; row++)
{
sum = 0;
for(column = 0; column < numColumns; column++)
sum = sum + matrix[row][column];
cout << "average = " << (row + 1) << sum << endl;
}
}
|