How to use showpoint and noshowpoint (decimal point) format flags in C++

1 Answer

0 votes
#include <iostream>
#include <iomanip> 

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

int main()
{
	double a = 20;
	double b = 100.0;
	double pi = 3.1416;

	std::cout.precision(5);

	std::cout << std::showpoint << a << "  :  " << b << "  :  " << pi << endl;
	std::cout << std::noshowpoint << a << "  :  " << b << "  :  " << pi << endl;

	return 0;
}


/*
run:

20.000  :  100.00  :  3.1416
20  :  100  :  3.1416

*/

 



answered Apr 7, 2018 by avibootz
...