Computer Science, asked by bans3566, 11 months ago

Which of the following variable names are invalid ? Justify.
(a) try
(b) 123 Hello
(c) sum
(d) abc@123

Answers

Answered by letmeanswer12
10

The 'sum' is valid variable name.

Explanation:

The following are the rules for declaring variable names.

  • The characters [A-Z], [a-z] or [0-9], $(dollar sign) and _(underscore) in a valid identifier.
  • An identifier should not declare with space.
  • An identifier should not start with a number.
  • An identifier ideally should be of 14-15 characters for appropriate use.
  • An identifier should not use Reserved words.

According to the above rule set in our scenario:

  • (a) try - Reserved word can’t be used as an identifier.
  • (b) 123 Hello - Variable names should not start with a digit.
  • (d) abc@123 - Special characters aren’t allowed in variable names.

Similar questions