Valid Identifiers

Q7. Which of the following are valid identifiers and why/why not:

Data_rec, _data, 1data, data1, my.file, asm, switch, goto, break.

Ans. Data_rec, _data and data1 are valid identifiers because there first character is either a letter or an underscore.

1data is not a valid identifier because its first character is neither a letter nor an underscore.

my.file is not a valid identifier because this sequence of letters conatin a ‘.’ (full stop) which is not allowed in identifiers.

asm, switch, goto and break are not valid identifiers because they are keywords.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: