CPP Cafe

The Menu

 

Home -> Menu ->Multidimensional Arrays

Matrix

output

//Multidimensional Arrays
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
const int numrows = 4;
const int numcols = 3;
void print(int grades[][numcols], int norows);

int main(){
int row;
int col;
int numcol;
int numrows;
//Table
int grades[4][3] = {{89,90,78},{89,70,92},{68,77,89},{89,90,77}};
print(grades, numrows);
cout<<endl;

return 0;
system("pause");
}
void print(int grades[][numcols], int norows){
int row, col;
for (row = 0; row <numrows; row++){
for(col = 0; col < numcols; col++)
cout<<setw(5)<<grades[row][col]<<" ";
cout<<endl;
}
}