Article by: Manish Methani
Last Updated: September 26, 2021 at 10:04am IST
The transpose of a matrix is obtained by changing its rows into columns and its columns into rows. A rectangular array of numbers or functions that are arranged in the form of rows and columns is called a matrix.
#include <stdio.h> #define NUMBEROFROWS 10 #define NUMBEROFCOLS 10 int main() { int matrix[NUMBEROFROWS][NUMBEROFCOLS]; int i,j,row,col; printf("Enter number of Rows :"); scanf("%d",&row); printf("Enter number of Cols :"); scanf("%d",&col); printf("Enter matrix elements :"); for(i=0;i< row;i++) { for(j=0;j< col;j++) { printf("Enter element [%d,%d] : ",i+1,j+1); scanf("%d",&matrix[i][j]); } } printf("Transpose Matrix is :"); for(i=0;i< col;i++) { for(j=0;j < row;j++) { printf("%d ",matrix[j][i]); /*print elements*/ } printf(" "); /*after each row print new line*/ } return 0; }
Enter number of Rows :2 Enter number of Cols :3 Enter matrix elements : Enter element [1,1] : 10 Enter element [1,2] : 11 Enter element [1,3] : 12 Enter element [2,1] : 13 Enter element [2,2] : 14 Enter element [2,3] : 15 Transpose Matrix is : 10 13 11 14 12 15
Level: Advanced
Course Fees: INR 6999/-
Apply Coupon Code: UNLOCK
4 days 100% Money Back Guarantee
Explore CurriculumLevel: Intermediate
Course Fees: INR 1299/-
4 days 100% Money Back Guarantee
Explore CurriculumLevel: Beginners
Course Fees: INR 1299/-
4 days 100% Money Back Guarantee
Explore CurriculumLevel: Beginners
Course Fees: INR 1299/-
4 days 100% Money Back Guarantee
Coming SoonLevel: Beginners
Course Fees: FREE
Start WatchingTest your C Programming skills with this comprehensive mock test on C Programming.
Take TestSolve most asked Interview Questions on Flutter and Test your foundational skills in flutter.
Take TestSolve most asked GATE Questions in Operating Systems and test your Gate Score.
Take TestThis is a mock test designed to help you assess your knowledge and skills in HTML and CSS.
Take TestSolve most asked GATE Questions in Data Structures and Algorithms and test your Gate Score.
Take Test