-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhellomatrix.cpp
More file actions
31 lines (28 loc) · 811 Bytes
/
hellomatrix.cpp
File metadata and controls
31 lines (28 loc) · 811 Bytes
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
// File: Hello/hellomatrix.cpp
// Author: MihAela Malita
// Title: Initialize and print a matrix 2 x 2
/******************************************************
Matrix is:
1 2
3 4
********************************************************/
#include <iostream>
using namespace std;
const int N=2; // actual size
void printMatrix(int A[][N]);
/////////////////////////////////////////////////////////////
int main() { // generate a matrix and check property
int A[2][2] = {{1,2}, {3,4}}; // declare matrix
printMatrix(A);
return 0;
}
/////////////////////////////////////////////////////////////
void printMatrix(int X[][N]) {
cout << "\nMatrix is:\n";
for (int i=0; i< N; i++) {
for (int j=0; j < N ; j++) {
cout << X[i][j] << " ";
}
cout << endl;
}
}