How to write power of e in c++? Like e^3, does computer know e?
Can I write it as pow(e,3) ?

Thanks a lot.

How to write power of e in c++? Like e^3, does computer know e?
Can I write it as pow(e,3) ?

What do you think? Try it.

What do you think? Try it.

error: `e' undeclared (first use this function)

Can you tell me how to write it? I tried it, but it is wrong.

Are you just starting C now?

>error: `e' undeclared (first use this function)

This means that the compiler's never seen the variable e before. You have to declare it first, and initalize it for it to be any good.

Can you tell me how to write it? I tried it, but it is wrong. The line you wrote previously was correct. But you have to declare a variable first: int e = 0; In the above example, I created 'e' and initalized it with 0. Thus, pow(e, 3) will result in a 0.

I think you're looking for something like this:

#include <iostream>
#include <cmath>

int main()
{
  std::cout << M_E << std::endl;
  std::cout << std::pow(M_E, 3) << std::endl;
  return 0;
}

Oh sorry, I'm a little bit ignorant of the mathematical constant e . I completely thought he/she was referring to a variable. My apologies :)