Skip to content

Instantly share code, notes, and snippets.

@ShekharReddy4
Last active July 23, 2016 21:09
Show Gist options
  • Save ShekharReddy4/b49ca17b792666d7c4adbe20b0cb882c to your computer and use it in GitHub Desktop.
Save ShekharReddy4/b49ca17b792666d7c4adbe20b0cb882c to your computer and use it in GitHub Desktop.
#include <stdio.h>
int* transpose_matrix(int **matrix, int order){
int tmatrix[3][3];
int i,j,k;
for ( i = 0; i < order; i++) {
for ( j = 0; j < order; j++) {
matrix[i][j] = tmatrix[j][i];
}
}
return tmatrix;
}
void main() {
int order=3;
int matrix[3][3];
int **tpointer;
int detofmatrix;
int i,j;
printf("enter the elements in the matrix\n" );
for ( i = 0; i < order; i++) {
for ( j = 0; j < order; j++) {
scanf("%d",matrix[i][j]);
}
}
//detofmatrix = determinant(matrix,order);
//printf("determinant of the given matrix is : %d", detofmatrix);
printf("transpose of the given matrix is : \n");
tpointer = transpose_matrix(matrix, 3);
for ( i = 0; i < order; i++) {
for ( j = 0; j < order; j++) {
printf("%d ", tpointer[i][j]);
}
printf("\n");
}
}
@ShekharReddy4
Copy link
Author

this is a wrong approach, In c we cannot return the entire array by a function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment