C++ Institute CPA-21-02 Exam - Topic 2 Question 48 Discussion
What is the output of the program?#include #include using namespace std;union t{char c;int i;};class First{union t u;public:First() {u.c = 'A';}void Print(){cout Print();}
B) It prints: A
A) Garbage value
C) It prints: A 65
D) Compilation error
C++ Institute CPA-21-02 Exam - Topic 2 Question 48 Discussion
Actual exam question for
C++ Institute's
CPA-21-02 exam
I've got it! The union will store the 'A' character, but when we print it, it will print the ASCII value 65 instead of just the character. The answer is C.
Okay, let me think this through. The union has a char and an int member, and the First class initializes the char member to 'A'. So the output should be just 'A'.
Arlen
2 months agoLayla
2 months agoLashawn
3 months agoMaurine
3 months agoTasia
3 months agoCharlene
3 months agoBecky
3 months agoTijuana
3 months agoLayla
4 months agoDominga
4 months agoDion
4 months agoAlbina
4 months agoKenneth
5 months agoKimberlie
5 months agoIrma
5 months agoLaurel
5 months agoBilli
6 months agoDanica
6 months agoCordie
6 months agoBeatriz
6 months agoTyra
6 months agoPaulene
6 months agoJoesph
7 months agoRoyce
7 months agoJessenia
12 days agoSabra
17 days agoDenny
22 days ago