/*program to find sum of even and odd numbers below 1000*/
#include<stdio.h>#include<conio,h>
int main()
{
int num;
long int sume=0,sumo=0;
clrscr();
for(num=1;num<1000;num++)
{
if(num%2==0)
{
sume = sume+num;
}
else
{
sumo = sumo+num;
}
}
printf(“sum of even numbers is %d\n”sume);
printf(“sum of odd numbers is %d”,sumo);
getch();
return 0;
}
output:
sum of even numbers is 249500sum of odd numbers is 250000
Comments
Post a Comment