Science, asked by ifrahzameer463, 1 year ago

What is dangling else problem in c on campus?

Answers

Answered by kvnmurty
0
When there are many nested if statements but having only one else statement, then it is a case of dangling else statement.

There could be confusion regarding to which if , the else statement belongs.  

   if (expr1) 
     if (expr2) 
              if (expr3)
                   else stmnt.

Normally it belongs to the innermost.  But it depends on the language grammar definition.  It is better to put { } to clearly indicate the nesting.


kvnmurty: :-)
Answered by Anonymous
10

Explanation:

Dangling else. The dangling else is aproblem in computer programming in which an optional else clause in an if–then(–else) statement results in nested conditionals being ambiguous.

Similar questions