Beginner C Programming Question
In my introduction to computer programming course i was a given a project asking to create a change maker. Specifically, i must write a program that will make change in coins for any amount up to 99 cents using the fewest possible coins. The program should prompt the user to enter an amount, and then print out the number of each type of coin to make that amount of change. If there are no coins of a particular type, then the program should not print a line for that coin.
Enter the change amount: 93
Enter the change amount: 89
This is what i have so far. The program works unless the "change" value falls under 25 so i'm assuming the problem involves the "if" statements. I have been stuck for a while and was hoping a misc brah could help me out with some suggestions.
printf ("Please enter an amount of change from 0-99.\n");
scanf ("%d", &change);
coins = change/25;
printf ("Quarters: %d\n", coins);
remainder = change%25;
coins = remainder/10;
printf ("Dimes: %d\n", coins);
remainder = remainder%10;
coins = remainder/5;
printf ("Nickles: %d\n", coins);
remainder = remainder%5;
printf ("Pennies: %d\n", remainder);
Well, just put a little thought into it. If the value of change starts out less than 25, are which of your if statements are going to be executed?
I ♥ ManiacDan & requinix
This is a sig, and not necessarily
a comment on the OP:
don't be a help vampire