173k views
2 votes
Check if the following identifiers are valid: 1. c 2. cat 3. n1m1 4. short1 5. _hello, 6. 42c, 7. hi there, 8. cat!

User Rayjax
by
5.3k points

1 Answer

3 votes

Answer:

Only option 6 and 7 are not valid but the option 1,2,3,4,5 and 8 are valid.

Step-by-step explanation:

Identifier means the name which is defined for any programming language. There is a need for a variable in any programming language which is used to store the value to perform the calculation with the help of instruction.There are 2 rules which state that how a user can define an identifier. They are as follows--

  1. The identifier name must not start with any number.
  2. The identifier name can not hold the special symbol except underscore(_) either in start point or any other place.

The above question wants to know that which option is valid or not which are as follows--

  • Option 6 and 7 are not valid because the identifier of option 6 starts with number and the identifier of option 7 hold space.
  • Option 1,2,3,4,5 and 8 are valid because the identifier of these options has not neglected the rule to declare the identifier which is defined above.

User Vitor Canova
by
6.0k points