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() /* w w  w . ja va 2 s  . c o  m*/
{ 
    double x1 = 0.123456; 
    cout << left << setw(15) << x1 << endl; 
    return 0; 
}

Result

Related Exercise