A good answer might be:

Here is the example fragment properly indented and with matching if's and else's colored the same.

if ( a == b )
  
  if ( d == e )
    total = 0;
  
  else
    total = total + a;

else
  total = total + b;

Make Matches clear with Braces

Sometimes you have to use braces { and } to say exactly what you want. Other times you don't absolutely need them, but using them makes clear what you want. Here is the complete rule, including braces:

Rule for Matching if and else:   An "else" inside a set of braces cannot match an "if" outside of that pair. Within each pair of matching braces: start with the first "if" and work downward. Each "else" matches the closest preceeding unmatched "if." An "if" matches only one "else" and an "else" matches only one "if."

Here is a program fragment that uses braces:

if (  ch == 'q' )
{
    if ( sum == 12 )
          ch = 'b' ;
}
else
    ch = 'x' ; 

The blue if and blue else match. Without the braces, they would not match. Here is another, poorly indented, fragement:

if ( a == b )
{  
if ( d == e )
  total = 0;

else
  total = total + b;
}

QUESTION 12:

Match the if's and else's.