Pages

Sunday, 20 May 2012

program to print a String of 3*3 matrics


92./*Write a program to print a String of 3*3 matrics*/

#include<stdio.h>
#include<conio.h>
main()
{
int mat[3][3];
int i,j;
clrscr();
printf("Enter a 3 X 3 array:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&mat[i][j]);
}
}
printf("The array in the matrix form is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("MAT[%d][%d] =%d\t\t",i,j,mat[i][j]);
}
}
 getch();
}


OUTPUT
            Enter a 3 X 3 array:
            1
            2
            3
            4
            5
            6
            7
            8
            9
The array in the matrix form is
MAT[0][0]=1              MAT[0][1]=2              MAT[0][2]=3
MAT[1][0]=4              MAT[1][1]=5              MAT[1][2]=6
MAT[2][0]=7              MAT[2][1]=8              MAT[2][2]=9

No comments:

Post a Comment