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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the real time example of inheritance?

856


What is inheritance and how many types of inheritance?

812


Explain virtual inheritance?

887


Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

4469


How long to learn object oriented programming?

808


What is the point of polymorphism?

766


what is difference between class template and template class?

2393


What is polymorphism used for?

770


What are the 3 principles of oop?

832


What is oops in simple words?

803


What is class in oop with example?

829


Where You Can Use Interface in your Project

1616


What are classes oop?

789


Can a destructor be called directly?

802


#include #include #include #include void insert(char *items, int count); int main(void) { char s[255]; printf("Enter a string:"); gets(s); insert(s, strlen(s)); printf("The sorted string is: %s.\n", s); getch(); return 0; } void insert(char *items, int count) { register int a, b; char t; for(a=1; a < count; ++a) { t = items[a]; for(b=a-1; (b >= 0) && (t < items[b]); b--) items[b+1] = items[b]; items[b+1] = t; } } design an algorithm for Insertion Sort

2373