Complete the code to declare a structure named MyStruct.
struct [1] {
int a;
float b;
};The keyword struct is followed by the structure name. Here, MyStruct is the correct name.
Complete the code to declare a union named MyUnion.
union [1] {
int x;
double y;
};The keyword union is followed by the union name. Here, MyUnion is the correct name.
Fix the error in the code to correctly access the union member.
MyUnion u; u.[1] = 10;
The union MyUnion has members x and y. To assign an integer value, use x.
Fill both blanks to create a structure and access its member.
struct [1] { int age; }; [2] person; person.age = 25;
The structure name MyStruct (B) goes in BLANK_1. The declaration MyStruct person; uses the same type (B) in BLANK_2 to match the structure name.
Fill all three blanks to create a union, assign a value, and print the size.
union [1] { int i; char c; }; [2] u; u.i = 100; std::cout << sizeof([3]) << std::endl;
The union is named MyUnion. The variable u is declared as type MyUnion. The sizeof operator is used on the union type MyUnion to print its size.