Why is the answer correct? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 3

Why is the answer correct?

The forth quiz in Data Types, Arrays, Pointers The second question is,'Which of the following are legal variable names in C++?' The choices are 'salary' '14var' name3_var' '&*^var' The answer is 'salary' and 'name3_var' Even though I know why 'salary' is correct But I have no idea why 'name3_var' is correct If 'name3_var' is correct, why isn't '14var' correct

1st Jul 2018, 11:12 AM
lemonsuen
lemonsuen - avatar
5 Respostas
+ 9
There are certain rules for naming c++ variables. https://mathbits.com/MathBits/CompSci/DataBasics/naming.htm
1st Jul 2018, 11:16 AM
Hannah Grace
Hannah Grace - avatar
+ 5
You will find that a number of languages don't allow a variable to start with a number.
1st Jul 2018, 11:21 AM
Duncan
Duncan - avatar
+ 2
it's starting with 14var ,it's shouldn't have digits at first It should have case sensitive alphabet then you can go with 0-9 digits and any special symbol so,but it should start with alphabet it's rule !!
15th Jul 2018, 1:54 PM
Harsh Dave
Harsh Dave - avatar
+ 1
An identifier must start with a letter We can also use digits and underscores (after starting with a letter ) Uppercase and Lowercase are different ā˜Read these points
1st Jul 2018, 3:08 PM
Aveek Bhattacharyya
Aveek Bhattacharyya - avatar
+ 1
you cant start a variable with a number
4th Jul 2018, 11:30 AM
Neo
Neo - avatar