Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double change( int tot );
- double twenties;
- double tenners;
- double fivers;
- double poundcoins;
- void main()
- {
- int splitchange;
- int totalmoney = 20;
- splitchange = change ();
- printf("£20 consists of %d \n", splitchange );
- printf("number of twenties %d \n", twenties);
- }
- double change ( int tot)
- {
- double answer;
- if ((tot % 20) == 0)
- {
- twenties = tot/20;
- }
- if (tot % 10 ==0)
- {
- tenners = (tot-(tot % 20))/10;
- }
- if (tot % 5 ==0)
- {
- fivers = (tot-(tot % 20)-(tot % 10))/5;
- }
- if (tot % 10 ==0)
- {
- poundcoins = (tot-(tot % 20)-(tot % 10)-(tot % 5))/1;
- }
- return( answer );
- }
Add Comment
Please, Sign In to add comment