don't store the number as a number, use a string or a character array (same thing) and use the subscript operator to output it

string thingey = "23";
cout << thingey[1] << thingey[0];