C Program for Sum Of N Natural Numbers

Sum of N natural numbers in C programming (1)

Find Sum of N Natural Numbers

In the C programming language, the user is allowed to insert any integer value. With the help of For loop, this C program can calculate the sum of N natural numbers. Within this program, first printf statement will request the user to insert a number or value then the scanf statement will allocate the user inserted value to integer variable. The sum is calculated in the For loop. 

To perform the arithmetic operation of addition of n numbers we use this conditions 
Example –
Enter Number  3
N natural numbers 1,2,3,4,5,6,7,8…….
Where first 3 number is 1,2,3
Then we will return  sum of number = 6


  • Step 1. Start
  • Step 2. Enter a number (N).
  • Step 3. Use “For loop” to iterate  upto the user inserted value. 
  • Step 4. The “For loop” will calculate the sum of the user inserted value. 
  • Step 5. Stop

C Code

/* C Program to find Sum of N Numbers using For Loop */ 
    int main() 
    //for initialize variable
    int Number, i, Sum = 0;
    //to take user input
    printf (\n Kindly Insert an Integer Variable\n);
    scanf (“%d”, &Number);

    //use for loop for these condition
    for(i = 1; i <= Number; i++)
    Sum = Sum + i;

    printf (“Sum of Natural Numbers = %d”, Sum);

    return 0;
Kindly insert an integer variable : 5
Sum of Natural Numbers = 15