Open In App

C Quiz – 101 | Question 5

Like Article
Like
Save
Share
Report

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


Last Updated : 28 Jun, 2021
Like Article
Save Article
Share your thoughts in the comments
Similar Reads