How do you display exponents in C++?

I don't want to do the exponent math per say, I just want to display something like 3x to the second power.

All I have at the moment is:
cout << coefficient << "x" << ?

What do I write to display a 2 as an exponent of X? Must X be a character?
Assume that I have #include <cmath> included too, just in case.

Thanks in advance.

Right now you're printing a number 'coefficient' and a string "x". Since "x" is not a number I see no way to square it. Unless you want a "x^2"..
If you had a number 'x' then you could cout << x*x;
Topic archived. No new replies allowed.