For:
Sum = Var1 + Var2
Difference = Var1 - Var2
Quotient = Var1 / Var2
Product = Var1 * Var2

What
Exponent = ?

Thanks in advance...

I'm assuming you're not allowed to use the Math library or recursion.

If that's the case, use--

static double power(double value, short exponent){
       if(exponent >= 0){ // if exponent is greater than or equal to zero...
       double result = 1; // set result to one

       for(short i = 0; i < exponent; i++){ // doing something exponent times
             result = result * value; // result is assigned the number of itself times value
       }     
       
       return result; // return the result
       }else return 0; // exponent was less than 0 - return 0 for simplicity.
}

What if exponent is a double itself :-)

What if exponent is a double itself :-)

Then use the Math Library =P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.