i would really appreciate it if someone can point out the problems in my code. Basically what i am trying to do is to calculate the numberĀ of quarters, dimes, nickels and pennies needed, and then add them all up in the end. However, when i run the program, it shows: "cash.c:24:13: error: expression result unused [-Werror,-Wunused-value] printf=("i\n",coins); ^~~~~ cash.c:24:11: error: non-object type 'int (const char *, ...)' is not assignable printf=("i\n",coins);" I couldn't figure out why, pls help! thank you so much in advance!

Here is my code

int quarters, dimes, nickels, pennies, coins, cents;
cents = round(dollar*100);

quarters = round(cents/ 25);
dimes = round((cents-quarters*25) / 10);
nickels = round((cents-quarters*25-dimes*10) / 5);
pennies = round((cents-quarters*25-dimes*10-nickels*5) / 1);

coins = quarters+dimes+nickels+pennies;

Remove the = after printf, that shouldn't be an assignment, but a function call.

Also, you likely meant "%i\n", %i being a placeholder for an int-type variable printed as decimal number.

  • it worked, thank you so much Blauelf! and sorry for the careless mistake on my part, i forgot the %before i – cs50fan Mar 5 '20 at 9:32

You must log in to answer this question.

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