C Program to find the sum of first n natural numbers using while loop

Program

#include<stdio.h>
void main()
{
	int n, count, sum;
	sum = 0;
	count = 1;
	printf("Enter the value of n\t");
	scanf("%d", &n);
	while(count <= n)
	{
		sum += count;
		count++;
	}
	printf("Sum of first %d natural numbers is: %d\n", n, sum);
}

Output

Enter the value of n	50
Sum of first 50 natural numbers is: 1275