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 a 15 position field on the same line, in such away that scientific (or e-notation or exponential notation) is avoided. Each number should be printed with 5 digits to the right of the decimal point. For example, if their values were 24.014268319, 14309, 0.00937608, the output would be:|xxxxxxx24.01427xxxx14309.00000xxxxxxxx0.00938 NOTE: 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!

LANGUAGE: C++

CHALLENGE:

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 a 15 position field on the same line, in such away that scientific (or e-notation or exponential notation) is avoided. Each number should be printed with 5 digits to the right of the decimal point. For example, if their values were 24.014268319, 14309, 0.00937608, the output would be:|xxxxxxx24.01427xxxx14309.00000xxxxxxxx0.00938 NOTE: 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!

SOLUTION:

cout << fixed << setprecision(5) << setw(15) << a << setw(15) << b << setw(15) << c;