Answer: Read N and add 1, 2, 3, ..., N in a loop (the result equals \(\frac{N(N+1)}{2}\)).
#include <stdio.h>
int main(void)
{
int n, i;
long sum = 0;
printf("Enter N: ");
scanf("%d", &n);
for (i = 1; i <= n; i++)
sum = sum + i;
printf("Sum of first %d natural numbers = %ld\n", n, sum);
return 0;
}
The loop runs i from 1 to N and adds each value to sum. For N = 10 the output is 55, which matches the formula \(\frac{10 \times 11}{2} = 55\). The user only enters N; the natural numbers themselves are generated by the loop.