What is the layout to to declare a variableis it intaor int_3or int a3? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the layout to to declare a variableis it intaor int_3or int a3?

1 st lesson of variable last paragraph

27th Jul 2016, 4:07 PM
Sanskar Jain
Sanskar Jain - avatar
6 Answers
+ 3
int a3; is the correct one
27th Jul 2016, 4:14 PM
Karan Luther
Karan Luther - avatar
+ 3
If you use "inta" and "int_3" without space after "int" its wrong. If all three are like : int a ; int _3 ; int a3 ; are all right. Here "a", "_3", "a3" are variable names of data type "int". Rules for naming variables in C++ : A variable name should be start with an alphabet or a underscore "_". A variable name can have alphabets "a to z", "A to Z", numbers "0 to 9" and an underscore "_". examples: a a1 _a _1 _a1 a_1 a_11 a13 a16_ _3a abc _abc _ab45 ab45 all of these are correct.
28th Jul 2016, 5:39 AM
Preetam Daila
Preetam Daila - avatar
+ 2
int a; int _3; int a3; are all right ways to declare an integer variable but the first one is more used.
28th Jul 2016, 12:39 AM
Julien
+ 1
but in ques. we find int a more
27th Jul 2016, 6:12 PM
Sanskar Jain
Sanskar Jain - avatar
+ 1
Yah we can use any variable name. Here in the programs they are more comfortable with int a. But you can use others such as int _a , int a1 , int abc , and so on . But we cannot declare a variable beginning with a number or special character (except underscore ) . Example : int 3n is wrong int $a is wrong
28th Jul 2016, 3:14 PM
Programmer
0
Thanks
28th Jul 2016, 4:58 PM
Sanskar Jain
Sanskar Jain - avatar