Two if-structures should do the trick
The flowchart shows this function. The code for this flowchart is
/*
pre-condition:
a, b, and c are integers.
exit condition:
return the maximum of the three arguments.
*/
int maxThree(int a, int b, int c)
{
int max;
if (a >= b && a >= c)
max = a;
else
if (b >= c)
max = b;
else
max = c;
return max;
}
The flowchart is easy to follow, and the code follows it, so this is a good design, at least according to structuring principles.
If the maximum is a, how soon in the code is this known?