C Objective

What will be output if execute the following c code?

 int main()  
       int i=10;  
       static int x=i;  
      else if(x>i)  
         printf("Greater than");  
         printf("Less than");  
    return 0;  

 a) Equal 
 b) Greater than 
 c) Less than 
 d) Compiler error 
 e) None of above 

Answer: (d) 

Explanation: Static variables are load time entity while auto variables are run time entity. We cannot initialize any load time variable by the run time variable.In this example i is run time variable while x is load time variable.

No comments:

Post a Comment