The Code given below can be used in TURBO C++ Compilers: -
#include <iostream.h>
#include <conio.h>
void main ()
{
clrscr();
int i, j, x, y;
int num[3][3];
cout<<"Enter the elements of the 3x3 matrix:"<<endl;
for (i=0; i<3; i++)
{
for (j=0; j<3; j++)
cin>>num[i][j];
}
cout<<"The mirror of the matrix is:"<<endl;
for (i=2; i>=0; i--)
{
for (j=0; j<3; j++)
{
cout<<num[i][j]<<" ";
}
cout<<endl;
}
getch();
}
The Code given below can be used in gcc/g++ Compilers: -
#include <iostream>
using namespace std;
int main()
{
int i, j, x, y, n;
cout<<"Enter the order of the matrix: ";
cin>>n;
int num[n][n];
cout<<"Enter the elements of the matrix:"<<endl;
for (i=0; i<n; i++)
{
for (j=0; j<n; j++)
cin>>num[i][j];
}
cout<<"The mirror of the matrix is:"<<endl;
for (i=n-1; i>=0; i--)
{
for (j=0; j<n; j++)
{
cout<<num[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP