Chapter:

Recursive-program-in-c

C Program to Find Sum of N Numbers using Recursion

This is a C program to find sum of first N numbers using recursion.

Problem Description

The following C program using recursion displays the first N natural number on the terminal.

Problem Solution

The user enters the Nth number as the input, the program then calculates the sum of first N numbers using recursion and then displays the final result.

Program/Source Code

#include <stdio.h>

 

void display_sum(int);

 

int main()

{

    int num;

 

    printf("Enter the Nth number: ");

    scanf("%d", &num);

    display_sum(num);

    return 0;

}

 

void display_sum(int num)

{

    static int sum = 0;

Show More

All Chapters

View all Chapter and number of question available From each chapter from C-programming-