Interview answers verified by specialists.

Find interview questions and answers on this website:

See right interview answers on 30 common job interview questions

What is the benefit of using enum to declare a constant?

Using the enum keyword to define a constant can have several benefits. First, constants declared with enum
are automatically generated by the compiler, thereby relieving the programmer of manually assigning unique
values to each constant. Also, constants declared with enum tend to be more readable to the programmer,
because there is usually an enumerated type identifier associated with the constant's definition.

Additionally, enumerated constants can usually be inspected during a debugging session. This can be an
enormous benefit, especially when the alternative is having to manually look up the constant's value in a
header file. Unfortunately, using the enum method of declaring constants takes up slightly more memory
space than using the #define method of declaring constants, because a memory location must be set up to
store the constant.

Here is an example of an enumerated constant used for tracking errors in your program:

enum Error_Code

Do you know that?

1 in 3 people will be hired online by 2020 Next