programming-examples/c/_Basic/C Program to Find the Sum of first 50 Natural Numbers using For Loop.c

15 lines
271 B
C
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* 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);
}