If all required header files are already included, identify the output of the…
2023
If all required header files are already included, identify the output of the following C++ code from the given options:
- A.
1001 : 1
- B.
1001 : 4
- C.
1001 : 3
- D.
1001 : 2
Attempted by 153 students.
Show answer & explanation
Correct answer: B
The object S is created with Student S(1001); , so AdmNo = 1001 and default Class = 1 . Then S.Promoted(3) adds 3 to Class , making it 1 + 3 = 4 . Hence the output is 1001 : 4.