In: Computer Science
Indicate which of the following are valid C++ variable names and which are not. If not, state the reason the name is invalid.
Variable Name |
Valid – Yes/No |
If Invalid – Reason |
income |
||
2time |
||
int |
||
Tom's |
||
two fold |
||
c3po |
||
income#1 |
||
item |
Answer:
Variable Name |
Valid – Yes/No |
If Invalid – Reason |
income |
Yes |
|
2time |
No |
Variable name should start with character or _ |
int |
No |
int is a reserved keyword to define an integer variables. So we should not use |
Tom's |
No |
' character is no a valid escapte char for variable name. Only _ underscore allowed |
two fold |
No |
Space should be there in variable name |
c3po |
Yes |
|
income#1 |
No |
Only _ allowed in variabe name |
item |
Yes |