0% found this document useful (0 votes)
1 views2 pages

C Programming EX5a

The document outlines a C program designed to compute the transpose of a given matrix. It includes an algorithm detailing the steps to read a matrix, calculate its transpose, and print the result. The program successfully executes these tasks, confirming the functionality of the transpose operation.

Uploaded by

Malathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

C Programming EX5a

The document outlines a C program designed to compute the transpose of a given matrix. It includes an algorithm detailing the steps to read a matrix, calculate its transpose, and print the result. The program successfully executes these tasks, confirming the functionality of the transpose operation.

Uploaded by

Malathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

EX.

NO: 5a TRANSPOSE OF A MATRIX


DATE:

AIM
To write a C program to find the transpose of a given matrix.

ALGORITHM:
Step 1: Start
Step 2: Declare matrix a[m][n] of order mxn
Step 3: Read matrix a[m][n] from User
Step 4: Declare matrix t[n][m] of order nxm
Step 5: Find Transpose of Matrix as follows
Declare variables i, j
Set i=0, j=0
Repeat until i < n
Repeat until j < m
t[i][j] = a[j][i]
j=j+1
i=i+1
Step 6: Print matrix t
Step 7: Stop

PROGRAM:
#include <stdio.h>
#include <conio.h>
void main() {
int a[10][10], transpose[10][10], r, c;
clrscr();
printf("Enter rows and columns: ");
scanf("%d %d", &r, &c);
printf("\n Enter matrix elements:\n");
for (int i = 0; i < r; ++i)
for (int j = 0; j < c; ++j) {
printf("Enter element a %d %d: ", i + 1, j + 1);
scanf("%d", &a[i][j]);
}
printf("\n Entered matrix: \n");
for (int i = 0; i < r; ++i)
{
for (int j = 0; j < c; ++j) {
printf("%d ", a[i][j]);
}
printf("\n");
}
// computing the transpose
for (int i = 0; i < r; ++i)
for (int j = 0; j < c; ++j) {
transpose[j][i] = a[i][j];
}

// printing the transpose


printf("\n Transpose of the matrix:\n");
for (int i = 0; i < c; ++i) {
for (int j = 0; j < r; ++j)
{
printf("%d ", transpose[i][j]);
}
printf("\n");
}
getch();
}

RESULT:
Thus, the C program to find the transpose of a given matrix was
executed successfully.

You might also like