C Program to Print Transpose of a Matrix

Get Certified in C Programming and Take Your Skills to the Next Level

Program 1

// Program for Transpose of Matrix
#include<stdio.h>
#include<conio.h>
int main()
{
    int a[50][50],r,c,m,n;
    printf("Enter the values of Rows and Cols");
    scanf("%d %d",&m,&n);
    printf("Enter elements in matrix");
    for(r=0;r<m;r++)
    {
        for(c=0;c<n;c++)
        scanf("%d",&a[r][c]);
    }
    for(r=0;r<m;r++)
    {
        for(c=0;c<n;c++)
        { 
            printf("%5d",a[r][c]);
        }
     printf("\n\n");
    }
 printf("\n Transpose of Matrix is : \n");
    for(r=0;r<m;r++)
    {
        for(c=0;c<n;c++)
        { 
            printf("%5d",a[c][r]);
        }
     printf("\n\n");
    }
    return 0;
}

 

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *