...

/

Discussion: Eenie, Meenie, Miney, Mod

Discussion: Eenie, Meenie, Miney, Mod

Execute the code to understand the output and gain insights into number classification.

We'll cover the following...

Run the code

Now, it's time to execute the code and observe the output.

C
#include <stdio.h>
int main()
{
int m = 1;
while( m<10 ) {
if( 2%m )
printf("%d - Odd\n", m);
else
printf("%d - Even\n", m);
m++;
}
return(0);
}

Modulo operator mantra

The modulo operator (%) returns the remainder of the first number divided by the second: 5 % 3 results in two, the remainder of 5 ÷ 3. While such expressions are interesting, ...