1. ## Floating point operand?

I written a code to work out the coordinates on a bezier curve but i keep getting the same errors,"0022/0023/0023/0024/0025 ERROR:A floating point operand to ^ is not permitted"

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

main()
{
float u,g,p,r,s,t,x,y;
int xr0,xr1,xr2,xr3,yr0,yr1,yr2,yr3,w0,w1,w2,w3;

u=0;

printf("Enter in r values for the x coordinates e.g. xr0,xr1,xr2,xr3");
scanf("%d,%d,%d,%d",&xr0,&xr1,&xr2,&xr3);
printf("Enter in r values for the y coordinates e.g. yr0,yr1,yr2,yr3");
scanf("%d,%d,%d,%d",&yr0,&yr1,&yr2,&yr3);
printf("Enter in w values e.g. w0,w1,w2,w3");
scanf("%d,%d,%d,%d",&w0,&w1,&w2,&w3);

if (u>0,u<1,u+0.2)
{
p=((1-u)^3);//line 22//
g=(3*(1-u)^2*u);//line 23//
s=(3*(1-u)*u^2);//line 24//
t=(u^3);//and surprisingly line 25//

x=((p*w0*xr0)+(g*w1*xr1)+(s*w2*xr2)+(t*w3*xr3))/((p*w0)+(g*w1)+(s*w2)+(t*w3));
printf("/n",x);

y=((p*w0*yr0)+(g*w1*yr1)+(s*w2*yr2)+(t*w3*yr3))/((p*w0)+(g*w1)+(s*w2)+(t*w3));
printf("/t",y);

}
else
return 0;

}```

2. ^ isn't raise to power of in C, its exclusive-or. See also bitwise and(&) and or(|)

Include math.h, and use things like
pow(1-u,2)

3. I think the powers work fine now, thanks for the help. Now the program isnt workin right, it now works fine until it gets to the if statement which is now completely ignored and it just ends the program without printing any results.
Code:
```#include<stdio.h>
#include<math.h>

main()
{
float u,g,p,s,t,x,y;
int xr0,xr1,xr2,xr3,yr0,yr1,yr2,yr3,w0,w1,w2,w3;

u=0;

printf("Enter in r values for the x coordinates e.g. x0,x1,x2,x3\n");
scanf("%d,%d,%d,%d",&xr0,&xr1,&xr2,&xr3);
printf("Enter in r values for the y coordinates e.g. y0,y1,y2,y3\n");
scanf("%d,%d,%d,%d",&yr0,&yr1,&yr2,&yr3);
printf("Enter in w values e.g. w0,w1,w2,w3\n");
scanf("%d,%d,%d,%d",&w0,&w1,&w2,&w3);

if (u=0,u<1)
{
p=(pow(1-u,3));
g=(3*(pow(1-u,2)*u));
s=(3*pow((1-u)*u,2));
t=pow(u,3);

x=((p*w0*xr0)+(g*w1*xr1)+(s*w2*xr2)+(t*w3*xr3))/((p*w0)+(g*w1)+(s*w2)+(t*w3));
printf("\n",x);

y=((p*w0*yr0)+(g*w1*yr1)+(s*w2*yr2)+(t*w3*yr3))/((p*w0)+(g*w1)+(s*w2)+(t*w3));
printf("\t",y);
u=(u+0.2);
}
else
return 0;

}```

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

int main(void) /* main returns an int */
{
float u, g, p, s, t, x, y;
int xr0, xr1, xr2, xr3, yr0, yr1, yr2, yr3, w0, w1, w2, w3;

u = 0;

printf("Enter in r values for the x coordinates e.g. x0,x1,x2,x3\n");
scanf("%d,%d,%d,%d", &xr0, &xr1, &xr2, &xr3);
printf("Enter in r values for the y coordinates e.g. y0,y1,y2,y3\n");
scanf("%d,%d,%d,%d", &yr0, &yr1, &yr2, &yr3);
printf("Enter in w values e.g. w0,w1,w2,w3\n");
scanf("%d,%d,%d,%d", &w0, &w1, &w2, &w3);

if (u = 0, u < 1) {
p = (pow(1 - u, 3));
g = (3 * (pow(1 - u, 2) * u));
s = (3 * pow((1 - u) * u, 2));
t = pow(u, 3);

x = ((p * w0 * xr0) + (g * w1 * xr1) + (s * w2 * xr2) +
(t * w3 * xr3)) / ((p * w0) + (g * w1) + (s * w2) + (t * w3));
printf("\n%f", x); /* you might want a format specifier here */

y = ((p * w0 * yr0) + (g * w1 * yr1) + (s * w2 * yr2) +
(t * w3 * yr3)) / ((p * w0) + (g * w1) + (s * w2) + (t * w3));
printf("\t%f\n\n", y); /* another format specifier here */
u = (u + 0.2);
}

/* You don't have to use the 'else' clause with an if statement */

return 0;

}```
Also, you should consider getting your input in another way besides using scanf(). But that's another story.

~/

5. Sorry to go off topic but how does

if(u = 0, u < 1) work? What does ',' do here ? Is it the same as
if(u = 0 && u < 1) ?

Also shouldn't it be u == 0 rather than u = 0 ?

6. > if(u = 0, u < 1) work?
Probably not as they wanted
Assign u the value of 0, then compare u to 1

Since it is now 0, the comparison is true, so its really
u = 0;
if ( 1 )

But then u started off with the value of 0, and was unmodified by any of the scanf() calls, so the whole 'u' and if() thing is redundant.

However, looking further on, it seems they really want
Code:
```for ( u = 0 ; u < 1 ; u += 0.2 ) {
p = (pow(1 - u, 3));
g = (3 * (pow(1 - u, 2) * u));
s = (3 * pow((1 - u) * u, 2));
t = pow(u, 3);
// etc...
}```

7. Thanks for all the help, the program works perfectly now:
Code:
```#include<stdio.h>
#include<math.h>

int main(void)
{
float u, g, p, s, t, x, y;
int xr0, xr1, xr2, xr3, yr0, yr1, yr2, yr3, w0, w1, w2, w3;
u = 0;

printf("Enter in r values for the x coordinates e.g. x0,x1,x2,x3\n");
scanf("%d,%d,%d,%d", &xr0, &xr1, &xr2, &xr3);
printf("Enter in r values for the y coordinates e.g. y0,y1,y2,y3\n");
scanf("%d,%d,%d,%d", &yr0, &yr1, &yr2, &yr3);
printf("Enter in w values in the format w0,w1,w2,w3\n");
scanf("%d,%d,%d,%d", &w0, &w1, &w2, &w3);

for ( u = 0 ; u < 1 ; u += 0.2 ) {
p = (pow(1 - u, 3));
g = (3 * (pow(1 - u, 2) * u));
s = (3 * pow((1 - u) * u, 2));
t = pow(u, 3);

x = ((p * w0 * xr0) + (g * w1 * xr1) + (s * w2 * xr2) + (t * w3 * xr3)) / ((p * w0) + (g * w1) + (s * w2) + (t * w3));
printf("For u = %f:   ", u);
printf("\nx  =  %f", x);

y = ((p * w0 * yr0) + (g * w1 * yr1) + (s * w2 * yr2) + (t * w3 * yr3)) / ((p * w0) + (g * w1) + (s * w2) + (t * w3));
printf("\ty  =  %f\n\n", y);
}
return 0;
}```