Home
About
Desclaimer
Privacy Policy
Terms of Services
Python
C/C++
Java
HTML/CSS
Home
About
Desclaimer
Privacy Policy
Term of Services
Python
C/C++
Java
HTML/CSS
Ad Code
Responsive Advertisement
Categories
C Program
(10)
c++ Programs
(3)
Search This Blog
Powered by Blogger
December 2022
13
Report Abuse
About Me
Universal Programmers
View my complete profile
Home
C Program
Write a C program for Transpose of a Matrix. (Choose the order of as your own)
Write a C program for Transpose of a Matrix. (Choose the order of as your own)
Universal Programmers
December 30, 2022
Answer
Copy
#include
#include
int main(void) { / Declare a 2D array to store the matrix int matrix[3][3]; / Read the matrix from the user printf("Enter the elements of the matrix:\n"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { scanf("%d", &matrix[i] [j]); } }/ Print the original matrix printf("Original matrix:\n"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { printf("%d ", matrix[i][j]); } printf("\n"); } / Calculate the transpose of the matrix int transpose[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j+ +) { transpose[i][j] = matrix[j][i]; } }/ Print the transpose of the matrix printf("Transpose of the matrix:\n"); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { printf("%d ", transpose[i] [j]); } printf("\n"); } return 0; }
OUTPUT
C Program
Post a Comment
0 Comments
Social Plugin
Popular Posts
Subscribe Us
Facebook
Tags
Close Menu
0 Comments