Write a program to test the results of printing the integer value 12345 and the floating-point value 1.2345 in various-sized fields. What happens when the values are printed in fields containing fewer digits than the values?
What will be an ideal response?
```
#include
#include
using namespace std;
int main()
{
// values used for testing output in various field lengths
int x = 12345;
double y = 1.2345;
// display values in fields the size of loop counter
for ( int loop = 0; loop <= 10; loop++ )
cout << x << " printed in a field of size " << setw( 2 )
<< loop << " is " << setw( loop ) << x << '\n' << y
<< " printed in a field of size " << setw( 2 )
<< loop << " is " << setw( loop ) << y << '\n';
} // end main
```
12345 printed in a field of size 0 is 12345
1.2345 printed in a field of size 0 is 1.2345
12345 printed in a field of size 1 is 12345
1.2345 printed in a field of size 1 is 1.2345
12345 printed in a field of size 2 is 12345
1.2345 printed in a field of size 2 is 1.2345
12345 printed in a field of size 3 is 12345
1.2345 printed in a field of size 3 is 1.2345
12345 printed in a field of size 4 is 12345
1.2345 printed in a field of size 4 is 1.2345
12345 printed in a field of size 5 is 12345
1.2345 printed in a field of size 5 is 1.2345
12345 printed in a field of size 6 is 12345
1.2345 printed in a field of size 6 is 1.2345
12345 printed in a field of size 7 is 12345
1.2345 printed in a field of size 7 is 1.2345
12345 printed in a field of size 8 is 12345
1.2345 printed in a field of size 8 is 1.2345
12345 printed in a field of size 9 is 12345
1.2345 printed in a field of size 9 is 1.2345
12345 printed in a field of size 10 is 12345
1.2345 printed in a field of size 10 is 1.2345
You might also like to view...
Any attempt to manipulate information in pursuit of a military or political goal is ________
a. Cyberterrorism b. Economic terrorism c. Information warfare d. None of the above
Telecommunications network providers and users are concerned about the single point of failure in "the last mile," which is the single cable from the network provider's last switching station to the customer's premises. How can a customer protect against that single point of failure? Comment on whether your approach presents a good cost-benefit trade-off
What will be an ideal response?
You use the ______ operator to perform wildcard searches of valid search string values.
A) MATCH B) LIKE C) BETWEEN D) STRING
?The _____ element is used to contain an image file and can also be used to mark any page content that should standapart from the main content of an article.
A. ?border B. ?article C. ?image D. ?figure