0

I programmed greedy.c and when I try to compie it there is one error coming up and I have no clue how to fix it. Thats my code:

include

include

include

int main(void) { float dollars; int amount int count = 0;

do
{
printf ("how much change is owed?: \n");
dollars = GetFloat ();
}

while (dollars <= 0);

amount = round(dollars*100);

while ( amount >= 25)
{ count ++;
amount -= 25;
}

while ( amount >=10)
{ count++;
amount-= 10;
}

while (amount >= 5)
{ count++;
amount-=5;
}
while ( amount >= 1)
{ count++;
amount -= 1;
}

printf ("%d\n, count");

return 0;

} And error is: greedy.c:40:15: error: more '%' conversions than data arguments [-Werror,-Wformat] printf ("%d\n, count") Does anyone have an idea? Thank you!

0

The closing quote is in the wrong place.

printf ("%d\n, count");

The compiler sees the variable count that corresponds to the %d placeholder as part of the string to be printed and is looking for something else to match up to the placeholder. The closing double quote should be between the \n and the comma.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1
  • Thank you! It´s always these tiny mistakes that I don´t see because I am looking for a big mistake... It compiles now! Hallelujah!
    – user10882
    Mar 9 '16 at 16:39

You must log in to answer this question.

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