Answer :
#include<stdio.h> //header file contains the function,decleraction and macro defination of key words used in code.
int main ()
{
int num,even=0,odd=0,zero=0,num_1;
printf("Enter a 4 digit number");
scanf("%d",&num);
while (num>0) //loop
{
num_1=num%10; // to take a single digit
if (num_1==0)
{
zero++;
}
else if(num_1%2==0)
{
even++;
}
else
{
odd++;
}
num=num/10; // to divide the number and take the another number.
}
printf("even numbers : %d\n",even);
printf("odd numbers : %d\n",odd);
printf("Zeros : %d\n",zero);
}
Output :
0 Comments