Skip to content

Instantly share code, notes, and snippets.

@jagdish4501
Created May 10, 2021 12:05
Show Gist options
  • Save jagdish4501/7ce3d997c7296d0e013b14c9f65ab5bf to your computer and use it in GitHub Desktop.
Save jagdish4501/7ce3d997c7296d0e013b14c9f65ab5bf to your computer and use it in GitHub Desktop.
Let us c Q.Write a recursive function to obtain the running sum of first 25 natural numbers
#include <stdio.h>
int sum(int);
int main()
{
int num;
printf("Number of term ");
scanf("%d", &num);
printf("sum of runnig series =%d", sum(num));
}
int sum(int num)
{
if (num == 1)
{
return 1;
}
else
return num + sum(num - 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment