Advertisement
Guest User

Untitled

a guest
Jan 4th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3.  
  4. int main(void)
  5. {
  6. float n = get_float("Amount of Change \n");
  7. int r = 0;
  8.  
  9. {
  10. do
  11. {
  12. printf("amount \n");
  13. n = get_float();
  14. }
  15. while (n < 0);
  16. }
  17.  
  18.  
  19. int x = n*100;
  20.  
  21. //prompt user
  22.  
  23. //keep track of coins used
  24. //q, d, n, p
  25.  
  26. while (x >= 25)
  27. {
  28. r += 1;
  29. x = x - 25;
  30. }
  31. while (x >= 10)
  32. {
  33. r+= 1;
  34. x = x - 10;
  35. }
  36. while (x >= 5)
  37. {
  38. r +=1;
  39. x = x - 5;
  40. }
  41. while (x >= 1)
  42. {
  43. r += 1;
  44. x = x - 1;
  45. }
  46. printf("\n");
  47. printf("%d\n",r);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement