You're writing a program that needs to efficiently calculate the power of 2 for a given exponent. Which operator would be most efficient to use?

  • * (Multiplication)
  • ** (Exponentiation)
  • << (Left Shift)
  • ^ (Bitwise XOR)
The correct answer is C) ** (Exponentiation). To efficiently calculate the power of 2 for a given exponent, you should use the exponentiation operator (**).
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *