0% found this document useful (0 votes)
160 views1 page

Exercise 1: of Floating-Point Numbers" in This Chapter?

This document contains 5 exercises related to C++ programming. The exercises involve: 1) Identifying the output of a program formatting floating-point numbers 2) Writing statements to format numeric output with specified justification and precision 3) Writing a program to read and output article data 4) Writing a program to read a character code and display the character and code in various formats 5) Identifying why a character is output when a number is entered and correcting mistakes in a program

Uploaded by

MariaNedelcu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
160 views1 page

Exercise 1: of Floating-Point Numbers" in This Chapter?

This document contains 5 exercises related to C++ programming. The exercises involve: 1) Identifying the output of a program formatting floating-point numbers 2) Writing statements to format numeric output with specified justification and precision 3) Writing a program to read and output article data 4) Writing a program to read a character code and display the character and code in various formats 5) Identifying why a character is output when a number is entered and correcting mistakes in a program

Uploaded by

MariaNedelcu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

EXERCISES ■ 77

Exercise 1
What output is generated by the program on the page entitled “Formatted output
of floating-point numbers” in this chapter?

Exercise 2
Formulate statements to perform the following:

a. Left-justify the number 0.123456 in an output field with a width of 15.


b. Output the number 23.987 as a fixed point number rounded to two dec-
imal places, right-justifying the output in a field with a width of 12.
c. Output the number –123.456 as an exponential and with four decimal
spaces. How useful is a field width of 10?

Exercise 3
Write a C++ program that reads an article number, a quantity, and a unit price
from the keyboard and outputs the data on screen as displayed on the opposite
page.

Exercise 4
Write a C++ program that reads any given character code (a positive integer)
from the keyboard and displays the corresponding character and the character
code as a decimal, an octal, and a hexadecimal on screen.

✓ TIP

The variable type defines whether a character or a number is to be read or output.

Why do you think the character P is output when the number 336 is entered?
Exercise 5
Correct the mistakes in the program on the opposite page.

You might also like