im trying to fix this while loop but keep running into errors. Basically lets pretend I have 4 turtles, for every turtle that I sell I get a coin. Once I get to 0 I want to print how many coins I have. The error im getting is this,
error parentheses around assignment
used as truth value make: *** [cents]
Error 1
Here is the code:
while (turtles > 0) {
turtles = turtles - 1;
coin++;
if (turtles = 0)
printf("Now you have %d coins\n", coin);
}
Be glad that your compiler gave you that error.
You are assigning 0 to
turtlesin your if condition:I suppose you are trying to test if it is equal to 0. Then it should be two equals
==for equality instead.