C program to transpose the matrix

C program to transpose the matrix

#include <stdio.h<

int main()

{

    int a[10][10], i, j, row, col, trans[10][10];

    printf("Enter no. of rows:");

    scanf("%d", &row);

    printf("Enter no. of columns:");

    scanf("%d", &col);

    printf("Enter elements of matrix:");

    for (i = 0; i < row; i++)

    {

        for (j = 0; j < col; j++)

        {

            scanf("%d", &a[i][j]);
        }
    }

    printf("\nThe given matrix is :\n");

    for (i = 0; i < row; i++)

    {

        for (j = 0; j < col; j++)

        {

            printf("%d\t", a[i][j]);
        }

        printf("\n");
    }

    printf("\nThe matrix after transpose is :\n");

    for (i = 0; i < row; i++)

    {

        for (j = 0; j < col; j++)

        {

            trans[i][j] = a[j][i];

            printf("%d\t", trans[i][j]);
        }

        printf("\n");
    }
}

Comments

Popular posts from this blog

C Program for SCAN Disk Scheduling Algorithm | C Programming

C program to Find Cartesian Product of Two Sets | C programming

C Program To Check The String Is Valid Identifier Or Not | C Programming