Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 314 - 316 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 314

C & C Plus Plus
Edit

Describe in Detail

Essay▾

enum colors {BLACK, BLUE, GREEN}

  1. main()
  2. {
  3.     printf( “%d. %d. %d” BLACK, BLUE, GREEN);
  4.     return(1);
  5. }

Explanation

  • In a program
Table Shows the Program
enum colors {BLACK, BLUE, GREEN}Define the enum type
  1. main()
  2. {
  3.     printf( “%d. %d. %d” BLACK, BLUE, GREEN);
  4.     return(1);
  5. }
An enumeration consists of a set of named integer constants.

Enum assigns numbers starting from 0, if not explicitly defined

  • So the answer is 0.1. 2

Question 315

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What is RTTI?

Explanation

  • Run time type information is a mechanism that allows the type of an object to determine during program execution.
  • Added to the C ++ language because many class libraries implementing this functionality resulting in incompatibilities between libraries.
  • Available only for classes, which are polymorphic, which means they have at least one virtual method.

Question 316

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is similarity between a structure, Union and enumeration?

Explanation

Difference between a Structure, Union and Enumeration
StructureUnionEnumeration
A structure allocates the total size of all elements in it.A union allocates as much memory as its largest element requires.A user define data type that consist of integral constants
The keyword struct is used to declare a structure.The keyword union is used to declare a union.Uses the keyword enum.
All data members in a structure are active at timeOnly one data member is active at a time.Enumeration can take only one of the enumerated values.

Developed by: