You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
343 B
C

/*
* C program to find the sum of 'N' natural numbers
*/
#include <stdio.h>
void main()
{
int i, num, sum = 0;
printf("Enter an integer number \n");
scanf ("%d", &num);
for (i = 1; i <= num; i++)
{
sum = sum + i;
}
printf ("Sum of first %d natural numbers = %d\n", num, sum);
}