Vidyalelo
C++ Programming · all questions

Structures and Unions in C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

35

Questions

1/2

Page

Pick an option on a question to see the right answer and solution.

What is a structure in C++?

Select an option to see the answer and solution.

Which keyword is used to define a structure in C++?

Select an option to see the answer and solution.

What is the correct way to access members of a structure in C++?

Select an option to see the answer and solution.

What is the purpose of typedef in C++ structures?

Select an option to see the answer and solution.

How do you declare a structure variable in C++?

Select an option to see the answer and solution.

What is the output of the following code: struct Student { int roll; }; Student s1; s1.roll = 101; cout << s1.roll; in C++?

Select an option to see the answer and solution.

What is the purpose of using structures in C++?

Select an option to see the answer and solution.

What is the correct way to pass a structure to a function in C++?

Select an option to see the answer and solution.

What is a union in C++?

Select an option to see the answer and solution.

What is the difference between a structure and a union in C++?

Select an option to see the answer and solution.

What is the size of the following structure in C++: struct Employee { int id; char name[20]; float salary; };

Select an option to see the answer and solution.

What is the correct syntax to define a structure pointer in C++?

Select an option to see the answer and solution.

What is the output of the following code: union Data { int x; char y; }; Data d; d.x = 10; d.y = 'A'; cout << d.x << " " << d.y; in C++?

Select an option to see the answer and solution.

What is the purpose of using unions in C++?

Select an option to see the answer and solution.

What does the 'sizeof' operator return when used with a structure in C++?

Select an option to see the answer and solution.

What is the correct syntax to declare a structure with a tag name in C++?

Select an option to see the answer and solution.

What is the correct way to access structure members through a pointer in C++?

Select an option to see the answer and solution.

What is the difference between a structure and a class in C++?

Select an option to see the answer and solution.

What is the output of the following code: struct Point { int x, y; }; Point p1; p1.x = 10; p1.y = 20; cout << p1.x << " " << p1.y; in C++?

Select an option to see the answer and solution.

What is the purpose of the 'typedef' keyword in C++ structures?

Select an option to see the answer and solution.