Variable names in C++ can begin with which of the following?

Prepare for the ASU CSE100 Programming Exam with C++ Study Guide. Review flashcards, multiple choice questions, with hints and explanations. Master your exam!

In C++, variable names must begin with a letter or an underscore. This allows the compiler to recognize the start of an identifier correctly. Starting with a letter (such as A-Z or a-z) ensures that the variable name conforms to the naming conventions established in the C++ language standard. After the first character, variable names can include letters, numbers, and underscores.

Thus, beginning with a letter is valid and essential for ensuring that the variable name is recognized as such. Other options, like starting with a number or a special character, are not allowed and would result in a compilation error. Additionally, whitespaces in variable names are not permitted, as they would confuse the compiler in distinguishing different identifiers. Hence, starting with a letter is the only acceptable answer for valid variable naming in C++.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy