0

So I'm just trying to slowly navigate my way through this problem by seeing if I can get the total amount to subtract 25 from the float. I keep getting an error message that says


cash3.c:18:27: error: relational comparison result unused [-Werror,-Wunused-comparison] for (int coins = 0; i < 0.25, coins++)


Here is my coding so far:

int main(void)

{float n;
do
{
 n = get_float("number\n");
}
while (n <= 1);


int i = round(n * 100 );

for (int coins = 0; i < 0.25, coins++)
{
   printf("I have %i coins \n", coins);
    }
    }

Any hints from anyone out there as to why this isn't working as I want it to? I feel like I've got everything in the right spot. Thanks!

1 Answer 1

0
for (int coins = 0; i < 0.25, coins++)

Instead of a comma in the for loop we must put a semicolon. Regarding your error, it is a good warning from the compiler, the expression i <0.25 is never fulfilled, think about it, if you multiply n * 100, and n is greater than zero ... In addition, the variable i never changes inside the loop, which can lead to an infinite loop

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .