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 3 of 5.
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 "*".
Chandrabhan B. said:
1 decade ago
Why underscore allowed in variable formation as first character in variable?
Buvanesh said:
1 decade ago
Because, other symbols not allowed in variable formation as first char.
(1)
Jenifer said:
10 years ago
Why shouldn't (*)? Its a pointer variable right.
Madhu said:
10 years ago
What?
Can identifiers start with '$' symbol also? I know that only the special symbol allowed is '_' (underscore). Is it correct?
Can identifiers start with '$' symbol also? I know that only the special symbol allowed is '_' (underscore). Is it correct?
Ashwini said:
9 years ago
Yes '$' also allowed.
Manish sharma said:
9 years ago
Is this decalartion int_aera22; correct?
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
AKUGIZIBWE SAMUEL said:
9 years ago
Can we use underscore only as a variable name?
Swetha said:
9 years ago
Yes @Samuel.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers