Monday, January 4, 2010

Program to display first 10 natural no & their sum.

#include
#include

void main()
{
int i,sum=0;
clrscr();
for(i=1;i<=10;i++)
{
printf("%d no is= %d\n",i,I);
sum=sum+i;
}
printf("sum =%d",sum);
getch();
}



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
 

No comments:

Post a Comment