Sunday, 15 December 2013

C Program to Find the Sum of first 50 Natural Numbers using For Loop

#include < stdio.h>
 
void main()
{
    int  num, sum = 0;
 
    for (num = 1; num <= 50; num++)
    {
        sum = sum + num;
    }
    printf("Sum = %4d\n", sum);
}

Output

 Sum =  1275 

For More Details Please Visit Ictjobs.info

No comments: