//DISPLAY 4.16 Factorial Function #include using namespace std; //Function Declaration int factorial(int n); //Returns factorial of n. //The argument n should be nonnegative. int main () { int k; cout <<"Enter a natural number:"; cin >> k; cout <<"TRACING: calling factorial with argument " << "=" << k << endl; int result = factorial (k); cout <<"TRACING: After function call\n"; cout <<"n="<< k <<"factorial of " << k << " = " << result << endl; return 0; } //Function Definition int factorial(int k) { cout <<"TRACING: inside factorial, k=" << k << endl; int product = 1; while (k > 0) { product = k * product; k--; } cout <<"TRACING: Before returning: " <<" k= " << k <<" return " << product << endl; return product; }