// This program illustrates how the showpoint, setprecision, and fixed manipulators operate both individually and when used together.

#include <iostream>
#include <iomanip> // Header file needed to use stream manipulators

using namespace std;

int main() {

    double x = 6.0; // Declare x as double

    cout << x << endl; // Print x with a new line
    // This format does not include decimals when the decimal is 0

    cout << showpoint << x << endl; // Force x to print with decimal point
    // Showpoint defaults to 8 digits

    cout << setprecision(2) << x << endl; // Set precision to two digits

    cout << fixed << x << endl; // Add fixed to command stream
    // Always use decimal notation, never scientific notation
    // Fixed in combination with setprecision forces setprecision to apply after the decimal point

    // The above settings are preserved until changed

    double pi = 3.14159; // Declare pi as double
    
    cout << pi << endl; // Print pi
    // This will use setprecision(2) and fixed

    cout << fixed << setprecision(4); // Set manipulators
    // Change precision to 4 after decimal

    cout << pi << endl;

    return 0;

}