Sum of Even Numbers Program in C

This Sum Of Even Numbers Program in C page provides program that explains clearly how to find the sum of even numbers in the given range. 

void main()
int n , i, even_sum=0, odd_sum=0 ;
printf(“Enter the Limit : “);
scanf(“%d”, &n);
for(i=1 ; i<=n ; i++)
even_sum += i ;
odd_sum += i ;
printf(“Even numbers sum : %d\n”,even_sum);
printf(“Odd numbers sum : %d\n”,odd_sum);

Share this