1,067 views
0 votes
0 votes

Let L be the set of letters {_,A,B,...Z,a,b,…z} and D be the set of digits {0,1…9}. Then which of the following regular expression represents the set of valid C identifiers. Assume that any C keyword is also allowed as variable name.

  1.  L*(L+D)*
  2.  LL*D*
  3.  L(L+D)*
  4.   None of the above

Please explain with valid reason..?

Thanks,

1 Answer

2 votes
2 votes

In this question the premise assumes that we are only talking about identifier construction with digits and letter as given in form of two sets , D and L.

The regular expression is:= L(L+D)* because the first character in naming an identifier should be a letter then it can be followed by any digit or letter.

Hence the answer is C.

I am providing a snapshot which gives a similar regular expression for C identifier construction:

Related questions

3 votes
3 votes
1 answer
1
ashishgateashish asked Mar 13, 2018
1,156 views
Part A:Given : (b|ab*ab*)* How can it be interpreted as:1.((b+ab*)ab*)* 2.(b+(ab*ab*))*3.((b+a)b*ab*)*Part B:1.What will be its NFA ? 2.Can we draw a direct MINIMAL DFA f...
0 votes
0 votes
0 answers
2
iarnav asked Jan 30, 2018
202 views
L = anbm / n,m>=1What type pf Language is this? Also, please tell are n,m are independent or dependent i.e can we have like n=2 and m=3 or both n,m have to have same valu...
0 votes
0 votes
0 answers
3
prabhath challa asked 1 day ago
18 views
what will be the regular expression of this DFA using Arden's theorem