It should **not** work because the exclamation point "!" is in the wrong place!
Here's a better code sample:
printf("\nDEMO flag is ON");
printf("\nDEMO flag is OFF");
Also, the description of DEMO is:
A demo account is selected through the [Account] scrollbox.
It does not care what mode you are in.