Computer Science, asked by rakheekohli, 9 months ago

Which of the following variable names are invalid. Give reasons.

(i) My.var (ii) 1input (iii) st$name (iv) e_salary​

Answers

Answered by stylishtamilachee
4

Answer:

(i) My.var - This is an invalid variable. Because it has a special character ( which means other than A to Z, a to z and _ or $ )

(ii) 1input - This is an invalid variable. Because it starts with a digit.

(iii) st$name - This is a valid variable.

(iv) e_salary - This is a valid variable.

Explanation:

  • A variable is a named memory location, which holds a data value of a particular data type.

  • While naming variables, you should make sure to follow identifier naming rules and conventions.

  • Variables are also called as symbolic variables.
Answered by AmoliAcharya
0

My.var and 1input are invalid.

(i) Variable names cannot contain period(.).

(ii) Variable names cannot start with a digit. The first character must be a letter.

(iii) It is valid since $ is used in variable names.

(iv) Underscores are allowed in variable naming.

#SPJ6

Similar questions