Float in array

Hello

I am from poland so please do not use advanced english.

I have problem I have something like this:

float arg[99];

for (i=x_p;i<=n;i++)
{

arg[i] = x_p + ((i/n)*(x_k - x_p));

}

Why if I display arg i have only for example 0 not 0,2 0,4 0,6....
Problem is not in var's x_p because when I used 7/i in loop i had 3 not 3,5 etc
Look at this snippet:
arg[i] = x_p + ((i/n)*(x_k - x_p));

What type of variable is x_p? i? n? x_k? And what are their values prior to the loop?

I suppose that both i and n are integers. In this case i/n is 0 in every case except last, where it is 1 due to integer division taking place.

Cast one of the variables to float before calculations
Topic archived. No new replies allowed.