print matrix c 2b 2b

Solutions on MaxInterview for print matrix c 2b 2b by the best coders in the world

showing results for - "print matrix c 2b 2b"
Emanuele
02 Jan 2019
1#include <iostream>
2
3using namespace std;
4
5int matrix[3][3];
6
7int main()
8{
9    // asigning values, I suppose this is done allready.
10
11    for(int x=0;x<3;x++)
12    {
13        for(int y=0;y<3;y++)
14        {
15            matrix[x][y]=1;
16        }
17    }
18
19    // showing the matrix on the screen
20
21    for(int x=0;x<3;x++)  // loop 3 times for three lines
22    {
23        for(int y=0;y<3;y++)  // loop for the three elements on the line
24        {
25            cout<<matrix[x][y];  // display the current element out of the array
26        }
27    cout<<endl;  // when the inner loop is done, go to a new line
28    }
29    return 0;  // return 0 to the OS.
30}