Which of the following are legal variable name in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Which of the following are legal variable name in c++?

1:- name3_var 2:- 14var 3:- &*^var 4:- salary Note:-In this question has two answer

19th May 2019, 2:40 PM
Ashish Mewada
Ashish Mewada - avatar
12 Answers
+ 14
1 and 4 are legal
21st May 2019, 5:21 AM
Tushar
Tushar - avatar
+ 12
Variable names have to begin with an alphabetic character or _ and cannot contain special characters other than _ (underscore).
20th May 2019, 2:59 AM
Sonic
Sonic - avatar
+ 5
The answer is 1&4 ..
19th May 2019, 2:58 PM
Vijendra Mewada
Vijendra Mewada - avatar
+ 4
1 & 4
20th May 2019, 8:48 AM
AWI
AWI - avatar
+ 4
Option 1 and 4 are correct. No numbers allowed at the start of the var name No special characters except _ is allowed
20th May 2019, 11:27 AM
HariHaran
HariHaran - avatar
+ 3
As replied above 1 and 4
20th May 2019, 3:00 PM
Abhinav
+ 3
One and four(1 and 4)!
20th May 2019, 5:07 PM
CodeFu
CodeFu - avatar
+ 3
14
20th May 2019, 10:41 PM
Gagan Deep Singh
Gagan Deep Singh - avatar
+ 1
A variable name can start with alphabet and underscore only. It can't start with digit.
20th May 2019, 3:21 PM
Ankit Mewada
Ankit Mewada - avatar
+ 1
the dependent variable starts "int" or gives a value to a letter depending on the operation to be performed, example: sum
21st May 2019, 3:00 AM
nigthcrawler
0
1&4
14th May 2021, 12:28 PM
Subham Dey
0
1 and 4
3rd Dec 2022, 2:17 PM
Hamza Ali Shabbir
Hamza Ali Shabbir - avatar