cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
How do you display exponents in C++?
How do you display exponents in C++?
Feb 15, 2011 at 9:11pm UTC
rekson
(7)
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.
Feb 15, 2011 at 9:17pm UTC
hamsterman
(4538)
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.