Computer Science, asked by salinrout8342, 5 months ago

Q22. Dangling else problem occurs when
(A) There is no matching if
(B) There is no matching else
(C) There is no matching then
(D) There is no matching while​

Answers

Answered by chkartikkgp
0

Answer:

Answer c is the right answer please put tick on it

Answered by Sahil3459
0

Answer:

The correct option for this question is (A) There is no matching if.

Explanation:

Dangling else problem occurs when there is no matching if. The if-then-else statement's optional else clause causes nested conditionals to be confusing, which is an issue when parser generators are being programmed. There are multiple right parse trees since the language's reference context-free grammar is officially ambiguous. When a programmer assumes (or forgets) the code indent and loses track of the if statement that goes with the else statement, the dangling else problem occurs. The else statement will be connected to the last used if statement unless brackets are used to separate the code blocks.

Thus, the issue of the dangling else is in syntactic ambiguity. When we employ nested if, it happens.

Similar questions