programming-examples/c/Recursion/C Program to find Sum of N Numbers using Recursion.c
2019-11-15 12:59:38 +01:00

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);
}
}