0
1.2kviews
What do you mean by recursion? Write a program to find out summation of n no using recursion.
1 Answer
0
5views

In programming, when a function calls itself the case is called recursion and the function involved is called recursive function.

#include<stdio.h>
int add(int n);
void main()
{
int n;
    printf("Enter a positive integer: ");
    scanf("%d",&n);
    printf("Sum = %d",add(n));
getche();
}
int add(int n)
{
if(n!=0)
return n+add(n-1);/* recursive call */
    else
     return 0;
}

Output

Enter a positive integer: 5

Sum =15

Please log in to add an answer.