Ask coding questions

← Back to all posts
Trouble with input
RobertFurr (55)

So I wanted to code a program that would do scientific notation and when I got to the a*10^b the endl could not be identified. Could someone tell me why?

mwilki7 (1104)

Sadly ^ symbol is used for bitwise exclusive or logic instead of exponent.

If you want to use to the power of you'll need to replace it with pow. Here is an example:
a ^ b to pow(a, b)

In your case, it's
a*10^b to a * pow(10, b)

SPQR (535)

@mwilki7 It should be mentioned that you need to #include <cmath> in order to use pow