C Program to find the sum of first n natural numbers using for loop
Program
#include<stdio.h>
void main()
{
int n, count, sum;
sum = 0;
printf("Enter the value of n\t");
scanf("%d", &n);
for(count = 1; count <= n; count++)
{
sum = sum + count;
}
printf("Sum of first %d natural numbers is: %d\n", n, sum);
}
Output
Enter the value of n 100
Sum of first 100 natural numbers is: 5050