Thursday, 21 June 2012

program 19

#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],i,j,temp;
clrscr();
printf("\nenter the element of matrix :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=i+1;j<3;j++)
{
temp=a[i][j];
a[i][j]=a[j][i];
a[j][i]=temp;
}
}
printf("\nthe display of matrix is :\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
getch();
}
/*
enter the element of matrix :                                                   
1 4 5                                                                           
7 8 9                                                                           
3 6 9                                                                           
                                                                                
the display of matrix is :                                                      
1       7       3                                                               
4       8       6                                                               
5       9       9                                                               
   */

No comments: