Cpp - Write program to left-justify the number 0.123456 in an output field with a width of 15

Requirements

Write program to left-justify the number 0.123456 in an output field with a width of 15

Demo

#include <iostream> 
#include <iomanip>     // For setw() and setprecision() 
using namespace std; 
int main() /*from  w w w.  j a  v a2 s . co m*/
{ 
    double x1 = 0.123456; 
    cout << left << setw(15) << x1 << endl; 
    return 0; 
}

Result

Related Exercise