Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

C | Storage Classes and Type Qualifiers | Question 19

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

#include <stdio.h>
int main() 
  int x = 10; 
  static int y = x; 
  if(x == y) 
  else if(x > y) 
  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

My Personal Notes arrow_drop_up
Last Updated : 10 Jul, 2018
Like Article
Save Article
Similar Reads