// Default argument example

#include <iostream>
#include <iomanip>
using namespace std;

// Use default argument = -1 to specify default precision
void printDouble(double value, int decPlaces = -1);

int main()
{
    printDouble(0);
    printDouble(1);
    printDouble(1.5);
    printDouble(1.5,4);
    printDouble(123456.789);
    printDouble(123456.789,2);
    printDouble(123456.789,5);
    printDouble(3.141592654,5);
    return 0;
}

void printDouble(double value, int decPlaces)
{
    if (decPlaces < 0) {
        cout << value << endl;
    }
    else {
        cout << setprecision(decPlaces) << fixed << value << endl;
    }
}


*****  OUTPUT  *****

0
1
1.5
1.5000
123456.7890
123456.79
123456.78900
3.14159