C program to display sum of first 10 natural numbers using for loop

 

C program to display sum of first 10 natural numbers using for loop


/**************************************************

 C program to display sum of first 10 natural numbers using for loop

 **************************************************/

 #include<stdio.h>

#include<conio.h>

 void main()

 {

     int sum=0;

    clrscr();

     printf("** OUTPUT**\n");

     printf("First 10 natural numbers are\n");

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

     {

     printf("%d\n",i);

     sum=sum+i;

     

     }

     printf("The sum of first 10 natural number is: %d\n",sum);

     printf("End of program");

 }

** OUTPUT**

First 10 natural numbers are

1

2

3

4

5

6

7

8

9

10

The sum of first 10 natural number is: 55

End of program



टिप्पणी पोस्ट करा

0 टिप्पण्या