Reference no: EM131708537
Assignment: Integer Exponent Function
The exponentiation operator (^) is used to raise a number to a power. If the exponent is an integer >= 0, then:
x^0 = 1
x^1 = x*x^0
x^2 = x*x^1
x^3 =
.
.
.
x^n = x*x^(n-1)
1. Write a Function procedure that calculates xn using a For-Next Loop instead of the exponentiation operator. Your function will accept two input arguments: n (any integer >= 0) and x (any real floating-point number), and will return the result xn.
2. Validate that the integer input value is valid.
a. If it is valid, your function will return the resulting value of xn
b. If it is not valid, your function will return the following error code, using the VBA built-in error function:
CVErr(xlErrValue)
Where "xlErrValue" is the VBA built-in constant that results in function "CVErr" returning the error code "#Value!".
3. Test your function on a worksheet, with two clearly labeled and named input cells for values of x and n, and one clearly labeled output cell where you will use your function.