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 4 of 5.

Kittu said:   1 decade ago
@sudi, s area_2 is correct, because digits can be used in variable.

Animesh said:   1 decade ago
We can't use special symbol in a variable name excluding underscore(_)

Ravi said:   1 decade ago
It is necessary to declare variable in this format.

Sunil said:   1 decade ago
As only underscore is predefined to used as variable name.

Keshav said:   1 decade ago
Why only _ underscore is allowed?

Subhalaxmi said:   1 decade ago
I can not understand the question clearly? can you give full explanation?

Sudi said:   1 decade ago
Is the declaration int area_2; correct?

Kanakam vinay kumar said:   1 decade ago
You are Correct prathyu.

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!...

Sureshkumar said:   1 decade ago
Where to use underscore operator? can you give me the merits and demerits?


Post your comments here:

Your comments will be displayed after verification.