Monday, 26 May 2014

Write a program to calculate the sum of all the numbers from 1 to 50 using for loop.

#include<stdio.h>

main()
{
    int i,sum=0;
    for(i=1;i<=50;i++)
    {
        sum=sum+i;
    }
    printf("\nSum of all the number from 1 to 50=%d",sum);
}

No comments:

Post a Comment