Cpp - Write program to Output number -123.456 as an exponential and with four decimal spaces.

Requirements

Write program to Output number -123.456 as an exponential and with four decimal spaces.

Demo

#include <iostream> 
#include <iomanip>     // For setw() and setprecision() 
using namespace std; 
int main() /*from  w w  w.  ja  va  2 s.  c  om*/
{ 
    double x3 = -123.456; 
    cout << scientific << setprecision(4) << x3 << endl; 

    return 0; 
}

Result

Related Exercise