28-Write a C program to calculate the sum of 1 to 100 numbers.

Program: 28

Write a C program to calculate the sum of 1 to 100 numbers.

#include
#include
void main()
{
    int i, sum=1;
    while(i<=100)
    {
    sum=sum+i;
    i=i+1;
    }
    printf("%d\t",sum);
    getch();
}
Output
2840
Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.