You are here:

- Home
- Computing/Technology
- C/C++
- C++
- C++ exponents

Advertisement

How do you write exponents in C++ code? I've been trying to find out but it has me confused.

Hi Dear Melissa!

Writing Exponents in programming languages is different from math notations since the compiler some times would not understand the notations or its will interpret the symbols in its own format.

say if you want to write a simple exponent (x+1)^y in C++ , straight away you should not write the same code , if so the above statement will be interpreted as (x+1) XOR y (which is not the one we require !)

the right form is usage of built in function pow() available in math.h header file , the above statement should be written as

#include <math.h>

....

..

..

pow(x + 1, y);

.

.

.

Note: if you are dealing with some advanced concepts with exponents , please let me know!

Thanks and Regards!

Prince M. Premnath

Years of research in C/C++ Will bring you all facts regarding , OOPS , SVGA , MOUSE , BIOS , IVT , Feel free to query me :-)

More than 5 years**Education/Credentials**

MCA