setprecision and setw - 1st Example

/*This program will demonstrate how to  
display significant digits using setprecision 
and field widths with setw*/

#include <iostream.h> //cin and cout
#include <iomanip.h> // setw , setprecision, unsetf

main()
{
	int x = 342;
	float p = 3.141562;
	cout.setf(ios::showpoint);//activating decimal display
 	
	cout <<setw(4) << "##" << setw(6) << "mmm" << '\n';
	cout << setprecision(4) << p << "XYZ" << setprecision(5) << p << '\n';
	cout <<setw(2) << "****" << "ABC" << setprecision(1) << x << '\n';
	cout << setw(7) << setprecision(6) << p << '\n'; 

	cout.unsetf(ios::showpoint); //deactivating decimal display.	
	
	return 0;
}
/*
  ##   mmm
3.142XYZ3.1416
****ABC342
3.14156
*/