/* Homwork two:(Binomial Theorem) We know (x+y)^3 = x^3 + 3xy^2 + 3 x^2y + y^3 Now, we want this to be verified via a simple program which takes in two numbers x and y and an exponent say n. Then returns (x+y)^n. Next, we want a loop which calculates the binomial rule for this i.e., we want x^n + n xy^(n-1) + ... Need the task for calculating the binomial coefficients first. for which, we need the factorial of a whole number set up right. */ #include #include using namespace std ; unsigned int factorial ( unsigned int num ) { 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 ; } int main() { cout << "Hi!" << endl ; unsigned int num = 1; //Input the number and save it. cout<<"Enter the no."<> num; cout << "You typed "<< num << endl; //Calculate the factorial using loop cout << "the factorial is: "<< factorial(num)<< endl; return 0; }