Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. choice = menu();
  2.  
  3.  
  4. // Execute the appropriate choice.
  5. if (choice == 1) {
  6. dobuy(&cash, &numchips);
  7. }
  8. else if (choice == 2) {
  9. dosell(&cash, &numchips);
  10. }`
  11.  
  12. void dosell(int *cash, int *numchips) {
  13.  
  14. int numsell;
  15.  
  16. // Determine the number of chips to be sold.
  17. printf("How many chips do you want to sell?n");
  18. scanf("%d", &numsell);
  19.  
  20. // Print out the error message if this is too much.
  21. if (numsell > *numchips)
  22. printf("Sorry, you do not have that many chips. No chips sold.n");
  23.  
  24. // Execute the transaction.
  25. else {
  26. (*cash) += sellchips(numsell);
  27. (*numchips) -= numsell;
  28. }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement