Sail E0 Webinar
Question

Will the program compile successfully?
#include<stdio.h>

int main()

{

      #ifdef  NOTE

            int     a;

            a = 10;

      #else

           int a;

           a=20;

       #endif

        printf("%d`setminus`n" , a)'

        return 0;

}


Options:
A .  Yes
B .  No
Answer: Option A

Yes, this program will compile and run successfully and prints 20.

The macro #ifdef NOTE evaluates the given expression to 1. If satisfied it executes the 

#ifdefblock statements. Here #ifdef condition fails because the Macro NOTE is nowhere declared.

Hence the #else block gets executed, the variable a is declared and assigned a value of 20.

printf("%dn", a); It prints the value of variable a 20.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers