C Programming - Declarations and Initializations - Discussion
Discussion Forum : Declarations and Initializations - General Questions (Q.No. 3)
3.
Which of the following special symbol allowed in a variable name?
Answer: Option
Explanation:
Variable names in C are made up of letters (upper and lower case) and digits. The underscore character ("_") is also permitted. Names must not begin with a digit.
Examples of valid (but not very descriptive) C variable names:
=> foo
=> Bar
=> BAZ
=> foo_bar
=> _foo42
=> _
=> QuUx
Discussion:
42 comments Page 1 of 5.
Prathyusha said:
1 decade ago
AS FAR AS I KNOW , VARIABLE DECLARATION RULES:
1]VARIABLE NAME MUST START WITH A LETTER OR SPECIAL CHARACTER UNDERSCORE(_)IS ALSO ALLOWED AS FIRST CHARACTER.
2]OTHER THAN UNDERSCORE NO OTHER SYMBOL IS ALLOWED IN VARIABLE NAME.
3]VARIABLE NAME CAN BE 32 CHARACTERS(THIS IS SYSTEM DEPENDENT)
4]VARIABLES MUST NOT CONTAIN ANY KEYWORDS.
CORRECT ME IF I AM WRONG!...
1]VARIABLE NAME MUST START WITH A LETTER OR SPECIAL CHARACTER UNDERSCORE(_)IS ALSO ALLOWED AS FIRST CHARACTER.
2]OTHER THAN UNDERSCORE NO OTHER SYMBOL IS ALLOWED IN VARIABLE NAME.
3]VARIABLE NAME CAN BE 32 CHARACTERS(THIS IS SYSTEM DEPENDENT)
4]VARIABLES MUST NOT CONTAIN ANY KEYWORDS.
CORRECT ME IF I AM WRONG!...
Tejesh said:
9 years ago
No, @Manish, it is not the correct way to declare any variable between datatype and variable name space will be required because compiler not recognises which one is datatype and which one is a variable name.
int _aera22; this means int[space] _aera22;
This is correct declaration
int _aera22; this means int[space] _aera22;
This is correct declaration
Drashti said:
1 decade ago
@Sachin.
it means that variable name can contain only 32 characters not more than it system depend means it is dependent on system that how many character system will allow.
Ex. Assume that one system allow 32 char. Other allow 28.
So i hope YOu understand.
it means that variable name can contain only 32 characters not more than it system depend means it is dependent on system that how many character system will allow.
Ex. Assume that one system allow 32 char. Other allow 28.
So i hope YOu understand.
Rajan said:
1 decade ago
Yes Thiru. Variables should start only with an alphabet or _ (underscore).
Examples:
Valid statements:
int a;
int area2;
int _Sum;
int A_Sum;
int _23area;
Invalid statements:
int 23area;
int @ss;
Examples:
Valid statements:
int a;
int area2;
int _Sum;
int A_Sum;
int _23area;
Invalid statements:
int 23area;
int @ss;
Saisree said:
8 years ago
The C rule of declaring variable name says that variable name starts with the underscore but not with other special characters, but $ can also be used right. Then why it is not mentioned in c rules.
Keerthana said:
8 years ago
@ALL.
1) variable names can contain;
a)A-Z
b)a-z
c)0-9
d)underscore character
2) First character must be letter or underscore.
3) The special characters are not allowed like #,$ etc.
1) variable names can contain;
a)A-Z
b)a-z
c)0-9
d)underscore character
2) First character must be letter or underscore.
3) The special characters are not allowed like #,$ etc.
Vidya said:
9 years ago
The C rule of declaring variable name says that variable name starts with the underscore but not with other special characters, and it should not be any identifier name.
Sachin said:
1 decade ago
Variable name can be 32 character. (this is system dependent).
What is exact meaning of variable name is 32 character?
What is meaning of system dependent?
What is exact meaning of variable name is 32 character?
What is meaning of system dependent?
Ragaveni said:
1 decade ago
To @Sudi as per me,
We cannot use any other symbol except (_) and always variable name starts with a letter or (_) after any one of this we can use digits.
We cannot use any other symbol except (_) and always variable name starts with a letter or (_) after any one of this we can use digits.
Sonam said:
1 decade ago
How compiler will know that int*p; is a pointer variable? Because in other way round variable name is not allowed to began with "*".
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers