Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- #include <math.h>
- int main(void)
- {
- float n;
- do
- {
- n = get_float("Change owed:");
- }
- while(n < 0);
- int x;
- x=round(n*100);
- int coin=0 ;
- while (x>=25)
- {
- x=x-25;
- coin++;
- }
- while (x>=10)
- {
- x=x-10;
- coin++;
- }
- while (x>=5)
- {
- x=x-5;
- coin++;
- }
- while (x>=1)
- {
- x=x-1;
- coin++;
- }
- printf("I have used %i coins\n", coin);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement