/*Program to Transpose of matrices*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a[100][100],t[100][100],i,j,r,c,n;
clrscr();
printf("Enter the no. of rows: ");
scanf("%d",&r);
printf("\nEnter the no. of cols: ");
scanf("%d",&c);
if(r!=c)
{
printf("\nRows and Columns must be same");
exit(0);
}
printf("\nEnter A Matrix\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("Enter the element %d %d: ",i+1,j+1);
scanf("%d",&a[i][j]);
}
}
printf("\nEnter A Matrix\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("\nTrapose Matrix\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
t[i][j]=a[j][i];
printf("%d\t",t[i][j]);
}
printf("\n");
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a[100][100],t[100][100],i,j,r,c,n;
clrscr();
printf("Enter the no. of rows: ");
scanf("%d",&r);
printf("\nEnter the no. of cols: ");
scanf("%d",&c);
if(r!=c)
{
printf("\nRows and Columns must be same");
exit(0);
}
printf("\nEnter A Matrix\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("Enter the element %d %d: ",i+1,j+1);
scanf("%d",&a[i][j]);
}
}
printf("\nEnter A Matrix\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("\nTrapose Matrix\n");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
t[i][j]=a[j][i];
printf("%d\t",t[i][j]);
}
printf("\n");
}
getch();
}
No comments:
Post a Comment