C Program to Find the sum of First N natural Number

In this article, we will see C Program to Find the Sum of First N Natural Numbers. A Natural number is the same as a Counting number. They are used to Count the number of real physical objects. Natural numbers start from 1 and go on infinite.

The positive numbers 1,2,3 ... are known as natural numbers.

The formula for Sum of First n natural numbers is n(n+1)/2.

If you want to add the first 5 Natural numbers then we find the Sum of 1+2+3+4+5 =15.

Flow Diagram:-



  • Start.

  • Declare and initialize variable, i,num, s=0.

  • Enter the value of num i.e. number up to which sum is to be calculated.

  • Use Loop to add numbers. Any of while, do-while or for loop can be used.

  • Print the sum.

  • Stop.



  #include <stdio.h>

  int main()


      int n;

      scanf("%d",&n); int sum = 0;

      for(int i=1;i<=n;i++)

                      // is same as writing sum = sum + i

              sum += i;

              printf("Sum is %d",sum);

              return 0;




  Sum is 15