[dir] Zum Verzeichnisinhalt     [exercise] Zum Aufgabenblatt     [download] (SHIFT + Linke Maustaste)
@=~
~p maximum_input_line_length = infinity

~A~<Dangling Else~>

The else part of ~{if~} statements is optional. Nested ~{if~} statements
like the following are errorprone:
~O~<dangling.in~>~{~-
{   
  int i, z;
  i = read();
  if (i>=0)
  if (i<10) z = 5+i;
  else      z = 0;
  print (z);
}
~}

C defines that the else belongs to the inner ~{if (i<10)~}.
The programmer might have intended to associate it to the
outer ~{if (i>=0)~}.
Hence the style guide requires to avoid such situations, e.g.
by additional curly braces. Your analysis tool shall emit a warning
if such a dangling else occurs:

~O~<dangling.out~>~{~-
"dangling.in", line 5:3 WARNING: beware of dangling else!
~}

The following questions may help to focus your attention on the
significant aspects of this problem:

1. Which are the adjacent tree contexts that will cause the warning?

2. In which context is the warning issued, and what is its precondition?

~B~<Solution~>

Fill in the description of your solution here.

~$~<dangling else computations~>~{

/* Fill in your Lido specification here. */

~}

~B~<Further Questions~>

1. Did you get messages on missing computations? 
If so, explain why.

2. Reconsider your solution when you have learned about
SYMBOL computations. How can you use them to simplify
your solution?

~B~<Output files~>

~O~<dangling.lido~>~{
~<dangling else computations~>
~}