Ask Question
9 May, 06:31

Write the definition of a method powerto, which receives two parameters. the first is a double and the second is an int. the method returns a double. if the second parameter is negative, the method returns zero. otherwise it returns the value of the first parameter raised to the power of the second parameter.

+1
Answers (1)
  1. 9 May, 09:05
    0
    The case of x⁰=1 is one you shouldn't overlook!

    double powerto (double f, int exponent)

    {

    if (exponent < 0) { return 0; }

    if (exponent = = 0) { return 1.0; }

    while (--exponent > 0) { f * = f; }

    return f;

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write the definition of a method powerto, which receives two parameters. the first is a double and the second is an int. the method returns ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers