CPP   70

recursion

Guest on 20th April 2022 02:12:12 AM

  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void decrement(int i) {
  5.     cout << i << endl;
  6.     i--;
  7.  
  8.     if(i>0)
  9.         decrement(i);
  10.     cout << "after: " << i << endl;
  11. }
  12.  
  13. int main() {
  14.  
  15.     decrement(10);
  16.  
  17.     return 0;
  18. }

Raw Paste


Login or Register to edit or fork this paste. It's free.