Thursday, 5 January 2017

When a value is smaller than a field specified with setw(),the unused locations are, by default, filled in with spaces. The manipulator setfill() takes a single character as an argument and causes this character to be substituted for spaces in the empty parts of a field. Rewrite the WIDTH program so that the characters on each line between the location name and the population number are filled in with periods instead of spaces, as in Port City.....2425785

Leave a Comment

Question:

When a value is smaller than a field specified with setw(),the unused locations are, by default, filled in with spaces. The manipulator setfill() takes a single character as an argument and causes this character to be substituted for spaces in the empty parts of a field. Rewrite the WIDTH program so that the characters on each line between the location name and the population number are filled in with periods instead of spaces, as in Port City.....2425785

Explanation:
Below mention code is compiled in Visual Studio 2015 and Code Blocks 13.12,output snap is attached.. If any problem you feel and you want some explanation feel free to contact us.

Code:

/**************************************************|
/*************C++ Programs And Projects************|
***************************************************/
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
       cout << "Port City" << setfill('.') << setw(10) << "2425785" << endl;

}

Output:
When a value is smaller than a field specified with setw(),the unused locations are, by default, filled in with spaces. The manipulator setfill() takes a single character as an argument and causes this character to be substituted for spaces in the empty parts of a field. Rewrite the WIDTH program so that the characters on each line between the location name and the population number are filled in with periods instead of spaces, as in Port City.....2425785



Related Articles:



If You Enjoyed This, Take 5 Seconds To Share It