100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

C++ for Everyone, Horstmann - Solutions, summaries, and outlines. 2022 updated

Rating
-
Sold
-
Pages
1052
Grade
A+
Uploaded on
15-02-2022
Written in
2021/2022

Description: INCLUDES Some or all of the following - Supports different editions ( newer and older) - Answers to problems & Exercises. in addition to cases - Outlines and summary - Faculty Approved answers. - Covers ALL chapters.

Show more Read less











Whoops! We can’t load your doc right now. Try again or contact support.

Document information

Uploaded on
February 15, 2022
Number of pages
1052
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

CHAPTER 1: SOLUTIONS TO REVIEW EXERCISES


Solution R1.1: Using a computer does not require any advanced know-how or skill. Most
people are capable of turning a computer on and executing a program (such as double
clicking on the icon for Microsoft Word to bring up the word processor to type a letter).
Programming a computer, however, requires very specific knowledge. You must know the
rules of the programming language, and you must know how to construct a program.




Solution R1.2: Both program code and data are typically stored long term in a computer’s
secondary storage, such as a hard disk. Secondary storage is relatively inexpensive and
retains information even if the computer’s power is turned off. In addition to a computer’s
secondary storage, program code and data can also be stored in a computer’s primary
storage. Primary storage consists of read-only memory (ROM), which holds programs that
must always be present (such as the computer’s operating system), and random access
memory (RAM), which can hold changing data and programs that are currently executing.
RAM is relatively expensive when compared to secondary storage, and is erased whenever
the computer is turned off.




Solution R1.3: The user of a computer receives information from the computer’s display
screen, speakers, and printers (the computer’s output devices). The user can input data
using the computer’s keyboard, a pointing device such as a mouse, a microphone, or a
webcam (the computer’s input devices).




Solution R1.4: A simple cell phone that can only be used to make calls would be a single-
function device. If you can download programs (such as media players, web browsers, and
games) to the cell phone and execute them, then it would be considered a programmable
computer, as it can serve multiple purposes.




Solution R1.5: One advantage of C++ over machine code is that C++ statements are
independent of the machine (computer) they are being executed on; machine code

,statements differ from one type of machine to the next. Another advantage of C++ is that it
is much more readable and understandable (by humans) than machine code.




Solution R1.6: The hello.cpp file that I created was found in the following folder on my
computer. The location will vary from machine to machine.



C:\Documents and Settings\Jonathan\My Documents\Visual Studio 2005\
Projects\Hello\Hello



The iostream file was found in the following folder on my computer. The location will vary
from machine to machine.



C:\Program Files\Microsoft Visual Studio 8\VC\include




As you can see, the location of the files on my computer shows that the computer I use has
the Microsoft Visual Studio development environment installed on it.




Solution R1.7: The program prints the following:



6 * 7 = 42




Solution R1.8: The program prints the following:



HelloWorld

,Solution R1.9: The program prints the following:



Hello

World




Solution R1.10: Programs 1 to 3 below each have a different compile-time error (an error
that violates the rules of C++). Program 4 has a run-time error (an error that will allow the
program to execute, but which fails to provide the correct results).



Program 1 (compile-time error – no end quote on string):



#include <iostream>

using namespace std;



int main()

{

cout << "Hello, World! << endl;

return 0;

}



Program 2 (compile-time error – no semicolon on the cout statement):



#include <iostream>

using namespace std;

, int main()

{

cout << "Hello, World!" << endl

return 0;

}



Program 3 (compile-time error – no parentheses for main function):



#include <iostream>

using namespace std;



int main

{

cout << "Hello, World!" << endl;

return 0;

}



Program 4 (run-time error – “World” is misspelled):



#include <iostream>

using namespace std;



int main

{

cout << "Hello, Wolrd!" << endl;

return 0;

}

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
TestBanks2022 Harvard University
View profile
Follow You need to be logged in order to follow users or courses
Sold
2129
Member since
3 year
Number of followers
1700
Documents
2246
Last sold
1 day ago

4.0

344 reviews

5
183
4
59
3
46
2
18
1
38

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions