How to write a C Program To Calculate First Numbers Using Recursion in C Programming Language ?
Solution For C Program :
#include<stdio.h>
void main()
{
int sum(int);
int n;
printf("\nEnter Any Number : ");
scanf("%d", &n);
printf("\nSum of N values in the Series is : %d.", sum(n));
}
int sum(int x)
{
int a, b;
if(x == 0) return (0);
if(x == 1) return (1);
a = x - 1;
b = x + sum(a);
return(b);
}
You may also learn these C Program/Code :