I tried to complete this task with the goal of solving a quadratic equation. Writing ax² inside a cout << , holding ALT as you type 253, displayed correctly only in the source code, BUT NOT on the console. When the program started, it looked like a bright rectangle instead of superscript 2.
A simple solution to this problem seems to distinguish the integer 253 as a char, like this ... (char)253 .
Since our professor does not recommend the use of "magic numbers", I declared it as a constant variable ... const int superScriptTwo = 253; //ascii value of super script two const int superScriptTwo = 253; //ascii value of super script two .
Then, when I wanted superscript 2 to be displayed in the console, I passed my variable as char , like this ... cout << "f(x) = ax" << (char)superScriptTwo << " + bx + c"; and it displays perfectly.
Perhaps it is even easier to just create it as a char to start with, and not worry about casting it. This code will also print super script 2 on the console when compiling and running in VS2013 on my Lenovo running Windows 7 ...
char ssTwo = 253; cout << ssTwo << endl;
I hope someone finds this helpful. This is my first post ever, so I apologize in advance if I accidentally violated the protocols to answer a question posted 5 years ago. Any such occurrence was not intentional.
Gary treadwell
source share