135k views
5 votes
Write a statement that reads 5 successive integers into these variables that have already been declared : x1 x2x3x4 x5. Then write a statement that prints each out on its own line so that they form a right-justified column with a 5-digit width. If any of the integers are 5-digits in size, then they will start at the very beginning of their lines. For example:|54213| 8713| 23| 147| 15cin >> x1 >> x2 >> x3 >> x4 >> x5;cout << setw(5) << right << x1 << "\\";cout << setw(5) << right << x2 << "\\";cout << setw(5) << right << x3 << "\\";cout << setw(5) << right << x4 << "\\";cout << setw(5) << right << x5 << "\\";

1 Answer

1 vote

Answer:

The statement to this question can be given as:

Statement:

cin >> x1 >> x2 >> x3 >> x4 >> x5;

cout<<right;

cout << setw(5) << x1 << "\\" << setw(5) << x2 << "\\" << setw(5) << x3 << "\\" << setw(5) << x4 << "\\" << setw(5) << x5 << "\\";

Explanation:

In the question, it is given that there is 5 integer variable that is x1, x2, x3, x4, and x5. In the above statement, we print the value of the integer variable and the right-justified column with a 5-digit width. In this statement first, we insert the value of the variables then we print the value in 5-digit width within its own line.

User Rojo
by
7.4k points