Show which of the following are valid and which are invalid

Show which of the following are valid and which are invalid identifiers: Why?

1) run_1

2) 2run

3) double

4) Char

5) double-trouble

6) two*four

Solution

Answer:

Valid:

1) run_1

4) Char

Char: identifiers are case senstive so Char is valid. we have char reserve for character data type.. Since Char is havinf C capital, we can use it

run_1: it meets indetifier rules so no issues.

Invalid:

2) 2run

3) double

5) double-trouble

6) two*four

double is revesred key word. it is a data type. we can not use for identifier.

2run: identifier name should start with character or underscore(\"_\")

double-trouble & two*four: identifier can have only letters (a-z) or (A-z) or 0-9 or underscore/.

Show which of the following are valid and which are invalid identifiers: Why? 1) run_1 2) 2run 3) double 4) Char 5) double-trouble 6) two*fourSolutionAnswer: Va

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site