10,287 views

In some programming language, an identifier is permitted to be a letter followed by any number of letters or digits. If $L$ and $D$ denote the sets of letters and digits respectively, which of the following expressions defines an identifier?

1. $(L + D)^+$
2. $(L.D)^*$
3. $L(L + D)^*$
4. $L(L.D)^*$

### 3 Comments

edited
from [D] we can not generate letter followed by letters only or letter followed by digits.
a letter followed by( any number of( letters or digits)*).

## 8 Answers

Best answer

Correct Option: C

It has to be started by a letter followed by any number of letters (or) digits.

### 4 Comments

Letter followed by any number of letters OR digits

Letter followed by any number of letters AND digits.

How they are different ??

Letter followed by any number of letters AND digits.

this means letter should be followed by both letters and digits.

A3 and AB will be rejected in this case

@karthikeyan
(L U D) or L+D defines elements either in L or in D or in both. In question they have asked "letters or digits", hence LUD.

It has to be started by a letter

Question is of form- R.E. which starts with L

Hence answer is C
Simply

Option C. L(L+D)*
Answer:

26 votes
5 answers
1
13,474 views
30 votes
8 answers
2
8,468 views
40 votes
6 answers
3
12,450 views
31 votes
4 answers
4
18,370 views