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. 


#include<stdio.h>
void main()
{
int n , i, even_sum=0, odd_sum=0 ;
printf(“Enter the Limit : “);
scanf(“%d”, &n);
for(i=1 ; i<=n ; i++)
{
if(n%i==0)
even_sum += i ;
else
odd_sum += i ;
}
printf(“Even numbers sum : %d\n”,even_sum);
printf(“Odd numbers sum : %d\n”,odd_sum);
}

Share this