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 www  .j a  va2s  .  c  om*/
{ 
    double x3 = -123.456; 
    cout << scientific << setprecision(4) << x3 << endl; 

    return 0; 
}

Result

Related Exercise