Interview Questions

Why doesn't C have an exponentiation operator?

C Interview Questions and Answers


(Continued from previous question...)

Why doesn't C have an exponentiation operator?

One reason is probably that few processors have a built-in exponentiation instruction. C has a pow function (declared in <math.h>) for performing exponentiation, although explicit multiplication is usually better for small positive integral exponents. In other words, pow(x, 2.) is probably inferior to x * x. (If you're tempted to make a Square() macro, though, check

(Continued on next question...)

Other Interview Questions