The most appropriate answer is (A) [It can also be B, if its possible to reduce into unambiguous].
Let me explain...
'Dangling Else' problem is like deciding with WHICH 'if' some 'else' can go with. Say for following...
ex1) X --> S | b
S --> if E X else a | if E X
ex2) S --> if E S else a | if E S | b
Both of the above cases suffers through Dangling Else problems. Why? Both can derive, " if E if E b else a" . (E stand for some expression in Code.) Now, with which 'if' should we configure our 'else'. Compilers (LALR(1) in our day to day life) uses the approach of choosing 'nearest if' . But this is just ONE of the way to resolve this so called ambiguity. Some other methods are...
1) Associate dangling else with nearest if by using some matching/unmatching statemnets
2) By using something like 'endif' for marking the end of of conditional structure.
3) By using opening ( { ) and closing ( } ) curly braces around statements.
4) By using different precedence rules to associate the dangling else with nearest if. (By using lower precedence for THEN and higher precedence for ELSE. Try it.) And by doing this and other techniques you are HANDLING ambiguity in grammer.
5) By insisting space indentation.
A nice article on this by "Efstathios Chatzikyriakidis" (What a name :) ) Check it out @ http://efxa.org/2014/05/17/techniques-for-resolving-common-grammar-conflicts-in-parsers/