Skip to main content
2 of 2
edited title

Pset1 Cash problem: error when trying to add quarters, dimes, nickels and pennies

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);