We know that ‘-‘ i.e. minus is always displayed for numbers but how about ‘+’ sign. Is there a way to show this sign using output streams in c++? The answer is yes! Use “showpos” function and use “noshowpos” to disable this functionality…
int main()
{
cout << showpos << 10 << " " << -100 << endl;
cout << noshowpos << 10 << " " << -100 << endl;
return 0;
}
// Output
+10 -100
10 -100
[/sourcecode]