Homework 19 Solution

1. Assuming the following declarations and initializations and prototypes:

double w = 0.25, u = 0.36;
int i=7;

// sqrt(x) is just like cmath's sqrt
double sqrt(double x);

// sqrt(k) returns true if the square root of k is a positive integer, false otherwise
bool sqrt(int k);

// round(x) returns integer nearest x
int round(double x);

Fill in the following table, giving the type and value of each expression.

 Expression Type Value sqrt(w) double 0.5 sqrt(-9) bool false round(sqrt(u)) int round(0.6) = 1 sqrt(5) || (i <2) bool false || false = false *

* If you said true || false then your probably read it as returns true if k is positive integer.

2. Step through this program with the debugger and figure out what useful work (if any) the mystery function accomplishes. In particular, use the "Step Into" button to step into calls to the function `mystery` ans watch it execute. Turn in a sentence telling me what this function does (not how it does it!).

It computes the factorial of the number.