What is dangling else problem and why does this appear here
What is dangling else problem and why does this appear here
Describe the \"dangling else problem\". That is, describe why the code fragment below can have different meanings and why this problem is caused by the grammar. if C1 then if C2 then S1 else S2Solution
Dangling else : The phenomenon of having to pick between one of two possible if conditions
Given grammar can be written in following ways.
if C1
if C2
S1
else
S2
In above snippet, else is there for second if condition
if C1
if C2
S1
else
S2
In above snippet, else it there for first if condition
We have 2 different possibilities for the grammar given.
This Dangling Else problem is cause because of not using
