Skip to content
Related Articles

Related Articles

C Quiz – 101 | Question 5
  • Difficulty Level : Easy
  • Last Updated : 30 Sep, 2015

Consider the following variable declarations and definitions in C




i) int var_9 = 1;
ii) int 9_var = 2;
iii) int _ = 3;


Choose the correct statement w.r.t. above variables.
(A) Both i) and iii) are valid.
(B) Only i) is valid.
(C) Both i) and ii) are valid.
(D) All are valid.


Answer: (A)

Explanation: In C language, a variable name can consists of letters, digits and underscore i.e. _ . But a variable name has to start with either letter or underscore. It can’t start with a digit. So valid variables are var_9 and _ from the above question. Even two back to back underscore i.e. __ is also a valid variable name. Even _9 is a valid variable. But 9var and 9_ are invalid variables in C. This will be caught at the time of compilation itself. That’s why the correct answer is A).

 

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :