C Recursion
A function that calls itself is known as a recursive function. And, this technique is known as recursion.
How recursion works?void recurse()
{
... .. ...
recurse();
... .. ...
}
int main()
{
... .. ...
recurse();
... .. ...
}
The recursion continues until some condition is met to prevent it. To prevent infinite recursion, if...else statement (or similar approach) can be used where one branch makes the recursive call, and other doesn't. Program: Sum of Natural Numbers Using Recursion
Output:
Enter a positive integer:3
sum = 6
Put the parts in order to form a sentence. When you think your answer is correct, click on "Check" to check your answer. If you get stuck, click on "Hint" to find out the next correct part.