How does an #if Preprocessor stage statement which contain variable of compile time get resolved at preprocessor stage itself?
Below is the code which runs without any error:
#include<stdio.h>
void main()
{
int num=10; /* compile time */
#if((num%2)==0) /* #if is preprocessor stage but has num of compile time why not error here? */
printf("\nNumber is Even");
#else
printf("\nNumber is Odd");
#endif
}
For the evaluation in #if, the preprocessor replaces all identifiers that are already defined macros by their appropriate expansion. All identifiers that remain after that have the value 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With