C Program to Calculate sum of first N natural numbers
Description:
This Program accepts one Integer from user and stores that value into the variable n. Then calculates the Sum of first n numbers.
Formula to calculate Sum of first N natural Numbers :
Program :

#include<stdio.h>

int main()

{

int i,sum,n;

printf(“Enter Number : “);

scanf(“%d”,&n);

sum = 0;

for(i=1; i<=n; i++)

{

// This loop will add each number to sum variable.

sum = sum + i;

}

printf(“The Sum of First %d natural numbers is : %d n“, n, sum);

return 0;

}
Output :
Related Programs:
 Sum of Digits of Given Number.
 Calculate area of Circle.
 C Program to calculate area and perimeter of Rectangle.
 C Program to calculate area of Traingle.
 C program to generate Prime Numbers between n1 and n2.
 C Program to Generate Fibonacci series using Recursion.
 More Mathematical C Programs.
 200+ C Language programs.
http://cplusplus.happycodings.com/beginnerslabassignments/