Sum of N Numbers Program In C: Using Recursion

This C Program to find the sum of n numbers using the Recursion we will calculate the sum of N natural Numbers.

C Program to find Sum of N Numbers using Recursion

#include<stdio.h>

/* Learn C Programming at www.Codetaglance.com */

int Sum_Recursion(int Number);

int main()
{
  int Number, Sum = 0;
  
  printf("\n Enter an Integer Value\n");
  scanf("%d", &Number);
  
  Sum = Sum_Recursion(Number);
  
  printf("Sum of Natural Numbers = %d", Sum);
  return 0;
}
int Sum_Recursion(int Number)
{
	if (Number == 0)
	{
		return Number;
	}
	else
	{
		return (Number + Sum_Recursion(Number - 1));
	}
}

 

Leave a Reply