Advertisement
apl-mhd

recursion

Dec 6th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.24 KB | None | 0 0
  1. #include<stdio.h>
  2. void spendMoney(int n){
  3. n = n - 1;
  4. if(n < 0)
  5.     return;
  6.  
  7.  
  8. spendMoney(n); /* function calls itself */
  9.  
  10. printf("Your wallet balance: %d\n",n);
  11.  
  12. }
  13. int main(){
  14. printf("Hello Mr. COBB!\n");
  15. spendMoney(5);
  16. return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement