The following C program using recursion displays the first N natural number on the terminal. The user enters the Nth number as the input, the program then displays all integral number starting from 1 up to the N.
Here is the source code of the C program to display first N numbers. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to find Sum of N Numbers using Recursion
int num, result;
printf("Enter the Nth number: ");
void display(int num)
static int i = 1;
if (num == i)
printf("%d \n", num);
printf("%d ", i);
$ cc pgm33.c $ a.out Enter the Nth number: 10 1 2 3 4 5 6 7 8 9 10
Sanfoundry Global Education & Learning Series – 1000 C Programs.