How can we use the preprocessor #if and #elseif.

Answers were Sorted based on User's Feedback



How can we use the preprocessor #if and #elseif...

Answer / som shekhar

Take the following example where i assume that table size
has been defined previosly but at some part of time i want
to change it..but the table size is defined in some other
module and you dont have an access to it.

#if TABLE_SIZE>200
#undef TABLE_SIZE
#define TABLE_SIZE 200

#elif TABLE_SIZE<50
#undef TABLE_SIZE
#define TABLE_SIZE 50

#else
#undef TABLE_SIZE
#define TABLE_SIZE 100
#endif

int table[TABLE_SIZE];

Is This Answer Correct ?    0 Yes 0 No

How can we use the preprocessor #if and #elseif...

Answer / som shekhar

Take the following example where i assume that table size
has been defined previosly but at some part of time i want
to change it..but the table size is defined in some other
module and you dont have an access to it.

#if TABLE_SIZE>200
#undef TABLE_SIZE
#define TABLE_SIZE 200

#elif TABLE_SIZE<50
#undef TABLE_SIZE
#define TABLE_SIZE 50

#else
#undef TABLE_SIZE
#define TABLE_SIZE 100
#endif

int table[TABLE_SIZE];

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More OOPS Interview Questions

How many types of access specifier in c# and vb.net?

1 Answers   Infosys,


Whatis the difference between oop and object based language

3 Answers  


How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?

1 Answers   IntraLogic,


Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.

0 Answers  


20% of a 6 litre solution and 60% of 4 litre solution are mixed what the % of mixture of solution it is resulted into?

5 Answers   IonIdea,


Name a typical usage of polymorphism

3 Answers  


What are the three main types of variables?

0 Answers  


What is difference between function overloading and overriding?

1 Answers   emc2,


i am getting an of the type can not convert int to int *. to overcome this problem what we should do?

0 Answers  


What is oop in simple words?

1 Answers  


What is object in oop?

0 Answers  


what is inline function?

3 Answers  


Categories