Hi people. I hope my thread title is apt, I've got no idea why the following code won't work. Basically I want to take in 6 floating values and assign 4 in one array and 2 in a second, but they must be entered on one line and then the return key entered at the end. I would've thought that they would've just merrily waited for the six scanf calls to be put in place, but apparently not. If you run the code and type in, say, "1 2 3 4 5 6" then Enter, that is not what you end up with when I check with printf.
Can anyone see any glaring errors? Cheers.
Can anyone see any glaring errors? Cheers.
Rich (BB code):
#include <stdio.h>
main()
{
float A[1][1];
float b[1];
float x1, x2;
int m = 0 , n = 0;
printf("Enter 6 values for matrix and answers.\n");
for (m=0;m<2;m++)
{
for(n=0;n<2;n++)
{
scanf("%f", &A[m][n]);
}
}
for (m=0;m<2;m++)
{
scanf("%f", &b[m]);
}
printf("%f %f %f %f %f %f ", A[0][0], A[0][1], A[1][0], A[1][1], b[0], b[1]);
getchar();getchar();
}