How to tell the user to input 3 numbers in a single statement?

I'm new to C++, I hope everyone can use a simple way to explain this.

How do you tell the user to enter three numbers in one statement?

The question is:

Write a program that asks the user for three floating-point numbers in a single statement. Print the numbers back to the screen with a precision of one decimal point. Use a field width for the output that places the three numbers across the screen as in the example below.

Input: 123.443 33.22 1.9
Output: 123.4 33.4 1.9

Last edited on
How do you tell the user to enter three numbers in one statement?
std::cout << "enter three numbers\n";
Now how to take those numbers. You can do either:
1
2
double a, b, c;
std::cin >> a >> b >> c;

or
1
2
3
4
double a, b, c;
std::cin >> a;
std::cin >> b;
std::cin >> c;
Both code parts do the same thing.
 
cout << setprecision(1) << setiosflags( ios::fixed | ios::showpoint ) << a;

Hope this helps.
Topic archived. No new replies allowed.