Write a program to find out the aggregate value of all even numbers and odd numbers lie between 1 to 100
int main()
{
int x=1, y=100;
int totalodd=0;
int totaleven=0;
while(x<y)
{
if(x%2==0)
totaleven=totaleven+x;
else
totalodd=totalodd+x;
x++;
}
printf("Sum of Even Number: %d\n",totaleven);
printf("Sum of Odd
Number: %d\n",totalodd);
return 0;
}
Comments
Post a Comment