• Post author:
  • Post category:Blog
  • Reading time:2 mins read
  • Post last modified:June 12, 2024

Which of the following identifiers is an invalid variable name?

  • 0_
  • _0_
  • _0
  • ___
Explanation & Hints:

In most programming languages, variable names must adhere to specific rules. Typically, these rules include:

  1. The name must start with a letter (uppercase or lowercase) or an underscore (_).
  2. The name can only contain letters, digits, and underscores.

Given these rules, let’s evaluate the provided identifiers:

  1. 0_: This is an invalid variable name because it starts with a digit.
  2. 0: This is a valid variable name. It starts with an underscore and contains only letters and underscores.
  3. _0: This is a valid variable name. It starts with an underscore and contains only letters and underscores.
  4. ___: This is a valid variable name. It starts with an underscore and contains only underscores.

So, the invalid variable name is 0_.

For more Questions and Answers:

Basic data types, operations, and flow control (decision-making statements) Module 2 Test Answers Full 100%

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments