previous | start | next

## Program Traces

- To get a printout of the program flow, you can insert trace messages into the beginning and end of every procedure.
- It is also useful to print the input parameters when a procedure is entered and to print return values when a function is exited.

  >     string int_name(int n)
  >     {
  >        cout << "Entering digit_name. n = " << n << "\n";
  >        ...
  >        cout << "Exiting digit name. Return value = "
  >           << s << "\n";
  >        return s;
  >     }

- To get a proper trace, you must locate each function exit point.
- Sample output for `n` = 12305.

  >     Inside int_name. Thousands.
  >     Entering int_name. n = 12
  >     Inside int_name. Teens.
  >     Entering teen_name. n = 12
  >     Exiting teen_name. Return value = twelve
  >     Exiting digit_name. Return value = twelve
  >     Inside int_name. Hundreds.
  >     Entering digit_name. n = 3
  >     Exiting digit_name. Return value = three
  >     Inside int_name. Ones.
  >     Entering digit_name. n = 5
  >     Exiting digit_name. Return value = five
  >     Exiting int_name. Return value = twelve thousand three hundred five

previous | start | next