Question 105Asked in BPSC TRE 2.0 (2023) Computer Science Class 11-12

What will be the output of the following? int a = 5;

What will be the output of the following? int a = 5; cout << "FIRST" << (a<<2) << "SECOND";
  1. AFIRST 52 SECOND
  2. BFIRST 20 SECOND
  3. CSECOND 25 FIRST
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (B) FIRST 20 SECOND

Explanation

a << 2 shifts 5 (101) left by two bits, giving 10100 = 20, which is the same as 5 × 4. The output is FIRST20SECOND.

From BPSC TRE 2.0 (2023) Computer Science Class 11-12 — Previous Year Paper

This is question 105 of BPSC TRE 2.0 (2023) Computer Science Class 11-12 — Previous Year Paper. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.