in Programming in C edited by
286 views
0 votes
0 votes
#define THIS 0
#define THAT 0
#include <stdio.h>
int main(int argc, char const *argv[])
{
        
    #ifdef THIS && THAT 
        printf("if\n");     
    #else
        printf("else\n");
    #endif
    return 0;
}
  • What is the output?
  • What happens if the first two lines are not initializing. i.e.,
#define THIS
#define THAT 
in Programming in C edited by
by
286 views

1 Answer

0 votes
0 votes
O/p : if
If not initialized o/p will remain same

Since condition is if defined  THIS && THAT and both are defined in both cases the "if" string will be printed

else part will be going to execute only if you remove
#define THIS or #define THAT or both

Basically ifdef and ifndef checks for #define for those MACROS
by

Related questions