How to set showpos format flag to show the a plus sign (+) for double number in C++

1 Answer

0 votes
#include <iostream>

using std::cout;
using std::endl;

int main()
{
	double f = 3.14;

	cout.setf(std::ios::showpos);
	cout << f << endl;

	return 0;
}

/*
run:

+3.14

*/

 



answered May 21, 2018 by avibootz

Related questions

1 answer 205 views
1 answer 224 views
1 answer 158 views
158 views asked Apr 8, 2018 by avibootz
1 answer 171 views
1 answer 223 views
...