filmov
tv
C Programming | Sum of Natural Numbers Using Recursion

Показать описание
#cprogramming #shorts #shortsvideo
C Programming | Sum of Natural Numbers Using Recursion
*************************************************************
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). This process continues until n is equal to 0.
When n is equal to 0, there is no recursive call. This returns the sum of integers ultimately to the main() function.
*********************************************************************
C Programming | Sum of Natural Numbers Using Recursion
*************************************************************
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). This process continues until n is equal to 0.
When n is equal to 0, there is no recursive call. This returns the sum of integers ultimately to the main() function.
*********************************************************************