79 79 79 79 79 79 79
ograms 3rd Edition by Kenneth Lambert
79 79 79 79 79
Solution and Answer Guide For All Chapters 1-
79 79 79 79 79 79 79
13| A+ PASS GUARANTEED
79 79 79
Page79|79
1
, CHAPTER791,7 9 INTRODUCTION79TA
BLE79OF79CONTENTS
Exercise79Solutions 1
Exercise791.1 1
Exercise791.2 2
Exercise791.3 3
Review79Questions79Answers 4
Programming79Exercises79Solutions 8
Debugging79Exercises79Solutions7 9 8
EXERCISE79SOLUTIONS79EXERCI
SE791.1
1. List79three79common79types79of79computing79agents.
Solution:
Human79beings,79desktop79computers,79cell79phones
2. Write79an79algorithm79that79describes79the79second79part79of79the79process79of79making79change79(cou
nting79out79the79coins79and79bills).
Solution:
There79are79various79ways79to79do79this,79but79here79is79one:
Repeat
Select79the79largest79unit79of79money79that79is79less79than79or79equal79to79the79remaining79change79Subtract79
this79unit79from79the79remaining79change
Until79the79remaining79change79is790
The79collection79of79units79selected79represent79the79change
Page79|79
2
,3. Write79an79algorithm79that79describes79a79common79task,79such79as79baking79a79cake.
Solution:
There79are79various79ways79to79do79this,79but79here79is79one:
Preheat79an79oven79to7937579degrees
Add79179cup79of79water79and79179egg79to79a79mixing79bowl
Beat79the79liquid79mixture79in79the79bowl79until79the79ingredients79are79blended79Add79the79contents79of79a79
boxed79cake79mix79to79the79mixing79bowl
Beat79the79mixture79in79the79bowl79until79the79ingredients79are79blended
Pour79the79contents79of79the79mixing79bowl79into79a79lightly79greased79cake79pan79Bake79the79cake79in79the79
oven79for794579minutes
4. Describe79an79instruction79that79is79not79well79defined79and79thus79could79not79be79included79as79a79step79
in79an79algorithm.79Give79an79example79of79such79an79instruction.
Solution:
Attempting79to79divide79a79number79by790
5. In79what79sense79is79a79laptop79computer79a79general-purpose79problem-solving79machine?
Solution:
A79laptop79computer79is79a79general-purpose79problem-
solving79machine79because79it79is79programmable79and79can79solve79any79problem79for79which79there79is79a
n79algorithm.
6. List79four79devices79that79use79computers79and79describe79the79information79that79they79process.79(Hint:7
9Think79of79the79inputs79and79outputs79of79the79devices.)
Solution:
Digital79camera—images,79music79player—sound,79cell79phone—text,79ATM—numbers
Page79|79
3
, Page79|79
4