Which of the following is not a valid C variable name?

Which of the following is not a valid C variable name?

a) var_1
b) 1_var
c) _var
d) var1

Answer:

b) 1_var

Explanation:

In C, variable names must begin with a letter or an underscore (_). They cannot start with a digit. Therefore, 1_var is not a valid variable name because it begins with a digit. Valid variable names can contain letters, digits, and underscores, but they must always start with a letter or underscore.

Understanding the rules for variable naming in C is essential for writing clear, error-free code that adheres to the language’s syntax.

Reference links:

https://www.rameshfadatare.com/learn-c-programming/

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top