Slip no : 26_2 write a C prog to display
transpose of matrix using user defined function
#include<stdio.h>
#include<conio.h>
void
transpose(int m[10][10],int r,int c)
{
int i,j;
printf("\n
Transpose of matrix : \n"); for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("%d\t",m[j][i]);
}
printf("\n");
}
}
int main()
{
int r,c,i,j,m[10][10];
printf("\n
Enter no of rows and columns : "); scanf("%d %d",&r,&c);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("\n
Enter element : "); scanf("%d",&m[i][j]);
}
}
transpose(m,r,c);
getch();
}
No comments:
Post a Comment