#include
void main()
{
int n,i;
int addeven=0;
int addodd=1;
printf("\nEnter a number\n");
scanf("%d",&n);
fflush(stdin);
for(i=2;i<=n;i++)
{
if(i%2==0)
addeven+=i;
else
addodd+=i;
}
printf("\nThe sum of odd numbers is %d \nThe sum of even numbers is %d\n",addeven,addodd);
}
No comments:
Post a Comment