/* * "Make change": * Prompt for number of cents. * Compute counts of dollars, quarters, etc. and print. */ #include int main(void) { /* * this variable will initially hold the input and then be modified * as we take out dollars, quarters, etc. * * (a better name would be "cents_remaining" but that is a lot to type) */ int cents; printf("enter number of cents:\n"); /* * return value from scanf is what we will use later for error * checking -- print for now to find out how it works */ int r = scanf("%d", ¢s); printf("did input succeed? %d (1 means yes)\n", r); printf("input: %d\n", cents); int dollars = cents / 100; cents = cents % 100; int quarters = cents / 25; cents = cents % 25; int dimes = cents / 10; cents = cents % 10; int nickels = cents / 5; cents = cents % 5; int pennies = cents; printf("%d dollars\n", dollars); printf("%d quarters\n", quarters); printf("%d dimes\n", dimes); printf("%d nickels\n", nickels); printf("%d pennies\n", pennies); return 0; }