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

What is virtual function?where and when is it used?

2 Answers   Sitel,


When a private constructer is being inherited from one class to another class and when the object is instantiated is the space reserved for this private variable in the memory??

13 Answers   HCL, Honeywell,


How to reverse a sentence in c program ex: ram is a good boy answer: boy good a is ram

0 Answers   IBM,


What is byval and byref? What are differences between them?

0 Answers   HCL, Wipro,


What is meant by oops concept?

0 Answers  






There are 2 empty jars of 5 and 3 liters capacity. And a river is flowing besides. I want to measure 4 liters of wanter using these 2 jars. How do you do this?

2 Answers  


Should you protect the global data in threads? Why or why not?

2 Answers   IBM,


what is different between oops and c++

0 Answers   IIT,


What are the main differences between procedure oriented languages and object oriented languages?

9 Answers   IBM, Infosys, Wipro,


What is abstraction?

9 Answers  


what is the difference between javap and jad utility

1 Answers   Wipro,


What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?

0 Answers   NIIT, SRA,


Categories