0

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;
printf=("i\n",coins);

1 Answer 1

0

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.

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

You must log in to answer this question.

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