Q46. Write a program using preprocessor directives.
Answer:
Program
#include <iostream>
#define a 100
#define MAX 10
#define MIN 1
using namespace std;
int main(void)
{
#if (a==100)
cout<<"Value of a is matched \n";
#else
cout<<"Value of a does not match\n";
#endif
#ifdef MAX
cout<<"\nMAX is defined.\n";
#else
cout<<"\nMAX is not defined.\n";
#endif
#ifndef MIN
cout<<"MIN is not defined.\n"<<endl;
#else
cout<<"MIN is defined.\n"<<endl;
#endif
#undef MIN
#ifdef MIN
cout<<"\nMIN is defined.\n";
#else
cout<<"\nMIN is not defined.\n";
#endif
return 0;
}
Output