In C programming, what command or code can be used to determine if a number of odd or even?
3 years ago
C Programming
There is no single command or function in C that can check if a number is odd or even. However, this can be accomplished by dividing that number by 2, then checking the remainder. If the remainder is 0, then that number is even, otherwise, it is odd. You can write it in code as:
if (num % 2 == 0)
printf("EVEN"); else
printf("ODD");
Sanisha Maharjan
Jan 20, 2022