EBK C++ FOR ENGINEERS AND SCIENTISTS
EBK C++ FOR ENGINEERS AND SCIENTISTS
4th Edition
ISBN: 8220100444968
Author: Bronson
Publisher: YUZU
bartleby

Videos

Question
Book Icon
Chapter 3.2, Problem 6E

(a)

Program Plan Intro

To determine the output of the give code:

(a)

Expert Solution
Check Mark
Program Description Answer

|5|

Explanation of Solution

Given information:

cout<<"|"<<5<<"|";

Program:

#include <iostream>
usingnamespacestd;
intmain()
{
cout<<"|"<<5<<"|";

Explanation:

The output stream, cout, is used along with the insertion operator (<<), to display values on the standard output.

The bar symbol ‘|’ is used to indicate start and end of the display. It acts like a string as this is placed inside the double codes “”.

Sample output: -

  EBK C++ FOR ENGINEERS AND SCIENTISTS, Chapter 3.2, Problem 6E , additional homework tip  1

(b)

Program Plan Intro

To determine and write the display produced by the below statement.

(b)

Expert Solution
Check Mark
Program Description Answer

|5|

Explanation of Solution

Given information:

cout<<"|"<<setw(4)<<5<<"|";

Program:

#include <iostream>
#include <iomanip>
usingnamespacestd;
intmain()
{
cout<<"|"<<setw(4)<<5<<"|";

}

Explanation:

The stream manipulator, setw (4) is used to set the field width to 4 places and theresult is displayed at fourth place using cout output stream. The setw() function is defined in the header file.

The bar symbol, ‘|’ is used to indicate start and end of the display. It acts like a string as this is placed inside the double codes “”.

Sample output: -

  EBK C++ FOR ENGINEERS AND SCIENTISTS, Chapter 3.2, Problem 6E , additional homework tip  2

(c)

Program Plan Intro

To determine and write the display produced by the below statement.

(c)

Expert Solution
Check Mark
Program Description Answer

|56829|

Explanation of Solution

Given information:

cout<<"|"<<setw(4)<<56829<<"|";

Program:

#include <iostream>
#include <iomanip>
usingnamespacestd;
intmain()
{
cout<<"|"<<setw(4)<<56829<<"|";

}

Explanation:

The stream manipulator: setw(4) is used to set the field width to 4 places. Since, the number is of 5 digits, the width will automatically adjust to accommodate 5 digits and the result is displayed using cout output stream.

The bar symbol, ' | ' is used to indicate start and end ofthe display.It acts like a string as this is placed inside the double codes “”.

Sample output: -

  EBK C++ FOR ENGINEERS AND SCIENTISTS, Chapter 3.2, Problem 6E , additional homework tip  3

(d)

Program Plan Intro

To determine and write the display produced by the below statement.

(d)

Expert Solution
Check Mark
Program Description Answer

| 5.26|

Explanation of Solution

Given information:

cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<5.26<<"|";

Program:

#include <iostream>
#include <iomanip>
usingnamespacestd;
intmain()
{
cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<5.26<<"|";

}

Explanation:

The given stream manipulator, setw(5) will set the width to 5 places, as 5 is passed in the parameter. And the given stream manipulator that issetiosflags( ios: : fixed ) , is used for the formatting and the stream manipulator, setprecision (2 ), will set the number to

2 places after the decimal point.

The bar symbol, ' | ' is used to indicate start and end ofthe display.It acts like a string as this is placed inside the double codes “”.

Sample output: -

  EBK C++ FOR ENGINEERS AND SCIENTISTS, Chapter 3.2, Problem 6E , additional homework tip  4

(e)

Program Plan Intro

To determine and write the display produced by the below statement.

cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<5.267<<"|";

(e)

Expert Solution
Check Mark
Program Description Answer

|5.27|

Explanation of Solution

Given information:

cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<5.267<<"|";

Program:

#include <iostream>
#include <iomanip>
usingnamespacestd;
intmain()
{
cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<5.267<<"|";

}

Explanation:

The given stream manipulator, setw(5) will set the width to 5 places, as 5 is passed in the parameter. And the given stream manipulator that issetiosflags( ios: : fixed ) , is used for the formatting and the stream manipulator, setprecision (2 ), will set the number to 2 places after the decimal point. As the precision is set to 2, the number 5.267 will be rounded off (67 to 70) and only two digits will be displayed on the screen.

The bar symbol, ' | ' is used to indicate start and end ofthe display.It acts like a string as this is placed inside the double codes “”.

Sample output: -

  EBK C++ FOR ENGINEERS AND SCIENTISTS, Chapter 3.2, Problem 6E , additional homework tip  5

(f)

Program Plan Intro

To determine and write the display produced by the below statement.

cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<53.264<<"|";

(f)

Expert Solution
Check Mark
Program Description Answer

|53.26|

Explanation of Solution

Given information:

cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<53.264<<"|";

Program:

#include <iostream>
#include <iomanip>
usingnamespacestd;
intmain()
{
cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<53.264<<"|";

}

Explanation:

The given stream manipulator, setw(5) will set the width to 5 places, as 5 is passed in the parameter. And the given stream manipulator that issetiosflags( ios: : fixed ) , is used for the formatting and the stream manipulator, setprecision (2 ), will set the number to

2 places after the decimal point. Since,the number occupies 6 places; the width will automatically adjust to accommodate 7 places.

The bar symbol, ' | 'is used to indicate start and end ofthe display.It acts like a string as this is placed inside the double codes “”.

Sample output: -

  EBK C++ FOR ENGINEERS AND SCIENTISTS, Chapter 3.2, Problem 6E , additional homework tip  6

(g)

Program Plan Intro

To determine and write the display produced by the below statement.

cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<534.264<<"|";

(g)

Expert Solution
Check Mark
Program Description Answer

|534.26|

Explanation of Solution

Given information:

cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<534.264<<"|";

Program:

#include <iostream>
#include <iomanip>
usingnamespacestd;
intmain()
{
cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<534.264<<"|";

}

Explanation:

The given stream manipulator, setw(5) will set the width to 5 places, as 5 is passed in the parameter. And the given stream manipulator that issetiosflags( ios: : fixed ) , is used for the formatting and the stream manipulator, setprecision (2 ), will set the number to

2 places after the decimal point. Since,the number occupies 7 places; the width will automatically adjust to accommodate 7places.

The bar symbol, ' | 'is used to indicate start and end ofthe display.It acts like a string as this is placed inside the double codes “”.

Sample output: -

  EBK C++ FOR ENGINEERS AND SCIENTISTS, Chapter 3.2, Problem 6E , additional homework tip  7

(h)

Program Plan Intro

To determine and write the display produced by the below statement.

cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<534.<<"|";

(h)

Expert Solution
Check Mark
Program Description Answer

|534.00|

Explanation of Solution

Given information:

cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<534.<<"|";

Program:

#include <iostream>
#include <iomanip>
usingnamespacestd;
intmain()
{
cout<<"|"<<setw(5)<<setiosflags(ios::fixed)<<setprecision(2)<<534.<<"|";

}

Explanation:

The given stream manipulator, setw(5) will set the width to 5 places, as 5 is passed in the parameter.And the givenstream manipulator that issetiosflags( ios: : fixed ) , is used for the formatting and the stream manipulator, setprecision (2 ), will set the number to 2 places after the decimal point.

Therefore, two zeroes are added after the decimal pomt to set the precision to 2 places and the width are auto adjusted to accommodate 6 places.

The bar symbol, ' | ' is used to indicate start and end ofthe display.It acts like a string as this is placed inside the double codes “”.

Sample output: -

  EBK C++ FOR ENGINEERS AND SCIENTISTS, Chapter 3.2, Problem 6E , additional homework tip  8

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
For each of the following statements, state whether it is True or False.
Write the negation of each of the following statements (hint: you may have to apply DeMorgan’s Law multiple times) Please show work
State whether the following are true or false. If the answer is false, explain why.d) An expression containing the || operator is true if either or both of its operands is true. .

