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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!