Which of the following are valid identifiers in C?
a. empsal101
b. emp.sal101
c. 101emp_sal
d. emp sal 101
e. emp_sal101
f. 101empsal
g. emp101sal
-
a, c, g
-
b, d, f
-
a, e, g
-
b, c, d
-
e, f, g
C
Correct answer
Explanation
All of (a) empsal101, (e) emp_sal101 and (g) emp101sal are valid identifiers.
(b) emp.sal101, (c) 101emp_sal, (d) emp sal 101 and (f) 101empsal have mistakes.
In (b) emp.sal101 fullstop is used. (No other special symbol rather than underscore can't be used in names of identifiers.)
In (c) 101emp_sal a number is used in starting of identifier. (An identifier should not start with a number.)
In (d) emp sal 101 spaces are used. (Spaces are not allowed within names of identifiers.)
In (f) 101empsal a number is used in starting of identifier. (An identifier should not start with a number.)