Which of the following is the correct identifier? *
$var_name
VAR_123
varname@
123varname
Answers
Answer: (b) VAR_123
Explanation:
VAR_123 is the correct identifier.
An identifier is a combination of alphanumeric characters. An identifier starts with an alphabet or an underscore, followed by numeric digits .
#SPJ3
VAR_123 is the correct identifier.
Extra Information
Rules for variables/identifiers in C++ language
1. Variable/Identifier name can start with a letter or underscore ( _ ) character only which means it cannot start with a number.
2. C++ is a case-sensitive language which means variable/identifiers names are also case-sensitive.
Example - These three are different variables age, AGE, Age
3. Variable/Identifier names can only have alphanumeric characters (A-Z, a-z, and 0-9) and underscore ( _ )
Variable can be short or long/descriptive.
Example - x, y, z, age, gender, Address, _var, etc.
Note - Variable names can't have whitespaces, special characters such as !, #, %, etc. and variable names can't be a keyword that is reserved such as float, int, etc.
What is case sensitivity?
Case sensitivity is the term that tells us about the programming language capability of making out differences between Upper Case Letters and Lower Case Letters.