The program to compute sum of first N natural numbers is written using Dev-C++ compiler on a Windows 7 64-bit system. You can use any other standard C compiler of your own choice to compile the program.

To help you understand the program logic, you will find following section helpful – problem definition, flowchart, program source code and a verified output.

This is a very simple program that computes first N natural numbers, hence, it is intended for beginners learning C programming language.

### Problem Definition

Natural numbers are all positive numbers greater than number 0 and it does not include the number zero.

For example

**Natural numbers = 1, 2, 3, 4, 5 …**

This C program reads the value of number N which is natural number and then sum all other natural numbers up to number N start from 1.

Suppose **N = 10,** then

**Sum = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55**

### Flowchart

### Program Code

```
/* Program for sum of First N Natural Numbers */
#include <stdio.h>
#include <conio.h>
main()
{
int num,i,sum;
sum = 0;
/* read the number */
printf("Enter number to sum:");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
sum = sum + i;
}
printf("sum of %d number is %d\n",num,sum);
getch();
return 0;
}
```