November 1999
Intermediate to advanced
240 pages
5h 22m
English
Difficulty: 9
This problem presents an interesting challenge: How many execution paths can there be in a simple three-line function? The answer will almost certainly surprise you.
How many execution paths could there be in the following code?
String EvaluateSalaryAndReturnName( Employee e )
{
if( e.Title() == "CEO" || e.Salary() > 100000 )
{
cout << e.First() << " " << e.Last() << " is overpaid" << endl;
}
return e.First() + " " + e.Last();
}
To provide a little structure here, you should start by relying on the following three assumptions, and then try to expand on them.
Different orders of evaluating function parameters are ignored, and failed destructors are ignored.
Called functions are considered atomic.
To count ...
Read now
Unlock full access