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?
* (asterisk)
| (pipeline)
- (hyphen)
_ (underscore)
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 5 of 5.

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;

Thiru said:   2 decades ago
Names must not begin with a digit.??Is this is right?


Post your comments here:

Your comments will be displayed after verification.