Program to find Transpose of a Matrix using Functions || Functions || C programming
In this, we are going to see a program in which we will find Transpose of a Matrix using functions in C programming Language.

// WAP to find Transpose of a Matrix using Functions

#include <stdio.h>

void transpose(int a[4][4], int b[4][4])
{
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            b[i][j] = a[j][i];
        }
    }
}

void main()
{
    int a[4][4] = {{1, 1, 1, 1}, {2, 2, 2, 2}, {3, 3, 3, 3}, {4, 4, 4, 4}};
    int b[4][4];

    printf("Original Matrix is: \n");
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            printf("%d ", a[i][j]);
        }
        printf("\n");
    }

    transpose(a, b);
    printf("Result Matrix is: \n");
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            printf("%d ", b[i][j]);
        }
        printf("\n");
    }
}

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post