Created
May 10, 2021 12:05
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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