PARITY COUNTER
Code :
#include<stdio.h>
int main()
{
int total_en = 0, even_en = 0, odd_en = 0, seq=0;
printf("==================================\n");
printf("\t PARITY COUNTER\n");
printf("==================================\n");
printf("Enter sequence of numbers \n(Terminated by -1) : ");
while(seq != -1)
{
scanf("%d", &seq);
if(seq == -1)
{
break;
}
if(seq%2 == 0)
{
even_en++;
}
else
{
odd_en++;
}
total_en++;
}
printf("\nTotal number of entries = %d\n", total_en);
printf("No of Evens = %d\n", even_en);
printf("No of Odds = %d\n", odd_en);
printf("-----------------------------------\n");
return 0;
}
Come again Learn again !
« iCodeBuzz »
No comments:
Post a Comment