You are here:

C++/C++ exponents

Advertisement


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

Answer
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

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise

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

Experience

More than 5 years

Education/Credentials
MCA

©2016 About.com. All rights reserved.