what is the program to add two number using recursion in C?
Riya Answered question December 19, 2023
Base Case:
If the second number is 0, return the first number. This serves as the stopping condition for the recursion.
Recursive Case:
If the second number is not 0, add 1 to the first number and decrement the second number.
Call the function recursively with the updated values.
Riya Answered question December 19, 2023
- Suppose the user entered 20.
- Initially, addNumbers() is called from main() with 20 passed as an argument.
- The number 20 is added to the result of addNumbers(19) .
- In the next function call from addNumbers() to addNumbers() , 19 is passed which is added to the result of addNumbers(18) .
Shathana. S.R. Answered question September 7, 2023
