20_10

Write a C program to find the transpose of a matrix.

Source code:

 //Write a C program to find the transpose of a matrix 

#include <stdio.h>

int main()

{

int array1[10][10], array2[10][10];

int i,j,row,col;

printf("Enter the number of row:");

scanf("%d",&row); 

printf("Enter the number of column:");

scanf("%d",&col); 

  printf("Enter the matrix:\n");

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

    {

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

        {

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

        }

    }

 /*Transpose a matrix */

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

    {

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

        {

            array2[i][j] = array1[j][i];    /*exchange elements*/

        }

    } 

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

    {

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

        {

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

        }

printf("\n");

    }

    return 0;

}

Output:
C program to find the transpose of a matrix


No comments:

Post a Comment

Write a program in C to convert a decimal number to binary using recursion.

 Source code: //Write a program in C to convert a decimal number to binary using recursion. #include<stdio.h> long convertB_to_D(int d...