Question
Code Sample A union test { int x; char arr[8]; int y; }; int main() { cout < < sizeof(union test)); return 0; } -What
Code Sample A
union test { int x; char arr[8]; int y; }; int main() {
cout << sizeof(union test)); return 0; }
-What would you expect the output to be in Code Sample A. Why?
-------------------------------------------------------------------------------------
Code Sample B
// using the union in code sample A test t; t.y = 40; cout << t.arr << endl;
-What is the output of Code Sample B? Why?
---------------------------------------------------------
Code Sample C
int x = 1, y = 2; #ifdef next x = 2; y = 1; #endif cout << "x is " << x << " y is " << y << endl;
-What is the output of Code Sample C?
-What are two reasons you might use a similar structure to Code Sample C?
-----------------------------------------------------------------------------
Code Sample D
#define A 1 + 2 #define B 3 + 4
int var = A * B; cout << var << endl;
-What is the output of Code Sample D?
-Copy Code Sample D below and edit it to make it work more as expected.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started