Write a program to display sum of even and odd numbers from 1-10

//this is a program to display sum of even and odd numbers from 1-10
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1,esum=0,osum=0;

printf("\n\nPrinting Sum of all the Even numbers and Odd Numbers from 1-100");

    while(i<=100)
{
if(i%2==0)
{
esum=esum+i;
}
else
{
osum=osum+i;
}
i++;
}

printf("\n\nSum of Even Numbers from 1-100=%d",esum);
printf("\n\nSum of Odd  Numbers from 1-100=%d",osum);
getch();
}


Previous
Next Post »