/* Homework 10(a): The program below computes the factorial of an integer using pointers. Please read the comments provided below to understand better. */ #include #include using namespace std ; /* int factorial ( int num ) //here we are providing the value of the integer num. //Function is called by value for example factorial(4) { int i =1, fact; //fact =i ; while(i <= num) { // cout << "Iteration number " << i << endl; if (i ==1) { fact = 1 ; //initialization // cout << "We are on iteration number = "<< i << endl; } fact=fact*i; i++; } return fact ; } */ void factorial ( int *num ) //here we are providing the a pointer num to the integer *num which is called by pointer num. { int i =1; int temp =*num; //we need to temporarily store the number *num whose factorial we seek. //cout << "Num whose factorial we seek: "<< *num <> x; //Calculate the factorial using loop cout << "calculating the factorial of "<< x << endl; factorial(num); // recall, num here is a pointer and this is what we mean by calling a function // by reference we are pointing to the address instead of introducing a new variable fact // where we will store a variable, we just replace at the address of x, the value of its // factorial. cout << "the factorial is "<< *num <