Lets see how the code works line by line ==>
const int perplexed = 2;
Declares and defines a constant variable perplexed , hence, memory is allocated and stored with value 2 which can't be changed .
#define perplexed 3
Defines a macro , so whenever purplexed occurs , substitute with 3. It doesn't follow scope rules and no memory allocation is done for macro statements.
#ifdef perplexed
This command checks whether a macro purplexed id defined or not. If defined ( returns true ) , directs control to the next line of code.
#ifdef macro
//some code here
#endif
This block will be executed only, when ifdef returns true for macro, otherwise fails to compile the block.
#undef perplexed
This command removes the macro puplexed, if it exists and directs the control to the next line of code.
#define perplexed 4
This command redefines the macro purplexed with substitution value = 4.
printf("%d",perplexed);
becomes
printf("%d",4 );
This will return 4.
#define perplexed 4 ==> If we remove this line , then scope of const int is used. Now printf will print 2.