🎴 Flashcard Mode
C Bitwise Operations and Expressions
Card1 / 15
Mastered0
Review0
QuestionClick to flip
What is the output of the given program?
int main()
{
printf(%d,128>>4>>3>>2);
// Line 1
}
AnswerClick to flip back
A
0
💡 Explanation:
This is the correct answer. The operator ( >>) is a right shift operator. The general formula to solve (N >> s) is: N/2^s. Here, 128>>4 will be solved first which is 128/(2^4) = 8. So, the statement now becomes 8>>3>>2. Now 8/(2^3) will be solved which will return (8/8) = 1. Now again the statement becomes 1>>2. So, 1/(2^2) will be solved resulting in 0. The correct output is zero.