Ask Question
5 May, 04:57

Write an efficient C+ + function that takes any integer value i and returns 2^i, as a long value. Your function should not multiply 2 by itself i times; there are much faster ways of computing 2^i.

+1
Answers (1)
  1. 5 May, 05:21
    0
    long power (int i)

    {

    return pow (2, i);

    }

    Explanation:

    The above written function is in C++. It does not uses loop. It's return type is long. It uses the function pow that is present in the math library of the c++. It takes two arguments return the result as first argument raised to the power of second.

    for ex:-

    pow (3,2);

    It means 3^2 and it will return 9.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write an efficient C+ + function that takes any integer value i and returns 2^i, as a long value. Your function should not multiply 2 by ...” 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