C Programming Program that will prompt a user to enter an amount of money betwee
ID: 3746470 • Letter: C
Question
C ProgrammingProgram that will prompt a user to enter an amount of money between $0 and en using modulo, determine the minimum number of coins(quarters, dimes, nickels, and pennies) would total that amount. Read in the amount from the user as an int (S0.50 should be entered as 50) Hint: Use modulo...there was a similar challenge in section 2.6 of the book if you need help. Output the answer similarly to the example below e.g. "62 cents should be retumed as 2 Quarters, 1 Dime, 0 Nickles, and 2 Pennies" Test your program with 92 cents.
Explanation / Answer
#include int main() { int total; printf("Enter amount between 0 and 1: "); scanf("%d", &total); int quarters = (total / 25); total %= 25; int dimes = (total / 10); total %= 10; int nickels = (total / 5); total %= 5; int pennies = total; printf("%d Quarters, %d Dimes, %d Nickels, %d Pennies ", quarters, dimes, nickels, pennies); return 0; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.