1

Is it possible to print subscripts/superscripts ? for example like that : x² what are functions allow to do that ?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
hacen
  • 31
  • 2
  • 3

3 Answers3

3

This depends entirely on the environment you're running in. For a GUI system (Windows, Mac, Qt, etc.) you would need to consult the API documentation. For a text mode system, the best you could do is use specific characters in your current encoding. For instance, unicode has certain code points that are super- or sub-scripts of other characters.

Cogwheel
  • 22,781
  • 4
  • 49
  • 67
1

If you're using a GUI, you can change the size and orientation of the font.

There are also superscript and subscript characters available in Unicode that could be used.

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622
1

You can print the appropriate Unicode symbol, to cout or wcout depending on locale:

#include <iostream>
int main()
{
        std::cout << "x\u00b2" << std::endl;
}

or

#include <iostream>
#include <locale>
int main()
{
        std::locale::global(std::locale("de_DE.UTF8"));
        std::wcout << L"x\u00b2" << std::endl;
}
Cubbi
  • 46,567
  • 13
  • 103
  • 169