Which of the union variables will likely hold the correct va

Which of the union variables will likely hold the correct value when used with the cout statement at the end of the following code? Select all that apply. Please provide explanation for answer.

union FlagPass bool unlimited; int visit left; float credit FlagPass MrSix; Mr Six . credit = 50 . O ; MrSix.unlimited = true ; MrSix.visitleft = 0; cout //MrSix variables Answers: credit - none of the variables visit_left unlimited

Solution

Answer:

Anwer will same

cout << MrSiz.credit;

same as others

it will give different results

because union allocates fix memory size of float + size of int + size of char to access variables we need to access it one by one like this MrSize.credit = 10; cout mrsize.credit; now assign next value mrsize.blabla = 50; cout mrsize.blabla; same for others.

Which of the union variables will likely hold the correct value when used with the cout statement at the end of the following code? Select all that apply. Pleas

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site