#include<stdio.h>
#include<conio.h>
int sum(int);
int main()
{
int ans = sum(25);
printf("Running sum of the numbers : %d", ans);
_getch();
return 0;
}
int sum(int x)
{
if (x == 0)
return x;
x = x + sum(x - 1);
return x;
}
Ad
Chapter - 6: Functions And Pointers
Write a recursive function to obtain the running sum of the first 25 natural numbers.
Ad
Ad