In this example, You learn about c program for mirror image of matrix.
Here you learn mirror image of matrix in C, You are given a matrix of N*N and the task of the program to find mirror image of matrix.
C Program to Print Mirror Image of Matrix
#include<stdio.h>
int main()
{
int r,i,j;
printf("Enter number of rows:");
scanf("%d",&r);
int a[r][r];
printf("Enter %d matrix elements:\n",r*r);
for(i=0;i<r;i++)
{
for(j=0;j<r;j++)
scanf("%d",&a[i][j]);
}
printf("Matrix Elements:\n");
for(i=0;i<r;i++)
{
printf("\n");
for(j=0;j<r;j++)
{
printf("%d\t",a[i][j]);
}
}
printf("\nMirror Image of Matrix:\n");
for(i=0;i<r;i++)
{
printf("\n");
for(j=r-1;j>=0;j--)
{
printf("%d\t",a[i][j]);
}
}
return 0;
}
OutputEnter Number of rows and cols:3 Matrix Elements: 3 8 4 7 9 2 7 5 1 Mirror Image of Matrix: 4 8 3 2 9 7 1 5 7
No comments:
Post a Comment
If you have any doubts, Please let me know