I'm working on an assignment where I have to write my own raisePower function to take a base and a power and compute the product. The assignment states that the function needs to return a long but all input/output values should be ints. The code compiles and runs but does not produce the correct product. Any help or suggestions would be appreciated. Thanks.
#include <iostream>
using namespace std;
long raisePower(int base, int power)
{
long product;
for (int i = 1; i <= power; i++)
{
product = base * base;
}
return product;
}
int main()
{
int base;
int power;
int product;
cout << "Enter an Integer for the Base: ";
cin >> base;
cout << "Enter an Integer for the Power: ";
cin >> power;
product = raisePower(base, power);
cout << base << " Raised to the Power of " << power << " is " << product << "\n";
return 0;
}