Login to ask a question from Arrays

Write a C program to find transpose of a matrix.

Write a C program to find transpose of a matrix.

#include 
int main()
 {
    int a[10][10], transpose[10][10], r, c, i, j;
    printf("Enter rows and columns: ");
    fflush(stdout);
    scanf("%d %d", &r, &c);
    // Assigning elements to the matrix
    printf("\nEnter matrix elements:\n");
    for (i = 0; i < r; ++i)
    {
        for (j = 0; j < c; ++j)
         {
            printf("Enter element a%d%d: ", i + 1, j + 1);
            fflush(stdout);
            scanf("%d", &a[i][j]);
        }
    }
    // Displaying the matrix a[][]
    printf("\nEntered matrix: \n");
    for (i = 0; i < r; ++i)
    {
        for (j = 0; j < c; ++j)
         {
            printf("%d  ", a[i][j]);
            if (j == c - 1)
            {
                printf("\n");
            }
        }
    }
    // Finding the transpose of matrix a
    for (i = 0; i < r; ++i....
Show More
Previous Question Next Question
🔗

Similar Questions

From Arrays · C programming

View All
WhatsApp