Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- int main(void)
- {
- float n = get_float("Amount of Change \n");
- int r = 0;
- {
- do
- {
- printf("amount \n");
- n = get_float();
- }
- while (n < 0);
- }
- int x = n*100;
- //prompt user
- //keep track of coins used
- //q, d, n, p
- while (x >= 25)
- {
- r += 1;
- x = x - 25;
- }
- while (x >= 10)
- {
- r+= 1;
- x = x - 10;
- }
- while (x >= 5)
- {
- r +=1;
- x = x - 5;
- }
- while (x >= 1)
- {
- r += 1;
- x = x - 1;
- }
- printf("\n");
- printf("%d\n",r);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement