EmbLogic's Blog

A Program that reads integers untill 0 is entered. after input terminates, the program report the total number of even integers (excluding 0) entered,the average value of the even integers,the total number of odd integers entered , and the value of the odd integers.

#include<stdio.h>
int main()
{
int n,even=0,odd=0;
float sumodd=0,sumeven=0;
scanf(“%d”,&n);
while(n!=0)
{
if(n%2==0)
{
even++;
sumeven=sumeven+n;
}
else
{
odd++;
sumodd=sumodd+n;
}
scanf(“%d”,&n);
}

printf(“\nTotal even num are %d nd Their Average is %f    \n “, even, sumeven/even );
printf(“Total odd  num are %d nd Their Average is   %f \n “, odd, sumodd/odd);

return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>