Home / Programs / Program to display first 10 natural no. & their sum.
Programming Example

Program to display first 10 natural no. & their sum.

👁 4,338 Views
💻 Practical Program
📘 Step by Step Learning
Program to display first 10 natural no. & their sum.

Program Code

/* Program to display first 10 natural no. & their sum.
  Author: Atnyla Developer */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,sum=0;
 
for(i=1;i<=10;i++)
{
	printf("%d no is= %d\n",i,i);
	sum=sum+i;
}
	printf("sum =%d",sum);
}

Output

1 no is= 1
2 no is= 2
3 no is= 3
4 no is= 4
5 no is= 5
6 no is= 6
7 no is= 7
8 no is= 8
9 no is= 9
10 no is= 10
sum =55 

Explanation

Program to display first 10 natural no. & their sum.

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.