What will the below code do?
void function(int& num, int pos)
{
num |= (1 << pos);
}
void setBit(int* num, int pos) {
*num |= (1 << pos);
}
void setBit(int[] num, int pos) {
num[0] |= (1 << pos);
}
def set_bit(num, pos):
return num | (1 << pos)
function setBit(num, pos) {
return num | (1 << pos);
}
divide num by pos.
Multiply num by pos.
Add num with pos.
set the given position (pos) of a number (num).
This question is part of this quiz :
Top MCQs on Bitwise Algorithms and Bit Manipulations with Answers