Ask Question
17 January, 17:22

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

+2
Answers (1)
  1. 17 January, 20:37
    0
    One of the things you can do is use recursion so the code you can use is like this, in order to do it simplier:

    double powerTo (double x, int y)

    {

    if (y < 1)

    return 1;

    else

    { return x * (powerTo (x, y-1));

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write the definition of a function powerto, which receives two parameters. the first is a double and the second is an int. the function ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers