61.4k views
1 vote
What is the output of the following program fragment? (alpha and beta are int variables and △ is a blank.) alpha = 2463; beta = 72; cout << "123456789" << endl << setw(5) << alpha << endl << setw(5) << beta << endl; A) 123456789 24630 72000 B) 123456789 △2463 72 C) 123456789 △2463 △△△ 72 D) 123456789 △2463 △△72 E) none of the above

User Magol
by
5.3k points

2 Answers

4 votes

Answer:

C. option is the answer.

Step-by-step explanation:

First line print is straightforward. Second line introduces one blank (because of setw()) before alpha value output. Third line puts 3 blanks before beta value output.

123456789

△2463

△△△72

setw() function sets field width. It is part of the iomanip library. Default justification is left, i.e. spaces or blanks start from the left.

setw() can be inserted or extracted on input streams or output streams.

User Ruslan Ostafiichuk
by
5.2k points
6 votes

Answer:

Correct option is C if each output includes a new line which not shown in option I think that is typing mistake and output will be like this

123456789

2463

72

Step-by-step explanation:

C is correct option because it generate output like option C because the function setw sets width of output to 5 character so in alpha total characters are 4 so it print 4 characters after a blank space character and in beta total characters are 2 so it prints those 2 characters after printing three blank spaces;

123456789

2463

72

User Monicuta
by
5.7k points