I want to write a program that does the following:
reads and integer matrix from stdin and outputs the input matrix, its transpose and multiplication of the input matrix with its transpose.
I limited the matrix to a 10x10.
I want to ask the user to enter a number of columns and then ask the user to input the elements in each row. I am currently stuck trying to understand what kind of stream function to use in order to store each number in each element of the matrix.
This is what I have:
#include<stdio.h>
int main(void)
{ // n - # of columns, i - counter.
int n, i, j, A[10][10];
//queries user for number columns
printf("Please enter the number of columns: ");
scanf("%d", &n);
//checks if # of 0<n<10. if not, returns error and exits
if(n>10 || n<0)
{
printf("Number of columns not supported\n");
exit(1);
}
//loop to enter the elements in each row
for (i = 0 ; i < n; i++)
{
for(j = 0; j < n; j++)
printf("Please enter the elements in row %d\n", i+1);
j = fgetc(stdin);
A[j][i];
printf("%d", A[j][i]);
}
return 0;
}
I know this is very incorrect but I am very new to programming.
Thanks!