Write a program in c++ to input and print 3X3 Matrix
#include <iostream>
using namespace std;
int main()
{
int a[3][3];
cout << "Enter Elements of Array : ";
//Loo-p to Enter Elements
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cin >> a[i][j];
}
}
// Loop to print Matrix
cout<<"3x3 Matrix :"<<endl;
for (int i = 0; i < 3; i++)
{
cout << endl;
for (int j = 0; j < 3; j++)
{
cout << a[i][j] << " ";
}
}
return 0;
}
OUTPUT
Enter Elements of Array : 12
34
56
23
45
67
11
32
87
3x3 Matrix :
12 34 56
23 45 67
11 32 87
Thank you for helping with my class work
ReplyDeleteWelcome
Delete