int main(){ int counter = 0; while (counter < 21){ ++counter; //Here we are using the bitwise and operation and is performing the and //operation on every bit of the counter and the second operand "1" in this case // 0001 0010 == 18 0001 0101 == 21 // 0000 0001 == 1 0000 0001 == 1 // --------------- --------------- // 0000 0000 == 0 0000 0001 == 1 if ( counter & 1) != 0){ /*do something here when counter is odd*/ } else { /*do something here when counter is even*/ } } return 0; }