#include #include int main(void) { int amount; /* how much change the user has */ int leftover; /* used to hold amount as it decreases */ int numquarters; /* how many quarters */ int numdimes; /* how many dimes */ int numnickels; /* how many nickels */ int numpennies; /* how many pennies */ int retval = 0; /* return value of scanf */ /* read in the amount and save it */ printf("Enter amount of change: "); while(retval != 1){ retval = scanf("%d", &amount); if (retval == EOF){ printf("\n"); exit(0); } if (amount < 0){ fprintf(stderr, "Please enter a non-negative integer\n"); } } leftover = amount; /* computer the number of quarters and how much is left over */ numquarters = leftover / 25; leftover = leftover % 25; /* computer the number of dimes and how much is left over */ numdimes = leftover / 10; leftover = leftover % 10; /* computer the number of nickels and how much is left over */ numnickels = leftover / 5; leftover = leftover % 5; /* whatever is left over is the number of pennies */ numpennies = leftover; /* print the result */ printf("%d cents is %d quarters, %d dimes, %d nickels, and %d pennies\n", amount, numquarters, numdimes, numnickels, numpennies); /* thank you, and goodnight! */ exit(0); }