Virtusa Polaris .NET Fresher Interview Questions Answers

In this tutorial, we are going to discuss about Virtusa Polaris .NET Fresher Interview Questions Answers.

Virtusa Polaris .NET Fresher Interview Questions Answers – enum:

How to define ENUM and how do you describe in programming/c-enumeration ?

The term Enumeration is defined as an user defined data type.  Usually enum contains integral constants in it. The keyword for enumeration is enum.

For example, enum flag { const1,const2,…,constN };
Here, name of the enumeration is flag.

And, the values of the enumeration are const1,const2, …., constN .

By default ,the value of const1 is 0, const2 is 1, constN is N-1 and so on. During the declaration of the enumeration itself the default values of the enum are changed (If nececessary).

// Changing default values of enum
enum suit {
club = 1,
diamonds = 2,
hearts = 3,
spades = 4,
} ;

Enumerated type declaration

The creation of the blue print is only needed for the creation of an enumerated type .The method of creating the variables for the enum type is discussed below.

enum boolean { false, true } ;
enum boolean check ;

Here, a variable check of type enum boolean is created.

The another way to check the same variable using a different syntax is declared below.

enum booolean
{
false, true ,
} check ;

C PREPROCESSOR :
The C Preprocessor is an macroprocessor which transforms the programs before it is compiled.

These transformations may be the inclusion of the header files and the macros expansions etc.
The # include preprocessor is used to include the header lines in c-enumeration.

For an example, In #include ,#include is the header line whereas the #include preprocessor directive replaces the above line with the contents of stdio.h header file which contains function and macro definitions.

Macro in C using a #define preprocessor derivative.

A macro is a fragment of code that is given a name. By using the name we can use the fragment of code in our program.

For an example, the speed of light is given by,
#define c 299792458 // speed of light.

REFERENCES :

https://www.programiz.com/c-programming/c-enumeration
https://www.programiz.com/c-programming/c-preprocessor-macros