Open In App

C | Storage Classes and Type Qualifiers | Question 19




#include <stdio.h>
int main() 
  int x = 10; 
  static int y = x; 
    
  if(x == y) 
     printf("Equal"); 
  else if(x > y) 
     printf("Greater"); 
  else
     printf("Less"); 
  return 0; 
}

(A) Compiler Error
(B) Equal
(C) Greater
(D) Less

Answer: (A)
Explanation: In C, static variables can only be initialized using constant literals. This is allowed in C++ though.  See this GFact for details.
Quiz of this Question

Article Tags :