edited by
288 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 
edited by

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

Related questions

0 votes
0 votes
1 answer
2
sushmita asked Mar 27, 2017
546 views
Find the out put of the following C program. main() { char *ptr = "techtud"; char p= (*ptr)++; printf("%s\n",ptr); }the output of the program came as$?$
1 votes
1 votes
1 answer
3