ExamVeda
Login
Home
Introduction to C plus plus
?

Which of the following is not a valid C++ identifier?

Answer & Solution
Correct Answer: Option E
C++ Identifiers: Naming Rules
In C++, identifiers are names you give to things like variables, functions, and classes. They must follow specific rules.

Rules for Valid Identifiers:
1. They can contain letters (a-z, A-Z), digits (0-9), and underscores (_).
2. They must begin with a letter or an underscore.
3. They cannot contain spaces.
4. They cannot be C++ keywords (like int, float, while, etc.).

Let's Check the Options:
A) _variableName: This is valid. It starts with an underscore and uses letters.
B) 2ndVariable: This is invalid. Identifiers cannot start with a digit.
C) variable_name@: This is invalid. It contains the "@" symbol, which is not allowed.
D) VariableName: This is valid. It starts with a letter and uses letters.

Therefore, the correct answer is E, Both (B) and (C) are not valid C++ identifiers.
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Bhawna Wadhwa
Bhawna Wadhwa 2 years ago
Sir plz check valid identifier. 2 identifier galat h isme
Sir ek ek number ki value hoti h.
Questions bahut ache h lakin ek answer galat ho to sab dusri site search karte h
Plz 🙏 h iska andwers update kre ya reason de