#include <stdio.h>
int main()
{
int i,n,even=0,odd=0,sum=0,counteven=0,countodd=0,countsum=0;
printf("Enter a number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("%d\n",i);
sum+=i;
countsum++;
if(i%2==0)
{
even+=i;
counteven++;
}
else
{
odd+=i;
countodd++;
}
}
printf("Sum=%d\n",sum);
printf("Average=%d\n",sum/countsum);
printf("Even Sum=%d\n",even);
printf("Even Average=%d\n",even/counteven);
printf("Odd Sum=%d\n",odd);
printf("Odd Average=%d",odd/countodd);
return 0;
}
No comments:
Post a Comment