Guest User

Untitled

a guest
Jan 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. double change( int tot );
  4. double twenties;
  5. double tenners;
  6. double fivers;
  7. double poundcoins;
  8.  
  9.  
  10. void main()
  11. {
  12. int splitchange;
  13. int totalmoney = 20;
  14. splitchange = change ();
  15.  
  16. printf("£20 consists of %d \n", splitchange );
  17. printf("number of twenties %d \n", twenties);
  18. }
  19.  
  20. double change ( int tot)
  21. {
  22. double answer;
  23.  
  24. if ((tot % 20) == 0)
  25. {
  26. twenties = tot/20;
  27. }
  28.  
  29. if (tot % 10 ==0)
  30. {
  31. tenners = (tot-(tot % 20))/10;
  32.  
  33. }
  34.  
  35. if (tot % 5 ==0)
  36. {
  37. fivers = (tot-(tot % 20)-(tot % 10))/5;
  38. }
  39.  
  40. if (tot % 10 ==0)
  41. {
  42. poundcoins = (tot-(tot % 20)-(tot % 10)-(tot % 5))/1;
  43.  
  44. }
  45. return( answer );
  46.  
  47. }
Add Comment
Please, Sign In to add comment