Computer Science, asked by kanhaiya7891, 1 year ago

What are the rules for writing an identifier? Mention at least four rules.

Answers

Answered by shatakshim28
4

There are some rules you have to follow for naming identifiers:

1) The first character of the identifier

must be a letter of the alphabet

(upper or lowercase) or an

underscore ('_').

2) The rest of the identifier name can

consist of letters (upper or

lowercase), underscores ('_') or

digits (0-9).

3)Identifier names are case-sensitive. For example, myname and myName are not the same. Note the lowercase n in the former and the uppercase N in te latter.

4)Examples of valid identifier names are i, __my_name, name_23 and a1b2_c3.

5)Examples of invalid identifier names are 2things, this is spaced out and my-name.

Answered by mohdshahab829
2

Answer:

1. Each identifier must have at least one character.

2. The first character must be picked from: alpha, underscore, or dollar sign. The first character can not be a digit.

3. The rest of the characters (besides the first) can be from: alpha, digit, underscore, or dollar sign

4. Examples are - i, _my_name, name_23 etc.

Similar questions