Matrix Program in CPP

This program will take input from user a 3×3 matrix and print it into the form of matrix.

#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int m[3][3];
int i;

for (i=0; i <= 2;i++)
{
for (int j=0; j <= 2; j++)
{
cout << "Enter matrix elements";
cin >> m[i][j];
}
}
for (i=0; i <= 2; i++)
{
for (int j=0; j <= 2; j++)
{
cout << m[i][j] << "   ";
}
cout << endl;
}
getch();
}

Output:

eg: 1 2 3
    4 5 6
    7 8 9

Leave a Reply