Zoho Second round - count odd and even number
Print the total number of odd and even digits in the given number.
Ex. Input : 1234567 Output : ODD 4 EVEN 3
#include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> int main() { int n,odd=0,even=0; int i=0,num,t; scanf("%d",&n); while(n>0) { t=n%10; n/=10; if(t%2==0) {even+=1;} else {odd+=1;} } printf("Even :%d\n",even); printf("Odd : %d",odd); getch(); return 0; }Happy coding!!!
Comments
Post a Comment