cant allign using setw manipulator | Sololearn: Learn to code for FREE!


cant allign using setw manipulator

The output is not properly alligned. The user enter the names and votes. Program outputs name votes recieved and percent of votes recieved by each candidate. I want to allign the outpot in a straight line but i cant. Sample input: Johnson 5000 Miller 4000 Duffy 6000 Robinson 2500 Ashtony 1800 Code:

12/15/2020 9:55:57 AM

Muhammad Abdullah

3 Answers

New Answer


The biggest problem with aligning text is that each character differs in width. Perfect alignment is only possible where a monospace font is used to print outputs. To prove this, use 'AAA' as names for all of the candidates. The output will be well aligned when the 'name' field consists of characters having similar width.


Ipang that is problem the pro bn lem i want to solve. Keep same names and still align


I know, I wish you luck buddy 👍