C Program for Sum Of N Natural Numbers

C Program to Find Sum of N natural numbers

In the C programming, 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 

Ex:-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 

Sum of N natural numbers in C programming (1)


Step 1: Start 

Step 2: The user is asked to enter an integer variable. 

Step 3: Use For loop to iterate the user inserted value. 

Step 4: The For loop will calculate the sum of the user inserted value. 

Step 5: Stop 

C program:-

/* 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; }
//display printf ("Sum of Natural Numbers = %d", Sum);
return 0; }


Kindly insert an integer variable: 5 

Sum of natural numbers: 15 

Please Login/Signup to comment