Hi All,
Is there is any format specifier, which can be used to print the sign of the number?
For example,
If I enter 10, it should print as +10.
If I enter -2, it should print as -2.
With Thanks and Regards,
A.Ilamparithi
Printable View
Hi All,
Is there is any format specifier, which can be used to print the sign of the number?
For example,
If I enter 10, it should print as +10.
If I enter -2, it should print as -2.
With Thanks and Regards,
A.Ilamparithi
With printf, there is one.
Try this one:
:)Code:printf("the integer is : %+i",10);
With iostream:
There is a flag showpos in the format flags of ios, set by the manipulator std::showpos, and removed by the manipulator std::noshowpos.Code:std::cout << std::showpos << 42 << std::noshowpos;