Write a program to print the sum of odd and eve numbers from 20-80

//this is a program to print the sum of odd and eve numbers from 20-80
#include<stdio.h>
#include<conio.h>
int main()
{
int esum=0,osum=0,i;

printf("\n\nPrinting sum of even and sum of odd numbers");

for(i=1;i<=100;i++)
{
if(i%2==0)
{
esum=esum+i;

}
else
{
osum=osum+i;
}
}

printf("\n\n Sum of even numbers= %d\n\nSum of odd numbers=%d",esum,osum);

getch();
}

Previous
Next Post »