C Quiz – 101 | Question 5
Consider the following variable declarations and definitions in C
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.
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).