Note: Remove the Red color Highlighted Lines such that it works as a code for Odd digits..
Source Code:
Source Code:
#include<stdio.h>
#include<stdlib.h>
void main(int argc, char const*argv[])
{
int oddCount = 0, evenCount = 0,
InputNum, temp ;
InputNum = atoi(argv[1]);
while (InputNum>
0)
{
temp =
InputNum % 10; /*
separate Last digit from number */
if (temp
% 2 == 1)
{
oddCount++;
}
else
{
evenCount++;
}
InputNum /= 10;
/* remove Last digit from num */
}
printf("Number of Odd digits : %d \nNumber of Even digits: %d\n",
oddCount, evenCount);
}
Output:
Also See : Count No Of Odd and Even Digits
Thanks and regards,
Tech Bird
Comments