# Matrix Table

Email
 Submitted on: 10/7/2016 9:20:07 PM By: Ben128 Level: Beginner User Rating: Unrated Compatibility: C++ (general), Microsoft Visual C++ Views: 2358

Code that shows how to display a matrix table using a 2d array. This will also show the max, min values in the table plus the total sum hope it help someome.

code:
Can't Copy and Paste this?
 ``` //************************************** // Name: Matrix Table // Description:Code that shows how to display a matrix table using a 2d array. This will also show the max, min values in the table plus the total sum hope it help someome. // By: Ben128 //************************************** // Print out a matrix table find the max,min and total sum of values in table. // By DreamVB 22:16 07/10/2016 #include using namespace std; using std::cout; using std::endl; int main(int argc, char *argv[]){ int i = 0; int j = 0; int max = 0; int min = 0; int sum = 0; const int ROWS = 4; const int COLS = 4; int matrix[ROWS][COLS] = { 1, 2, 3, 4, 5, 9, 4, 3, 4, 7, 2, 1, 8, 4, 3, 6 }; min = matrix[0][0]; //Print pretty matrix table for (i = 0; i < COLS; i++){ if (i < 1){ //Add headers cout << " " << (char)(65 + i); } else{ //Add headers cout << " " << (char)(65 + i); } } cout << endl; //Print matrix for (i = 0; i < ROWS; i++){ //Add rows cout << " " << (char)(65 + i); for (j = 0; j < COLS; j++){ cout << " " << matrix[i][j]; } //Add line break cout << endl; } cout << endl; //Find highest number in matrix for (i = 0; i < ROWS; i++){ for (j = 0; j < COLS; j++){ //Get the sum of matrix sum += matrix[i][j]; if (matrix[i][j]>max){ max = matrix[i][j]; } if (matrix[i][j] < min){ min = matrix[i][j]; } } } cout << "Max value in matrix is : " << max << endl; cout << "Min value in matrix is : " << min << endl; cout << "Sum of matrix is: " << sum << endl << endl; system("pause"); return 0; }```

Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)