# Multidimension array problem. I can't figure out why the last column is different

Discussion in 'C' started by warmsheet, Sep 21, 2009.

1. ### warmsheetNew Member

Joined:
Sep 21, 2009
Messages:
4
0
Trophy Points:
0
I'm sorry. I really need help on this. I even made a shorter and simpler program that I think is enough to show my problem.

This is the example program:

Code:
```#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
int i, j, deg, points;

printf("Enter degree of polynomial equation: "); scanf("%i", &deg);
printf("Enter number of points: "); scanf("%i", &points);
float xs[points-1], Fmat[points][deg];
for(i=0; i<points; i++)
{printf("x%i = ", i); scanf("%f", &xs[i]);}
printf("\n");

for(i=0; i<points; i++)
for(j=0; j<deg+1; j++)
Fmat[i][j]=pow(xs[i],1);

for(i=0; i<points; i++)
{for(j=0; j<=deg; j++)
printf("%ii%ij:%7.3f\t", i,j,Fmat[i][j]);
printf("\n");}

system("PAUSE");
return 0;
}```

Now, my problem is that it is printing (and probably storing) the right values EXCEPT on the last column.

This is greatly confusing me and I've spent my whole night trying to figure it out (to no avail, obviously). I'm sorry for the dumbness of my problem but will somebody please help me figure it out??

Last edited by a moderator: Sep 22, 2009
2. ### warmsheetNew Member

Joined:
Sep 21, 2009
Messages:
4
0
Trophy Points:
0
Sample output: img28.imageshack.us/i/output.jpg/
Screenshot of program: img142.imageshack.us/i/programl.jpg/

3. ### warmsheetNew Member

Joined:
Sep 21, 2009
Messages:
4
0
Trophy Points:
0
And I'm sorry. It's late that I read I need to enclose the code within code. I can't seem to edit it. I'm really sorry.

Joined:
Sep 21, 2009
Messages:
4