+ 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
5 Respuestas
+ 9
There are certain rules for naming c++ variables.
https://mathbits.com/MathBits/CompSci/DataBasics/naming.htm
+ 5
You will find that a number of languages don't allow a variable to start with a number.
+ 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 !!
+ 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
+ 1
you cant start a variable with a number