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
22 days agoLayla
27 days agoLashawn
1 month agoMaurine
1 month agoTasia
1 month agoCharlene
2 months agoBecky
2 months agoTijuana
2 months agoLayla
2 months agoDominga
2 months agoDion
2 months agoAlbina
3 months agoKenneth
3 months agoKimberlie
4 months agoIrma
4 months agoLaurel
4 months agoBilli
4 months agoDanica
4 months agoCordie
4 months agoBeatriz
5 months agoTyra
5 months agoPaulene
5 months agoJoesph
5 months agoRoyce
5 months ago