Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3. #include <math.h>
  4.  
  5.  
  6. int main(void)
  7. {
  8. float n;
  9. int count;
  10.  
  11.  
  12. do
  13. {
  14. printf("O hai! How much change is owed?\n");
  15. n = get_float();
  16. }
  17.  
  18. while (n < 0);
  19.  
  20. int iznos = round(n*100);
  21.  
  22. count=0;
  23.  
  24. while (iznos >= 25)
  25. {
  26. count++;
  27. iznos -= 25;
  28. }
  29.  
  30. while (iznos >= 10)
  31. {
  32. count++;
  33. iznos -= 10;
  34. }
  35.  
  36.  
  37. while (iznos >= 5)
  38. {
  39. count++;
  40. iznos -= 5;
  41. }
  42.  
  43.  
  44. while (iznos >= 1)
  45. {
  46. count++;
  47. iznos -= 1;
  48. }
  49.  
  50.  
  51. printf("%d\n", count);
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement