214k views
0 votes
Given three variables, a, b, c, of type double that have already been declared and initialized, write some code that prints each of them in scientific (also known as e-notation or exponential notation) in a 10 position field on the same line. Each number should be printed with 3 digits to the right of the decimal point. For example, if their values were 987654321, 1234, 0.00987654321, the output would be:

|x9.877e+08x1.234e+03x9.877e-03NOTE: The vertical bar, |, on the left above represents the left edge of the print area; it is not to be printed out. Also, we show x in the output above to represent spaces-- your output should not actually have x's!

User Jsv
by
5.5k points

1 Answer

5 votes

Answer:

The following code from the C++ programming Language:

cout << setw(10) << setprecision(3) << scientific;

cout << a << " " << b << " " << c;

Explanation:

In the above code, we have three double type variable "a", "b", "c" which already have been declared and initialized.

E-notation is how we write any number that is too small and too large to be in briefly written in decimal format.

User Ova
by
5.3k points