Hey guys I have a program im doing for fun, I need to be able to enter a minimum exponent and a maximum exponent as well as a base. CANNOT USE THE POW() FUNCTION.
Ex.
minimum exponent = -2
maximum exponent = 3
base = 2
output:
base exponent result
2 -2 0.25
-1 0.5
0 1
1 2
2 4
3 8
Here is what I have so far.
#include <iostream.h>
void ExpPow(float &res, int base, int count);
void negexp(float &res, int base, int count);
int main()
{
int base;
int expow;
int expomax;
int count;
float res = 1;
cout << "Please enter a maxiumum exponent value" << endl;
cin >> expomax;
cout << "Please enter a minimum exponent value" << endl;
cin >> expow;
cout << "Please enter a base" << endl;
cin >> base;
//intitialization of the for loop
for(count = expow; count <= expomax; count++)
{
//If exponent is negative
if (expow < 0)
negexp(res, base,count);
else
ExpPow(res, base,count);
cout << res << endl;
}
return 0;
}
void ExpPow(float &res, int base, int count)
{
res = res * base;
}
void negexp(float &res, int base, int count)
{
res = (1/(res * base));
}
ANY HELP APPRECIATED!