Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3. #include <math.h>
  4.  
  5. int main(void)
  6.  
  7.  
  8. {
  9. float n;
  10. do
  11. {
  12. n = get_float("Change owed:");
  13. }
  14. while(n < 0);
  15.  
  16. int x;
  17. x=round(n*100);
  18.  
  19.  
  20. int coin=0 ;
  21. while (x>=25)
  22. {
  23. x=x-25;
  24. coin++;
  25. }
  26. while (x>=10)
  27. {
  28. x=x-10;
  29. coin++;
  30. }
  31. while (x>=5)
  32. {
  33. x=x-5;
  34. coin++;
  35. }
  36. while (x>=1)
  37. {
  38. x=x-1;
  39. coin++;
  40. }
  41. printf("I have used %i coins\n", coin);
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement