
Patrick B. answered 05/29/19
Math and computer tutor/teacher
It is in math.h
#include <math.h>
no need to re-invent the wheel...
the basic algorithm is:
int result=1;
for (loop=0; loop<expo; loop++)
{
result = result * base;
}
However, you have multiple cases to consider:
base can be negative
exponent can be negative
base can be 1 or zero.
base=0 and exponent=0 is undefined
base=0 and exponent<0 is undefined
negative exponent means the RECIPROCAL must be returned.
etc