You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/c/Basic/C Program to find Sum of N ...

31 lines
506 B
C

/*
* C Program to find Sum of N Numbers using Recursion
*/
#include <stdio.h>
void display(int);
int main()
{
int num, result;
printf("Enter the Nth number: ");
scanf("%d", &num);
display(num);
return 0;
}
void display(int num)
{
static int i = 1;
if (num == i)
{
printf("%d \n", num);
return;
}
else
{
printf("%d ", i);
i++;
display(num);
}
}