Thursday, July 9, 2009

Why C language does not have the exponentiation operator ?

While C is often considered as a powerful language, why such a powerful language does not have an operator for exponentiation?





In a simple language like BASIC, we have ^ or ** for exponentiation. Why nothing like that in C as well as C++ too ?

Why C language does not have the exponentiation operator ?
because ^ is xor in c/c++ and ** is pointer on pointer


and you have function which provides you the same functionality - pow (overloaded version in c++) or powx where x is the first letter of the type you want to power in c - look up it in the documentation.





And the power of the language lies somewhere completely else.Function pointers, templates, speed of execution and many many others. Try to learn C++ and you would be amazed what you can do. Like defining your own allocation by overloading new operator and so on. Try to this stuff in BASIC.
Reply:#include %26lt;math.h%26gt;





pow(x, y);


No comments:

Post a Comment