0% found this document useful (0 votes)
1K views

Solution Manual For Starting Out With C Early Objects 9th Edition by Tony Gaddis

This document contains the solutions manual for Chapter 2 of the textbook "Starting out with C++: Early Objects" 9th Edition by Tony Gaddis. It provides the answers to programming problems and questions from the chapter. For each problem, it lists the code or values for the correct solutions. It also provides explanations for incorrect code examples and suggestions for improvements. The summary describes the type of content contained in the document without copying significant text.

Uploaded by

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

Solution Manual For Starting Out With C Early Objects 9th Edition by Tony Gaddis

This document contains the solutions manual for Chapter 2 of the textbook "Starting out with C++: Early Objects" 9th Edition by Tony Gaddis. It provides the answers to programming problems and questions from the chapter. For each problem, it lists the code or values for the correct solutions. It also provides explanations for incorrect code examples and suggestions for improvements. The summary describes the type of content contained in the document without copying significant text.

Uploaded by

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

From https://buytestbank.

eu/Solution-Manual-for-Starting-out-with-C-Early-Objects-9th-Edition-by-Tony-Gaddis

SM Chapter 2

1. semicolon 5. braces {}
2. iostream 6. literals (also sometimes called constants)
3. main 7. 9.7865E14
4. # 8. 1, 2
9. A) valid B) invalid C) valid
10. A) valid B) valid C) invalid
11. A) valid B) invalid C) valid only if Hello is a variable.
12. A) valid B) invalid C) valid
13. A) 11 B) 14 C) 3 (An integer divide takes place.)
14. A) 9 B) 14 C) 2
15. double temp,
weight,
height;
16. int months = 2,
days,
years = 3;
17. A) d2 = d1 + 2;
B) d1 = d2 * 4;
C) c = ‘K’;
D) i = ‘K’;
E) i = i – 1;
18. A) d1 = d2 – 8.5;
B) d2 = d1 / 3.14;
C) c = ‘F’;
D) i = i + 1;
E) d2 = d2 + d1;
19. cout << "Two mandolins like creatures in the\n\n\n";
cout << "dark\n\n\n";
cout << "Creating the agony of ecstasy.\n\n\n";
cout << " - George Barker\n\n\n";
20. cout << "L\n"
<< "E\n"
<< "A\n"
<< "F\n";
This can also be written as a single string literal: cout << "L\nE\nA\nF\n";
21. Input weeks // with prompt
days = weeks * 7
Display days
22. Input eggs // with prompt
cartons = eggs / 12 // perform integer divide
Display cartons
From https://buytestbank.eu/Solution-Manual-for-Starting-out-with-C-Early-Objects-9th-Edition-by-Tony-Gaddis

23. Input speed // with prompt


Input time // with prompt
distance = speed * time
Display distance
24. Input miles // with prompt
Input gallons // with prompt
milesPerGallon = miles / gallons
Display milesPerGallon
25. A) 0 B) 8 C) I am the incrediblecomputing
100 2 machine
and I will
From https://buytestbank.eu/Solution-Manual-for-Starting-out-with-C-Early-Objects-9th-Edition-by-Tony-Gaddis

amaze
you.
26. A) Be careful!
This might/n be a trick question.
B) 23
1
27. On line 1 the comments symbols are backwards. They should be /* */.
On line 2 iostream should be enclosed in angle brackets.
On line 5 there shouldn't be a semicolon after int main().
On lines 6 and 13 the opening and closing braces of function main are reversed.
On line 7 there should be a semicolon after int a, b, c. In addition, the comment
symbol is incorrect. It should be //.
On lines 8-10 each assignment statement should end with a semicolon.
On line 11 cout begins with a capital letter. In addition, the stream insertion operators
should read << instead of >> and the variable that is ouput should be c instead of
capital C.
28. Whatever problem a pair of students decides to work with they must determine such things as
which values will be input vs. which will be set internally in the program, how much
precision is required on calculations, what output will be produced by the program, and how
it should be displayed. Students must also determine how to handle situations that are not
clear cut. In the paint problem many of these considerations are listed in the teacher answer
key (Chapter 1, Question 34). In the recipe program students must determine such things as
how to handle quantities, like one egg, that cannot be halved. In the driving program,
knowing distance and speed are not enough. Agreement should be reached on how to handle
delays due to traffic lights and traffic congestion. Should this be an input value, computed as
a percent of overall driving time, or handled some other way?
From https://buytestbank.eu/Solution-Manual-for-Starting-out-with-C-Early-Objects-9th-Edition-by-Tony-Gaddis

You might also like