C Program to find GCD of two Numbers using Recursion
C Program to Find Sum of N Numbers using Recursion
This is a C program to find sum of first N numbers using recursion.
Problem Description
The following C program using recursion displays the first N natural number on the terminal.
Problem Solution
The user enters the Nth number as the input, the program then calculates the sum of first N numbers using recursion and then displays the final result.
Program/Source Code
#include
void display_sum(int);
int main()
{
int num;
printf("Enter the Nth number: ");
scanf("%d", &num);
display_sum(num);
return 0;
}
void display_sum(int num)
{
static int sum = 0;
if (num == 0)
{
printf("Sum of first N numbers is %d\n", sum);
Show More
All Chapters — C programming
Similar Questions
From Recursive program in c · C programming
Program to print Fibonacci Series using Recursion
Program to find Factorial of a Number using Recursion
C Program to find LCM of two Numbers using Recursion
C Program to Find Sum of Digits of a Number using Recursion
C Program to Print Binary Equivalent of an Integer using Recursion
C Program to calculate a Number raised to the Power of N using Recursion
C Program to Find Reverse of a Number using Recursion