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 the advantage in software? what is the difference between the software developer and Engineer

1 Answers  


What makes a language oop?

0 Answers  


write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

0 Answers  


What is multilevel inheritance?

0 Answers  


what is the application of oops?

8 Answers   IBM,






#include <iostream> using namespace std; struct wow { int x; }; int main() { wow a; wow *b; a.x = 22; b = &a; a.x = 23; cout << b->x; return 0; }

1 Answers  


What is overloading in oop?

0 Answers  


What is abstraction in oop?

0 Answers  


What is a class oop?

0 Answers  


what is the drawback of classical methods in oops?

0 Answers  


We have a scale and 7 balls. 1 ball is heavier than all the rest. How to determine the heaviest ball with only 3 possible weighing attempts?

8 Answers   IBM, Sage, Vertex,


How to overload postfix operator in c++

1 Answers   Mphasis,


Categories