Monday, December 13, 2010

Program to find the transpose of the matrix of nth order

#include<stdio.h>
int main()
{
    int i,j,a[10][10],m,n;
    printf("Enter the no.of rows and columns:");
    scanf("%d%d",&m,&n);
    printf("\nEnter the elements of Matrix:\n");
    for(i=0;i< m;i++)
    for(j=0;j< n;j++)
    {
        printf("Enter element a[%d][%d]:",i+1,j+1);
        scanf("%d",&a[i][j]);
    }
    printf("\nThe original matrix is:\n");
    for(i=0;i< m;i++)
    {
    for(j=0;j< n;j++)
    {
     printf("%d\t",a[i][j]);
    }
    printf("\n");
    }
    printf("\nThe transposed matrix is:\n");
    for(i=0;i< n;i++)
    {
        for(j=0;j< m;j++)
        {
            printf("%d\t",a[j][i]);
        }
        printf("\n");
    }
    return 0;
}

No comments:

Post a Comment