You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
626 B
C
21 lines
626 B
C
|
|
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;
|
|
}
|