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

ambiguity regulation of multiple inheritance with example.

1 Answers  


Base class has two public data members. How can i derive a new class with one datamember as public and another data member as private?.

2 Answers  


how do u initialize the constant variables

5 Answers   IBM, Siemens,


what are abstract classes and how they impliment , with example

2 Answers  


What is abstraction oop?

0 Answers  






What does the code "cout<<(0==0);" print? 1) 0 2) 1 3) Compiler error: Lvalue required

15 Answers   ISTS, Wipro,


Can abstract class have normal methods?

0 Answers  


Why we use classes in oop?

0 Answers  


In the following declaration of main, "int main(int argc, char *argv[])", to what does argv[0] usually correspond? 1) The first argument passed into the program 2) The program name 3) You can't define main like that

6 Answers  


what is the advantage in software? what is the difference between the software developer and Engineer

1 Answers  


Why do pointers exist?

0 Answers  


Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.

0 Answers  


Categories