0% found this document useful (0 votes)
12 views

Week 6 Assignment

Uploaded by

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

Week 6 Assignment

Uploaded by

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

NAME: CHUKWUEMEKA ESTHER NMESOMA

MATRIC NO: 2022/11575


DEPT: COMPUTER ENGINEERING
CEN 301 ASSIGNMENT

Develop a program to find the transpose of a matrix.

#include <stdio.h>

int main() {
int rows, cols, i, j;

printf("Enter the number of rows and columns of the matrix: ");


scanf("%d %d", &rows, &cols);

int matrix[rows][cols];

printf("Enter the elements of the matrix:\n");


for (i = 0; i < rows; i++) {
for (j = 0; j < cols; j++) {
scanf("%d", &matrix[i][j]);
}
}

int transpose[cols][rows];

// Transpose the matrix


for (i = 0; i < cols; i++) {
for (j = 0; j < rows; j++) {
transpose[i][j] = matrix[j][i];
}
}

printf("Transpose of the matrix:\n");


for (i = 0; i < cols; i++) {
for (j = 0; j < rows; j++) {
printf("%d ", transpose[i][j]);
}
printf("\n");
}

return 0;
}

You might also like