Im having issues with my class assigment. I have a mac and not a PC so I can only compile when Im at school.
This is the assignment:
Write a test program that reads a 4-by-4 matrix and displays the sum of all its elements. Heres a sample run:
Heres the code I have but its not doing what I want it to do.
- Code: Select all
using namespace std;
const int COLUMN_SIZE = 4;
int sum(const int a [COLUMN_SIZE], int rowSize)
int total = 0;
for (int row = 0; row < rowSize; row++)
for (int column = 0; column < COLUMN_SIZE; column++)
total += a[row][column];
cout<< "Sum of the matrix"<< sum(m,4) << endl;
Its only displaying the matrix and not asking what to input. Assingment is late so any help would be great! Thanks man!