Hey so Im writing a program for a user to enter a matrix and then I give its transpose and the product of the transpose and the matrix. There are 2 problems I am having. The first is I want to use the exit function. So if the user enter -2 as one of the matrix entries I want the program to say wring value and exit. But for some reason its not working. The second is I am not getting the correct answer for the product of transpose and matrix. PLEASE HELP ME!
Code:#include<stdio.h> int main() { int m, n, c, d, matrix[10][10], transpose[10][10]; printf("Enter the number of rows and columns of matrix "); scanf("%d%d",&m, &n); printf("Enter the elements of matrix \n"); for( c = 0 ; c < m ; c++ ) { for( d = 0 ; d < n ; d++ ) { scanf("%d",&matrix[c][d]); } } printf("\nHere is your matrix:\n"); for(c=0;c<m;c++) { for(d=0;d<n;d++) { printf("%d ",matrix[c][d]); } printf("\n"); } for( c = 0 ; c < m ; c++ ) { for( d = 0 ; d < n ; d++ ) { transpose[d][c] = matrix[c][d]; } } printf("Transpose of entered matrix :-\n"); for( c = 0 ; c < n ; c++ ) { for( d = 0 ; d < m ; d++ ) { printf("%d\t",transpose[c][d]); } printf("\n"); } printf("The product of matrix and transpose is %d:", matrix[c][d] * transpose[c][d]); return 0; }



LinkBack URL
About LinkBacks



