Que: Write a program to accept 9 numbers in the form of matrix and display in matrix form.
A matrix is the rectangular array of
numbers.
Code:
#include <stdio.h>
void main()
{
int array [3][3];
int i,j;
printf("Input elements in the matrix :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("element - [%d],[%d] : ",i,j);
scanf("%d",&array [i][j]);
}
}
printf("\nThe matrix is : \n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
printf("%d\t",array[i][j]);
}
printf("\n\n");
}
Output:
No comments:
Post a Comment