VOOZH about

URL: https://www.geeksforgeeks.org/quizzes/cpp-structures-and-unions/

⇱ Quiz about C++ Structure and Union


Last Updated :
Discuss
Comments

Question 1

The size of a union is determined by the size of the

  • First member in the union

  • Last member in the union

  • Biggest member in the union

  • Sum of the sizes of all members

Question 2

What will be the output of the following C++ code?

  • Adidas$9.99Adidas$1.11

  • Adidas $ 9.99Adidas $ 9.11

  • Adidas $ 9.99Adidas $ 11.11

  • Adidas $ 11.11Adidas $ 11.11

Question 3

When do we use "struct" keyword ?

  • To declare a structure

  • Optionally for creating structure variables

  • Both of the above

  • None of the above

Question 4

Which of the following comments about Union is false?

  • Union is a structure whose members share the same memory area

  • The compiler will keep track of what type of information is currently stored

  • Only one of the members of union can be assigned a value at particular time

  • Size allocated for Union is the size of its member needing the maximum storage

Question 5

What will output of the following C++ code?

  • Segmentation Fault

  • geeksquiz

  • GeeksQuiz

  • Compiler Error

Question 6

What will be the output of the following C++ code?

  • 252

  • 254

  • 258

  • 262

Question 7

What will be used when terminating a structure?

  • :

  • }

  • ;

  • ;;

Question 8

Which of the following accesses a variable in structure *b?

  • b->var;

  • b.var;

  • b-var;

  • b>var;

Question 9

Which of the following is a properly defined structure?

  • struct {int a;}

  • struct a_struct {int a;}

  • struct a_struct int a;

  • struct a_struct {int a;};

Question 10

What will happen when the structure is declared?

  • it will not allocate any memory

  • it will allocate the memory

  • it will be declared and initialized

  • None

Tags:

There are 10 questions to complete.

Take a part in the ongoing discussion