IGDTUW 2026 Computer PYQ — What is the output of the following C++ code? #include <iostream>… | Mathem Solvex | Mathem Solvex
Tip:A–D to answerE for explanationV for videoS to reveal answer
IGDTUW 2026 — Computer PYQ
IGDTUW | Computer | 2026
What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
int a = 5;
cout << a << 1;
return 0;
}
Choose the correct answer:
A.
5
B.
51
(Correct Answer)
C.
6
D.
Compilation Error
Correct Answer:
51
Explanation
The correct option is (b) 51.
Step-by-Step Explanation:
Variable Initialization: The variable a is initialized with an integer value of 5.
int a=5;
Stream Insertion Evaluation:
The expression cout << a << 1; uses the stream insertion operator (<<). This operator associates from left to right.
Breakdown of execution:
First, cout << a executes. This prints the value stored in variable a, which is 5, to the console output stream.
Immediately after that, the next chained insertion << 1 executes. This prints the literal integer 1 directly after the previous output on the same line.
Final Output:
Because there are no spaces or newline characters (\n or endl) separating them, the characters 5 and 1 appear sequentially on the screen, resulting in:
51
Explanation
The correct option is (b) 51.
Step-by-Step Explanation:
Variable Initialization: The variable a is initialized with an integer value of 5.
int a=5;
Stream Insertion Evaluation:
The expression cout << a << 1; uses the stream insertion operator (<<). This operator associates from left to right.
Breakdown of execution:
First, cout << a executes. This prints the value stored in variable a, which is 5, to the console output stream.
Immediately after that, the next chained insertion << 1 executes. This prints the literal integer 1 directly after the previous output on the same line.
Final Output:
Because there are no spaces or newline characters (\n or endl) separating them, the characters 5 and 1 appear sequentially on the screen, resulting in: