Pages

Sunday, 20 May 2012

program to print sum of 1,2,…,10 number


76./*Write a program to print sum of 1,2,…,10  number*/

#include<stdio.h>
#include<conio.h>
main()
{
            int i;
            int sum=0;
            clrscr();
            i=1;
            while(i<=10)
            {
             sum=sum+i;
             i++;
            }
            printf("\n The sum of numbers from 1 to 10 is:%d",sum);
            getch();
}

OUTPUT

            The sum of numbers from 1 to 10 is : 55

No comments:

Post a Comment