• Follow Us

Sum of N Numbers Program In C: Using Recursion

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

Your email address will not be published. Required fields are marked *

Shopping cart