Skip to content
Related Articles

Related Articles

Improve Article

C Quiz – 101 | Question 5

  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021

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

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :