All the codes and contents are generated by me. If you have any queries and questions, then please feel free to go “Ask A Question Section” & ask me questions. I will get back you as soon as possible.
#include<studio.h>
#include<conio.h>
void main()
{
int i; //it is used for iterations
int sum_even=0,sum_odd=0;//variable initialization
clrscr();
//we have the series of 1 to 100.
for(i=1;i<=100;i++)
{
if(i%2==0)
{
sum_even=sum_even+i;
}
else
{
sum_odd=sum_odd+i;
}
}
//Now we can print the variable sum_even and sum_odd to see the result.
printf(“The sum of odd number is %d”,sum_odd);
printf(“The sum of even number is %d”,sum_even);
getch();
}