COSC 1315

Programming Fundamentals

 Practice Text #106

Formatted Output

Revised: February 3, 2007
By Richard G. Baldwin

File Pfsg00106.htm
Practice Text Index


Welcome

The practice tests in this series were written specifically for the benefit of my students in COSC 1315, Fundamentals of Programming.  They consists of questions, answers, and explanations.  The questions are based on the material covered in my series of online lecture notes for the course.  Each practice test is keyed to a specific lecture.  This practice test is keyed to lecture #106 titled Formatted Output.

Questions



106-1.  The file named iomanip must be included in order to support which of the following capabilities:

Answer and Explanation

106-2.  True or False.  C++ manipulators make it possible to manipulate the format of data in a variety of ways.

Answer and Explanation

106-3.  True or False.  Manipulators are not only used in C++, they are also used in Java and C#.

Answer and Explanation

106-4.  True or False.  The contents of the include file named iomanip are required in order to use  the following manipulators:

Answer and Explanation

106-5.  True or False.  The statement in Listing 106-5 uses manipulators to prepare the system to:

Listing 106-5.
cout << setprecision(2) << fixed << showpoint;

Answer and Explanation

106-6.  True or False.  The code in Listing 106-6 prints:

Listing 106-6.
cout << setprecision(2) << fixed << showpoint;
cout << "10 divided by 3 is: " << 10.0/3.0;

Answer and Explanation

106-7.  True or False.  The code in Listing 106-7 prints:

10 divided by 3 is: 3.333

Listing 106-7.
cout << setprecision(2) << fixed << showpoint;
cout << "10 divided by 3 is: " << 10.0/3.0;

Answer and Explanation

106-8.  True or False.  The code in Listing 106-8 produces the screen output shown below where I manually replaced space characters with '-' characters so that you can see them and count them.

-------1.5-------2.200

Listing 106-8.
cout 
  << setw(10) << setprecision(1) << fixed << 1.5;
cout 
  << setw(12) << setprecision(3) << fixed << 2.2
                                         << endl;

Answer and Explanation

106-9.  True or False.  The code in Listing 106-9 produces the screen output shown below where I manually replaced space characters with '-' characters so that you can see them and count them.

------12.8-----3.14159

Listing 106-9.
cout 
  << setw(10) 
    << setprecision(1) << fixed << 12.78;
cout 
  << setw(12) 
      << setprecision(3) << fixed << 3.14159
                                        << endl;

Answer and Explanation

106-10.  True or False.  All of the capabilities supported by the include file named iomanip are shown in the following list.

Answer and Explanation



Copyright 2007, Richard G. Baldwin.  Reproduction in whole or in part in any form or medium without express written permission from Richard Baldwin is prohibited.

About the author

Richard Baldwin is a college professor (at Austin Community College in Austin, TX) and private consultant whose primary focus is a combination of Java and XML. In addition to the many platform-independent benefits of Java applications, he believes that a combination of Java and XML will become the primary driving force in the delivery of structured information on the Web.

Richard has participated in numerous consulting projects involving Java, XML, or a combination of the two.  He frequently provides onsite Java and/or XML training at the high-tech companies located in and around Austin, Texas.  He is the author of Baldwin's Java Programming Tutorials, which has gained a worldwide following among experienced and aspiring Java programmers. He has also published articles on Java Programming in Java Pro magazine.

Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.

Baldwin@DickBaldwin.com


Answers and Explanations

Answer 10

False

Back to Question 10

Explanation 10

Answer 9

False

Back to Question 9

Explanation 9

Too many digits to the right of the decimal point in the value in the second column.

Answer 8

True

Back to Question 8

Explanation 8

Answer 7

False

Back to Question 7

Explanation 7

Too many digits to the right of the decimal pointl.

Answer 6

True

Back to Question 6

Explanation 6

Answer 5

False

Back to Question 5

Explanation 5

Should be two digits to the right of the decimal point.

Answer 4

True

Back to Question 4

Explanation 4

Answer 3

False

Back to Question 3

Explanation 3

Answer 2

True

Back to Question 2

Explanation 2 

Answer 1

B.  Certain types of input/output formatting.

Back to Question 1

Explanation 1



Copyright 2007, Richard G. Baldwin.  Reproduction in whole or in part in any form or medium without express written permission from Richard Baldwin is prohibited.

About the author

Richard Baldwin is a college professor (at Austin Community College in Austin, TX) and private consultant whose primary focus is a combination of Java and XML. In addition to the many platform-independent benefits of Java applications, he believes that a combination of Java and XML will become the primary driving force in the delivery of structured information on the Web.

Richard has participated in numerous consulting projects involving Java, XML, or a combination of the two.  He frequently provides onsite Java and/or XML training at the high-tech companies located in and around Austin, Texas.  He is the author of Baldwin's Java Programming Tutorials, which has gained a worldwide following among experienced and aspiring Java programmers. He has also published articles on Java Programming in Java Pro magazine.

Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.

Baldwin@DickBaldwin.com

-end-