Chapter 3 Solutions

EBK C++ FOR ENGINEERS AND SCIENTISTS

Ch. 3.1 - (Debug) Determine and correct the errors in the...Ch. 3.1 - Prob. 12ECh. 3.1 - Prob. 13ECh. 3.1 - (General math) The area of an ellipse (see Figure...Ch. 3.1 - Prob. 15ECh. 3.2 - Prob. 1ECh. 3.2 - Prob. 2ECh. 3.2 - (Practice) Write a C++ program that displays the...Ch. 3.2 - Prob. 4ECh. 3.2 - Prob. 5ECh. 3.2 - Prob. 6ECh. 3.2 - Prob. 7ECh. 3.2 - Prob. 8ECh. 3.2 - (Electrical eng.) The combined resistance of three...Ch. 3.2 - Prob. 10ECh. 3.2 - Prob. 11ECh. 3.2 - (Civil eng.) Write a C++ program to calculate and...Ch. 3.3 - Prob. 1ECh. 3.3 - Prob. 2ECh. 3.3 - (Practice) Write C++ statements for the following:...Ch. 3.3 - Prob. 4ECh. 3.3 - (General math) Write, compile, and run a C++...Ch. 3.3 - (General math) If a 20-foot ladder is placed on...Ch. 3.3 - (Physics) The maximum height reached by a ball...Ch. 3.3 - (Transportation) Road construction requires...Ch. 3.3 - Prob. 9ECh. 3.3 - Prob. 10ECh. 3.3 - Prob. 11ECh. 3.3 - Prob. 12ECh. 3.4 - Prob. 1ECh. 3.4 - (Practice) a. Write a C++ program that first...Ch. 3.4 - Prob. 3ECh. 3.4 - Prob. 4ECh. 3.4 - Prob. 5ECh. 3.4 - Prob. 6ECh. 3.4 - (General math) a. Write, compile, and run a C++...Ch. 3.4 - Prob. 8ECh. 3.4 - Prob. 9ECh. 3.4 - (Electrical eng.) For the series circuit shown in...Ch. 3.4 - Prob. 11ECh. 3.4 - Prob. 12ECh. 3.4 - Prob. 13ECh. 3.5 - Prob. 1ECh. 3.5 - Prob. 2ECh. 3.5 - Prob. 3ECh. 3.5 - Prob. 4ECh. 3.5 - Prob. 5ECh. 3.6 - Prob. 1ECh. 3.6 - (General math) The value of p can be approximated...Ch. 3.6 - Prob. 3ECh. 3.6 - (General math) The volume of oil stored in an...Ch. 3.6 - Prob. 5ECh. 3.6 - (General math) The perimeter, approximate surface...Ch. 3.6 - Prob. 7ECh. 3.6 - Prob. 8ECh. 3.6 - Prob. 9ECh. 3 - (General math) a. Write a C++ program to calculate...Ch. 3 - General math) a. Write a C++ program to calculate...Ch. 3 - (General math) Modify the program written for...Ch. 3 - (Biology) The number of bacteria, B, in a culture...Ch. 3 - Prob. 5PPCh. 3 - (Heat transfer) The formula developed in Exercise...Ch. 3 - Prob. 7PPCh. 3 - (Electrical eng.) a. The voltage gain of an...Ch. 3 - (Electrical eng.) a. Write, compile, and run a C++...Ch. 3 - (Electrical eng.) The amplification of electronic...Ch. 3 - (Acoustics) The loudness of a sound is measured in...Ch. 3 - (General math) a. A balance has the following...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Boolean Algebra - Digital Logic and Logic Families - Industrial Electronics; Author: Ekeeda;https://www.youtube.com/watch?v=u7XnJos-_Hs;License: Standard YouTube License, CC-BY
Boolean Algebra 1 – The Laws of Boolean Algebra; Author: Computer Science;https://www.youtube.com/watch?v=EPJf4owqwdA;License: Standard Youtube License