What is the output of the below code?
#include<stdio.h>
#define Var 10
#define TRUE 1
void main()
{
if(Var==10)
{
if(TRUE)
break;
}
printf("Hello C Enthusiasts");
}
------------------------------------------------------------------
The above code tests below scenarios:
1. using Macros in the code
2. where to use break statement?
-------------------------------------------------------------------
Macro is a preprocessor directive used in C programming language. Macros define constants in the program which can be used in the program and the value cannot be varied
In the above program, we have 2 Macros, Var and TRUE
The if condition is checked and the if condition is satisfied, so, the statements inside the if condition shall be executed. if(TRUE) is also satisfied and then break statement is encountered. However, the compiler doesn't expect any break statement here as there is neither a loop nor switch statement here. Therefore, it returns error.
0 Comments