In this assignment the user has to input a matrix and then the program has to show that matrix and the transpose of it. I've got that part running. My teacher added a tweak. Basically when the user inputs the matrix the program has to only ask the number of columns. And then from there when the user has to input the matrix in matrix form. like for example i tell the program there are 2 columns then i write 12 23
#include<stdio.h>
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;
}
4 5
so then it understands there are 2 rows. I have NO IDEA! here is my code.