What statements should you include in your program to ensure that, when a number of type double is output, it will be output in ordinary notation with three digits after the decimal point?
PROGRAM CODE:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double number = 123.456789; // Replace this with your double value
//Prompt input statement
cout<<"Given number"<<number<<endl;
// Set the precision to three digits after the decimal point
cout <<fixed <<setprecision(3);
// Output the number in ordinary notation with three digits after the decimal point
cout <<"The ordinary notation with three digits after the decimal point: " <<number <<endl;
return 0;
}
OUTPUT:
Given number123.456789
The ordinary notation with three digits after the decimal point: 123.457