164k views
3 votes
Write a cout statement so the variable sales is displayed with a precision of three decimal places, with the decimal point always displayed.

User Eliana
by
3.6k points

1 Answer

3 votes

Answer:

The statement is as follows:

cout <<fixed<< setprecision(3) <<sales;

Step-by-step explanation:

Here, I assume that the variable has already been declared.

The syntax to use is:

cout<<fixed<<setprecision(n)<<variable-name;

In this case:


n = 3 --- i.e. to 3 decimal places

And the variable name is: sales

So, when implemented, the instruction is:

cout <<fixed<< setprecision(3) <<sales;

User Rogier Lommers
by
3.9k points