0% found this document useful (0 votes)
12 views

An Introduction to Programming with C 8th Edition Diane Zak download

The document provides links to various programming and technical ebooks, including 'An Introduction to Programming with C' by Diane Zak and other titles. It emphasizes the availability of instant digital downloads in multiple formats. Additionally, it contains copyright information and a brief overview of the contents of the programming textbooks.

Uploaded by

dyceeanerry
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)
12 views

An Introduction to Programming with C 8th Edition Diane Zak download

The document provides links to various programming and technical ebooks, including 'An Introduction to Programming with C' by Diane Zak and other titles. It emphasizes the availability of instant digital downloads in multiple formats. Additionally, it contains copyright information and a brief overview of the contents of the programming textbooks.

Uploaded by

dyceeanerry
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/ 57

An Introduction to Programming with C 8th

Edition Diane Zak pdf download

https://ebookname.com/product/an-introduction-to-programming-
with-c-8th-edition-diane-zak/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Clearly Visual Basic Programming with Microsoft Visual


Basic 2012 3rd Edition Diane Zak

https://ebookname.com/product/clearly-visual-basic-programming-
with-microsoft-visual-basic-2012-3rd-edition-diane-zak/

CGI Perl Web Warrior Series 1st Edition Diane Zak

https://ebookname.com/product/cgi-perl-web-warrior-series-1st-
edition-diane-zak/

Microsoft Visual C 2010 An Introduction to Object


Oriented Programming 4th Edition Joyce Farrell

https://ebookname.com/product/microsoft-visual-c-2010-an-
introduction-to-object-oriented-programming-4th-edition-joyce-
farrell/

The Protection of Archaeological Heritage in Times of


Economic Crisis 1st Edition Elena Korka (Ed.)

https://ebookname.com/product/the-protection-of-archaeological-
heritage-in-times-of-economic-crisis-1st-edition-elena-korka-ed/
Policy Concertation and Social Partnership in Western
Europe Lessons for the Twenty First Century 1st Edition
Stefan Berger

https://ebookname.com/product/policy-concertation-and-social-
partnership-in-western-europe-lessons-for-the-twenty-first-
century-1st-edition-stefan-berger/

Lectures on Quantum Groups 2nd Edition Pavel Etingof

https://ebookname.com/product/lectures-on-quantum-groups-2nd-
edition-pavel-etingof/

Functional Food Ingredients and Nutraceuticals


Processing Technologies 1st Edition John Shi

https://ebookname.com/product/functional-food-ingredients-and-
nutraceuticals-processing-technologies-1st-edition-john-shi/

The I L Peretz Reader Peretz

https://ebookname.com/product/the-i-l-peretz-reader-peretz/

The Most Controversial Decision Truman the Atomic Bombs


and the Defeat of Japan 1st Edition Wilson D. Miscamble
C.S.C.

https://ebookname.com/product/the-most-controversial-decision-
truman-the-atomic-bombs-and-the-defeat-of-japan-1st-edition-
wilson-d-miscamble-c-s-c/
Gale Encyclopedia of Science 3rd Edition K. Lee Lerner
And Brenda Wilmoth Lerner

https://ebookname.com/product/gale-encyclopedia-of-science-3rd-
edition-k-lee-lerner-and-brenda-wilmoth-lerner/
An Introduction to
Programming with C++

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Eighth Edition

An Introduction to
Programming with C++

Diane Zak

Australia • Brazil • Mexico • Singapore • United Kingdom • United States

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
This is an electronic version of the print textbook. Due to electronic rights restrictions,
some third party content may be suppressed. Editorial review has deemed that any suppressed
content does not materially affect the overall learning experience. The publisher reserves the right
to remove content from this title at any time if subsequent rights restrictions require it. For
valuable information on pricing, previous editions, changes to current editions, and alternate
formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for
materials in your areas of interest.

Important Notice: Media content referenced within the product description or the product
text may not be available in the eBook version.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
An Introduction to Programming with C++, © 2016 Cengage Learning
Eighth Edition
WCN: 02-200-203
Diane Zak
Product Director: Kathleen McMahon ALL RIGHTS RESERVED. No part of this work covered by the copyright
herein may be reproduced, transmitted, stored or used in any form or by
Product Team Manager: Kristin McNary any means graphic, electronic, or mechanical, including but not limited to
Senior Product Manager: Jim Gish photocopying, recording, scanning, digitizing, taping, Web distribution,
Senior Content Developer: Alyssa Pratt information networks, or information storage and retrieval systems, except
as permitted under Section 107 or 108 of the 1976 United States Copyright
Product Assistant: Abigail Pufpaff
Act, without the prior written permission of the publisher.
Marketing Manager: Eric LaScola
Senior Production Director:
For product information and technology assistance, contact us at
Wendy Troeger Cengage Learning Customer & Sales Support, 1-800-354-9706
Production Director: Patty Stephan For permission to use material from this text or product, submit all
Senior Content Project Manager: requests online at www.cengage.com/permissions
Jennifer K. Feltri-George Further ­permissions ­questions can be emailed to
permissionrequest@cengage.com
Managing Art Director: Jack Pendleton
Cover image(s):
Library of Congress Control Number: 2015940474
© Rudchenko Liliia/Shutterstock.com
ISBN: 978-1-285-86011-4
Unless otherwise noted all screenshots are
Cengage Learning
courtesy of Microsoft Corporation
20 Channel Center Street
Open Clip art source: OpenClipArt Boston, MA 02210
USA

Cengage Learning is a leading provider of customized learning solutions


with employees residing in nearly 40 different countries and sales in more
than 125 countries around the world. Find your local representative at
www.cengage.com

Cengage Learning products are represented in Canada by


Nelson Education, Ltd.

For your course and learning solutions, visit www.cengage.com


Purchase any of our products at your local college store or at our
preferred online store www.cengagebrain.com
Notice to the Reader
Publisher does not warrant or guarantee any of the products described herein or
perform any independent analysis in connection with any of the product informa-
tion contained herein. Publisher does not assume, and expressly disclaims, any
obligation to obtain and include information other than that provided to it by the
manufacturer. The reader is expressly warned to consider and adopt all safety
­precautions that might be indicated by the activities described herein and to avoid
all potential hazards. By following the instructions contained herein, the reader
­willingly assumes all risks in connection with such instructions. The publisher
makes no representations or warranties of any kind, including but not limited to,
the ­warranties of ­fitness for particular purpose or merchantability, nor are any such
­representations implied with respect to the material set forth herein, and the
­publisher takes no responsibility with respect to such material. The publisher shall
not be liable for any special, consequential, or exemplary damages resulting, in
whole or part, from the readers’ use of, or reliance upon, this material.

Printed in the United States of America


Print Number: 01 Print Year: 2016

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
v

Brief Contents

Pref ace . . . . . . . . . . . . . . . . . . . . . . . . . xi v
Read T h is B ef o re You Begi n . . . . . . . . . . . . . . . xv i i i
Chapt e r 1 A n I n t ro du ct io n to Programmi ng . . . . . . . . . . . . . . 1
Chapt e r 2 B eg in n in g t h e Probl em- Sol v i ng Process . . . . . . . . . . . 23
Chapt e r 3 Var iables an d Constants . . . . . . . . . . . . . . . . . 51
Chapt e r 4 Co m plet in g t h e Probl em- Sol v i ng Process . . . . . . . . . . 75
Chapt e r 5 T h e Select io n Structure . . . . . . . . . . . . . . . . . 113
Chapt e r 6 M o re o n t h e Selecti on Structure . . . . . . . . . . . . . 157
Chapt e r 7 T h e Repet it io n Structure . . . . . . . . . . . . . . . . 201
C HAPT E R 8 M o re o n t h e Repeti ti on Structure . . . . . . . . . . . . . 247
C HAPT E R 9 Valu e-Ret u r n in g Functi ons . . . . . . . . . . . . . . . . 279
C HAPT E R 10 Vo id F u n ct io n s . . . . . . . . . . . . . . . . . . . . . 329
C HAPT E R 11 On e-Dim en s io n a l Array s . . . . . . . . . . . . . . . . . 369
C HAPT E R 12 Tw o -Dim en s io n a l Array s . . . . . . . . . . . . . . . . . 425
C HAPT E R 13 St r in g s . . . . . . . . . . . . . . . . . . . . . . . . 461
C HAPT E R 14 Sequ en t ial A ccess Fi l es . . . . . . . . . . . . . . . . . 511
C HAPT E R 15 Clas s es an d Obj ects . . . . . . . . . . . . . . . . . . 551
A pp endix A C+ + Keyw o rds . . . . . . . . . . . . . . . . . . . . . 593
A pp endix B A SC II Co des . . . . . . . . . . . . . . . . . . . . . . 595
A pp endix C Co m m o n Syn t ax Errors . . . . . . . . . . . . . . . . . 597
A pp endix D Ho w To B o xes . . . . . . . . . . . . . . . . . . . . . 599
I n dex . . . . . . . . . . . . . . . . . . . . . . . . . 603

The Answers.pdf and data files can be found online at CengageBrain.com.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
vi

Contents

Pref ace . . . . . . . . . . . . . . . . . . . . . . . . . xi v
R ead T h is B ef o re Yo u Begi n . . . . . . . . . . . . . . . xv i i i

Chapt e r 1 A n I n t ro du ct io n t o Programmi ng . . . . . . . . . . . . . . 1
Programming a Computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
The Programmer’s Job . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Employment Opportunities . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
A Brief History of Programming Languages . . . . . . . . . . . . . . . . . . . . 3
Machine Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Assembly Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
High-Level Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Control Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
The Sequence Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
The Selection Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
The Repetition Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
LAB 1-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . . 10
LAB 1-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
LAB 1-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
LAB 1-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Chapter 2 B eg in n in g t h e Pro blem- Sol v i ng Process . . . . . . . . . . . 23


Problem Solving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Solving Everyday Problems . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Creating Computer Solutions to Problems . . . . . . . . . . . . . . . . . . . . 25
Step 1—Analyze the Problem . . . . . . . . . . . . . . . . . . . . . . . . . 26
Hints for Analyzing Problems . . . . . . . . . . . . . . . . . . . . . . . . . 26
Step 2—Plan the Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Step 3—Desk-Check the Algorithm . . . . . . . . . . . . . . . . . . . . . . . 31
The Gas Mileage Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
LAB 2-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . . 36
LAB 2-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
LAB 2-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
LAB 2-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
LAB 2-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
LAB 2-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
vii
 

Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

Chapt er 3 Var iables an d Constants . . . . . . . . . . . . . . . . . 51


Beginning Step 4 in the Problem-Solving Process . . . . . . . . . . . . . . . . 52
Internal Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Selecting a Name for a Memory Location . . . . . . . . . . . . . . . . . . . . 53
Revisiting the Addison O’Reilly Problem from Chapter 2 . . . . . . . . . . . . . 54
Selecting a Data Type for a Memory Location . . . . . . . . . . . . . . . . . . 55
How Data Is Stored in Internal Memory . . . . . . . . . . . . . . . . . . . . 57
Selecting an Initial Value for a Memory Location . . . . . . . . . . . . . . . . . 60
Declaring a Memory Location . . . . . . . . . . . . . . . . . . . . . . . . . 62
LAB 3-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . . 64
LAB 3-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
LAB 3-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
LAB 3-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
LAB 3-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
LAB 3-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

Chapt er 4 Co m plet in g t h e Probl em- Sol v i ng Process . . . . . . . . . . 75


Finishing Step 4 in the Problem-Solving Process . . . . . . . . . . . . . . . . . 76
Getting Data from the Keyboard . . . . . . . . . . . . . . . . . . . . . . . . 76
Displaying Messages on the Computer Screen . . . . . . . . . . . . . . . . . . 78
Arithmetic Operators in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Type Conversions in Arithmetic Expressions . . . . . . . . . . . . . . . . . . 82
The static_cast Operator . . . . . . . . . . . . . . . . . . . . . . . . . 83
Assignment Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Arithmetic Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . 87
Step 5—Desk-Check the Program . . . . . . . . . . . . . . . . . . . . . . . 88
Step 6—Evaluate and Modify the Program . . . . . . . . . . . . . . . . . . . . 90
LAB 4-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . . 94
LAB 4-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
LAB 4-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
LAB 4-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
LAB 4-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
LAB 4-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
viii
Contents 

Chapt e r 5 T h e Select io n St r u ct u re . . . . . . . . . . . . . . . . . 113


Making Decisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Flowcharting a Selection Structure . . . . . . . . . . . . . . . . . . . . . . . 116
Coding Selection Structures in C++ . . . . . . . . . . . . . . . . . . . . . . 118
Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Swapping Numeric Values . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Displaying the Area or Circumference . . . . . . . . . . . . . . . . . . . . . 124
Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Using the Truth Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
A Different Version of the Area or Circumference Program . . . . . . . . . . . . 130
Summary of Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Converting a Character to Uppercase or Lowercase . . . . . . . . . . . . . . . 133
Formatting Numeric Output . . . . . . . . . . . . . . . . . . . . . . . . . . 134
LAB 5-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . . 137
LAB 5-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
LAB 5-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
LAB 5-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
LAB 5-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
LAB 5-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

Chapt er 6 M o re o n t h e Select io n Structure . . . . . . . . . . . . . 1 57


Nested Selection Structures . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Flowcharting a Nested Selection Structure . . . . . . . . . . . . . . . . . . . 161
Coding a Nested Selection Structure . . . . . . . . . . . . . . . . . . . . . . 163
Logic Errors in Selection Structures . . . . . . . . . . . . . . . . . . . . . . 165
First Logic Error: Using a Compound Condition Rather Than a Nested
Selection Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Second Logic Error: Reversing the Outer and Nested Decisions . . . . . . . . . 169
Third Logic Error: Using an Unnecessary Nested Selection Structure . . . . . . 169
Fourth Logic Error: Including an Unnecessary Comparison in a Condition . . . . 170
Multiple-Alternative Selection Structures . . . . . . . . . . . . . . . . . . . . 173
The switch Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
LAB 6-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . . 177
LAB 6-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
LAB 6-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
LAB 6-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
LAB 6-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
LAB 6-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
ix
 

Chapt e r 7 T h e Repet it io n Structure . . . . . . . . . . . . . . . . 201


Repeating Program Instructions . . . . . . . . . . . . . . . . . . . . . . . . 202
Using a Pretest Loop to Solve a Real-World Problem . . . . . . . . . . . . . . . 204
Flowcharting a Pretest Loop . . . . . . . . . . . . . . . . . . . . . . . . . 206
The while Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Using Counters and Accumulators . . . . . . . . . . . . . . . . . . . . . . . 211
The Stock Price Program . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Counter-Controlled Pretest Loops . . . . . . . . . . . . . . . . . . . . . . . 217
The for Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
The Total Payroll Program . . . . . . . . . . . . . . . . . . . . . . . . . . 220
The Tip Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Another Version of the Commission Program . . . . . . . . . . . . . . . . . 224
The Even Integers Program . . . . . . . . . . . . . . . . . . . . . . . . . 226
LAB 7-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . . 229
LAB 7-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
LAB 7-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
LAB 7-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
LAB 7-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
LAB 7-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

Chapter 8 M o re o n t h e Repeti ti on Structure . . . . . . . . . . . . . 247


Posttest Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Flowcharting a Posttest Loop . . . . . . . . . . . . . . . . . . . . . . . . . 250
The do while Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Nested Repetition Structures . . . . . . . . . . . . . . . . . . . . . . . . . 254
The Clock Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
The Car Depreciation Program . . . . . . . . . . . . . . . . . . . . . . . . . 258
LAB 8-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . . 262
LAB 8-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
LAB 8-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
LAB 8-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
LAB 8-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
LAB 8-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270

Chapter 9 Valu e-Ret u r n in g Functi ons . . . . . . . . . . . . . . . . 279


Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Value-Returning Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
The pow Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
x
Contents 

The sqrt Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282


The Hypotenuse Program . . . . . . . . . . . . . . . . . . . . . . . . . . 283
The rand , srand , and time Functions . . . . . . . . . . . . . . . . . . . . . 285
The Guessing Game Program . . . . . . . . . . . . . . . . . . . . . . . . 289
Creating Program-Defined Value-Returning Functions . . . . . . . . . . . . . . . 291
Calling a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
The Savings Account Program . . . . . . . . . . . . . . . . . . . . . . . . 295
Function Prototypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Completing the Savings Account Program . . . . . . . . . . . . . . . . . . . 298
The Scope and Lifetime of a Variable . . . . . . . . . . . . . . . . . . . . . . 304
LAB 9-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . . 305
LAB 9-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
LAB 9-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
LAB 9-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
LAB 9-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
LAB 9-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

Chapt er 10 Vo id F u n ct io n s . . . . . . . . . . . . . . . . . . . . . 329
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Creating Program-Defined Void Functions . . . . . . . . . . . . . . . . . . . . 331
Passing Variables to a Function . . . . . . . . . . . . . . . . . . . . . . . . 337
Reviewing Passing Variables by Value . . . . . . . . . . . . . . . . . . . . . 338
Passing Variables by Reference . . . . . . . . . . . . . . . . . . . . . . . 341
LAB 10-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . 345
LAB 10-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . 347
LAB 10-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
LAB 10-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . 356
LAB 10-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
LAB 10-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360

Chapter 11 On e-Dim en s io n al Ar r ay s . . . . . . . . . . . . . . . . . 369


Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
One-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
Declaring and Initializing a One-Dimensional Array . . . . . . . . . . . . . . . 371
Entering Data into a One-Dimensional Array . . . . . . . . . . . . . . . . . . 373
Displaying the Contents of a One-Dimensional Array . . . . . . . . . . . . . . 375
The Calories Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
Passing a One-Dimensional Array to a Function . . . . . . . . . . . . . . . . . 382
Calculating a Total and an Average . . . . . . . . . . . . . . . . . . . . . . . 384

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xi
 

The Social Media Program—Searching an Array . . . . . . . . . . . . . . . . . 385


The Currency Converter Program—Accessing an Individual Element . . . . . . . . 388
The Highest Number Program—Finding the Highest Value . . . . . . . . . . . . 391
Parallel One-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . 396
Sorting the Data Stored in a One-Dimensional Array . . . . . . . . . . . . . . . 399
LAB 11-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . 406
LAB 11-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . 407
LAB 11-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
LAB 11-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . 411
LAB 11-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
LAB 11-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416

Chapter 12 Tw o -Dim en s io n al Array s . . . . . . . . . . . . . . . . . 425


Using Two-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . 426
Declaring and Initializing a Two-Dimensional Array . . . . . . . . . . . . . . . 427
Entering Data into a Two-Dimensional Array . . . . . . . . . . . . . . . . . . 428
Displaying the Contents of a Two-Dimensional Array . . . . . . . . . . . . . . 431
The Chapton Company Program . . . . . . . . . . . . . . . . . . . . . . . 432
Accumulating the Values Stored in a Two-Dimensional Array . . . . . . . . . . . 434
Searching a Two-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . 436
Passing a Two-Dimensional Array to a Function . . . . . . . . . . . . . . . . . 443
LAB 12-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . 444
LAB 12-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . 446
LAB 12-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
LAB 12-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . 449
LAB 12-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
LAB 12-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452

Chapter 13 St r in g s . . . . . . . . . . . . . . . . . . . . . . . . 461
The string Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
Getting String Input from the Keyboard . . . . . . . . . . . . . . . . . . . . . 462
The Primrose Auction House Program . . . . . . . . . . . . . . . . . . . . . 464
The ignore Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Determining the Number of Characters in a string Variable . . . . . . . . . . . 471
Accessing the Characters in a string Variable . . . . . . . . . . . . . . . . . 473
Searching the Contents of a string Variable . . . . . . . . . . . . . . . . . . 477
Removing Characters from a string Variable . . . . . . . . . . . . . . . . . . 481
Replacing Characters in a string Variable . . . . . . . . . . . . . . . . . . . 484
Inserting Characters Within a string Variable . . . . . . . . . . . . . . . . . 485

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xii
Contents 

Duplicating a Character Within a string Variable . . . . . . . . . . . . . . . . 487


Concatenating Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
LAB 13-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . 491
LAB 13-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . 492
LAB 13-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
LAB 13-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . 497
LAB 13-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
LAB 13-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504

Chapter 14 Sequ en t ial A cces s F iles . . . . . . . . . . . . . . . . . 511


File Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
Creating File Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
Opening a Sequential Access File . . . . . . . . . . . . . . . . . . . . . . . 514
Determining Whether a File Was Opened Successfully . . . . . . . . . . . . . 516
Writing Data to a Sequential Access File . . . . . . . . . . . . . . . . . . . . 518
Reading Information from a Sequential Access File . . . . . . . . . . . . . . . 519
Testing for the End of a Sequential Access File . . . . . . . . . . . . . . . . 522
Closing a Sequential Access File . . . . . . . . . . . . . . . . . . . . . . . . 522
The eBook Collection Program . . . . . . . . . . . . . . . . . . . . . . . . . 523
LAB 14-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . 528
LAB 14-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . 530
LAB 14-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
LAB 14-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . 540
LAB 14-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
LAB 14-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544

Chapter 15 Clas s es an d Object s . . . . . . . . . . . . . . . . . . 551


Object-Oriented Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Defining a Class in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
Instantiating an Object and Referring to a Public Member . . . . . . . . . . . . 556
Exa mple 1—A Class That Contains a Private Data Member
and Public Member Methods . . . . . . . . . . . . . . . . . . . . . . . 557
Header Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
Example 2—A Class That Contains a Parameterized Constructor . . . . . . . . . 562
Example 3—Reusing a Class . . . . . . . . . . . . . . . . . . . . . . . . . 565
Example 4—A Class That Contains Overloaded Methods . . . . . . . . . . . . . 566
LAB 15-1 Stop and Analyze . . . . . . . . . . . . . . . . . . . . . . . . . 569
LAB 15-2 Plan and Create . . . . . . . . . . . . . . . . . . . . . . . . . . 571
LAB 15-3 Modify . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xiii
 

LAB 15-4 What’s Missing? . . . . . . . . . . . . . . . . . . . . . . . . . . 576


LAB 15-5 Desk-Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576
LAB 15-6 Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
Key Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581

App endix A C+ + Keyw o rds . . . . . . . . . . . . . . . . . . . . . 593

A pp endix B A SC II Co des . . . . . . . . . . . . . . . . . . . . . . 595

A pp endix C Co m m o n Syn t ax Errors . . . . . . . . . . . . . . . . . 597

A pp endix D H o w To B o xes . . . . . . . . . . . . . . . . . . . . . 599

In dex . . . . . . . . . . . . . . . . . . . . . . . . . 603

The Answers.pdf and data files can be found online at CengageBrain.com.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xiv

Preface

An Introduction to Programming with C++, Eighth Edition uses the C++ programming language
to teach programming concepts. This book is designed for a beginning programming course.
Although the book provides instructions for using several specific C++ compilers (such as
® ®
Microsoft Visual C++ , Dev-C++, and Code::Blocks), it can be used with most C++ compilers,
often with little or no modification.

Organization and Coverage


An Introduction to Programming with C++, Eighth Edition contains 15 chapters and several
appendices. In the chapters, students with no previous programming experience learn how to
plan and create well-structured programs. They also learn how to write programs using the
sequence, selection, and repetition structures, as well as how to create and manipulate functions,
sequential access files, arrays, strings, classes, and objects.

Approach
An Introduction to Programming with C++, Eighth Edition is distinguished from other textbooks
because of its unique approach, which motivates students by demonstrating why they need to
learn the concepts and skills presented. Each chapter begins with an introduction to one or more
programming concepts. The concepts are illustrated with code examples and sample programs.
The sample programs allow the student to observe how the current concept can be used before
they are introduced to the next concept. The concepts are taught using standard C++ commands.
Following the concept portion in each chapter (except Chapter 1) are six labs: Stop and Analyze,
Plan and Create, Modify, What’s Missing?, Desk-Check, and Debug. Each lab teaches students
how to apply the chapter concepts; however, each does so in a different way.

Features
An Introduction to Programming with C++, Eighth Edition is an exceptional textbook because it
also includes the following features:
READ THIS BEFORE YOU BEGIN This section is consistent with Cengage Learning’s
unequaled commitment to helping instructors introduce technology into the classroom.
­Technical considerations and assumptions about hardware, software, and default settings are
listed in one place to help instructors save time and eliminate unnecessary aggravation.

LABS  Each chapter (except Chapter 1) contains six labs that teach students how to
apply the concepts taught in the chapter to real-world problems. In the first lab,
which is the Stop and Analyze lab, students are expected to stop and analyze an
­existing program. Students plan and create a program in the Plan and Create lab,
which is the second lab. The third lab is the Modify lab. This lab requires students to

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xv
Organization and Coverage 

modify an existing program. In the fourth lab, which is the new What’s Missing? lab, students are
asked to find one or more missing instructions in a program. However, before they can
­accomplish this task, they must put the existing instructions in the proper order. The fifth lab is
the Desk-Check lab, in which students follow the logic of a program by desk-checking it. The
sixth lab is the Debug lab. This lab gives students an opportunity to find and correct the errors in
an existing program. Answers to the labs are provided in the Answers.pdf file available at
­CengageBrain.com. Providing the answers allows students to determine whether they have
­mastered the material covered in the chapter.

HOW TO BOXES The How To boxes in each chapter summarize important concepts and
­ rovide a quick reference for students. The How To boxes that introduce new statements,
p
­operators, stream manipulators, or functions contain the syntax and examples of using the syntax.
STANDARD C++ SYNTAX Like the previous edition of the book, this edition uses the standard
C++ syntax in the examples, sample programs, and exercises in each chapter.
PSEUDOCODE AND FLOWCHARTS Both planning tools are shown for many of the programs
within the chapters.
TIP  These notes provide additional information about the current concept. Examples
include alternative ways of writing statements, warnings about common mistakes made
when using a particular command, and reminders of related concepts learned in previous
chapters.
MINI-QUIZZES Mini-Quizzes are strategically placed to test students’ knowledge at various
points in each chapter. Answers to the quiz questions are provided in the Answers.pdf file,
allowing students to determine whether they have mastered the material covered thus far before
continuing with the chapter.
WANT MORE INFO? FILES These notes direct students to files that accompany
each chapter in the book. The files contain additional examples and further
­explanations of the concepts covered in the chapter. The files are in PDF format and
are available online at CengageBrain.com. Search for the ISBN associated with your
book (from the back cover of your book) using the search box at the top of the page.
This will take you to the product page where free companion resources can be found.
SUMMARY A Summary section follows the labs in each chapter. The Summary section recaps
the programming concepts and commands covered in the chapter.
KEY TERMS Following the Summary section in each chapter is a listing of the key terms
­introduced throughout the chapter, along with their definitions.
REVIEW QUESTIONS Review Questions follow the Key Terms section in each chapter.
The Review Questions test the students’ understanding of what they learned in the chapter.
PAPER AND PENCIL EXERCISES The Review Questions are followed by Pencil
and Paper Exercises, which are designated as TRY THIS, MODIFY THIS,
­INTRODUCTORY, INTERMEDIATE, ADVANCED, and SWAT THE BUGS. The
answers to the TRY THIS Exercises are provided at the end of the chapter. The
ADVANCED Exercises provide practice in applying cumulative programming k­ nowledge or
allow students to explore alternative solutions to programming tasks. The SWAT THE BUGS
­Exercises provide an opportunity for students to detect and correct errors in one or more lines
of code.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xvi
Contents Organization and Coverage

COMPUTER EXERCISES The Computer Exercises provide students with additional


Computer
practice of the skills and concepts they learned in the chapter. The Computer
­Exercises are designated as TRY THIS, MODIFY THIS, INTRODUCTORY,
­INTERMEDIATE, ADVANCED, and SWAT THE BUGS. The answers to the
TRY THIS Exercises are provided at the end of the chapter. The ADVANCED Exercises provide
practice in applying cumulative programming knowledge or allow students to explore a­ lternative
solutions to programming tasks. The SWAT THE BUGS Exercises provide an opportunity for
students to detect and correct errors in an existing program.

New to this Edition!


ANSWERS.PDF FILE The answers to the Mini-Quizzes and Labs are now contained
in the Answers.pdf file (rather than in Appendix A); this file is available to students at
­CengageBrain.com.
NEW EXAMPLES, PROGRAMS, LABS, QUESTIONS, AND EXERCISES  The chapters
­contain new code examples, sample programs, Labs, Review Questions, and Exercises.
WHAT’S MISSING? LAB The chapters contain a new Lab called What’s Missing?.
In the What’s Missing? Lab, students must determine the one or more missing
­instructions in a program. However, before they can do this, they must first put the
existing instructions in the proper order.

VIDEOS These notes direct students to videos that accompany each chapter in the
book. Many of the videos have been revised from the previous edition. The videos
explain and/or demonstrate one or more of the chapter’s concepts. The videos are
­available online at CengageBrain.com. Search for the ISBN associated with your book (from the
back cover of your book) using the search box at the top of the page. This will take you to the
product page where free companion resources can be found.
INSTALLATION VIDEOS These videos, which have been revised from the previous
edition, show students how to install various C++ compilers (such as Microsoft Visual
C++, Dev-C++, and Code::Blocks). The videos are named Ch04-Installation
­developmentTool, where developmentTool is the name of the C++ development tool ­covered in
the video. The videos are available online at CengageBrain.com. Search for the ISBN associated
with your book (from the back cover of your book) using the search box at the top of the page.
This will take you to the product page where free companion resources can be found.
STEP-BY-STEP INSTRUCTIONS This book is accompanied by files that contain ­step-by-step
instructions for completing Labs 4-2, 4-3, 4-4, 4-6, 5-2, 5-3, and 5-6 using various
C++ ­compilers. The files, which have been revised from the previous edition, are named
Ch04-Lab4-X developmentTool.pdf and Ch05-Lab5-X developmentTool.pdf, where X represents
the lab number, and developmentTool is the name of the C++ development tool covered in the
file. The files are in PDF format and are available online at www.cengagebrain.com. Search for
the ISBN associated with your book (from the back cover of your book) using the search box at
the top of the page. This will take you to the product page where free companion resources can
be found.
APPENDICES Appendices B, C, D, and E are now Appendices A, B, C, and D. The information
in Appendix A from the previous edition is now contained in the Answers.pdf file.
POW FUNCTION The pow function is now covered along with the built-in value-returning
functions in Chapter 9 (rather than in Chapter 8).

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xvii
Acknowledgments 

Instructor Resources
The following resources are available on the Instructor Companion Site (sso.cengage.com) to
instructors who have adopted this book. Search for this title by ISBN, title, author, or keyword.
From the Product Overview page, select the Instructor’s Companion Site link to access your
complementary resources.
INSTRUCTOR’S MANUAL The Instructor’s Manual follows the text chapter by chapter to assist
you in planning and organizing an effective, engaging course. The manual includes learning
objectives, chapter overviews, ideas for classroom activities, and additional resources. A sample
course Syllabus is also available.
TEST BANK Cengage Learning Testing Powered by Cognero is a flexible, online system that
allows you to:
•• author, edit, and manage test bank content from multiple Cengage Learning solutions
•• create multiple test versions in an instant
•• deliver tests from your LMS, your classroom or wherever you want

POWERPOINT PRESENTATIONS This book comes with Microsoft PowerPoint slides for
each chapter. These are included as a teaching aid for classroom presentation, to make ­available
to students on the network for chapter review, or to be printed for classroom distribution.
­Instructors are encouraged to customize the slides to fit their course needs, and may add slides
to cover additional topics using the complete Figure Files from the text, also available on the
Instructor Companion Site.
SOLUTION FILES Solutions to the Labs, Review Questions, Pencil and Paper Exercises, and
Computer Exercises are available. The Solution Files also contain the sample programs that
appear in the figures throughout the book.
DATA FILES Data Files are required to complete many Labs and Computer Exercises in this
book. They are available on the Instructor Companion Site as well as on CengageBrain.com.

Acknowledgments
Writing a book is a team effort rather than an individual one. I would like to take this
­opportunity to thank my team, especially Alyssa Pratt (Senior Content Developer), Jennifer
K. Feltri-George (Senior Content Project Manager), Marisa Taylor (Senior Project Manager),
and Nicole Ashton, Serge Palladino, Chris Scriver (Quality Assurance). Thank you for your
­support, enthusiasm, patience, and hard work; it made a difficult task much easier. Last, but
certainly not least, I want to thank Fred D’Angelo, Pima Community College East Campus;
Charles ­Nelson, Rock Valley College; and Mark Shellman, Gaston College for their invaluable
ideas and comments.
Diane Zak

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
xviii

Read This Before


You Begin

Technical Information
Data Files
You will need data files to complete the Labs and Computer Exercises in this book. Your
­instructor may provide the data files to you. You may obtain the files electronically at
­CengageBrain.com. Search for the ISBN associated with your book (from the back cover of your
text) using the search box at the top of the page. This will take you to the product page where
free companion resources can be found.
Each chapter in this book has its own set of data files, which are stored in a separate folder
within the Cpp8 folder. The files for Chapter 4 are stored in the Cpp8\Chap04 folder. Similarly,
the files for Chapter 5 are stored in the Cpp8\Chap05 folder. Throughout this book, you will be
instructed to open files from or save files to these folders.
You can use a computer in your school lab or your own computer to complete the Labs and
Computer Exercises in this book.

Using Your Own Computer


To use your own computer to complete the Labs and Computer Exercises in this book, you will
need a C++ compiler. This book is accompanied by videos that show students how to install
various C++ compilers (such as Microsoft Visual C++, Dev-C++, and Code::Blocks). The
­videos are named Ch04-Installation development Tool, where development Tool is the name of
the C++ development tool covered in the video. You may obtain the files electronically at
CengageBrain.com. Search for the ISBN associated with your book (from the back cover of
your book) using the search box at the top of the page. This will take you to the product page
where free ­companion resources can be found.
The book was written and Quality Assurance tested using Microsoft Visual C++ in Visual
Studio Ultimate 2015. It also was tested using Code::Blocks and Dev-C++. However, the book
can be used with most C++ compilers, often with little or no modification. At the time of
this writing, you can download a free copy of the Community Edition of Visual Studio 2015,
which contains the Visual C++ compiler, at https://www.visualstudio.com/en-us/downloads/
visual-studio-2015-downloads-vs.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Chapter 1
An Introduction to
Programming

After studying Chapter 1, you should be able to:

Define the terminology used in programming


Explain the tasks performed by a programmer
Understand the employment opportunities for programmers and
software engineers
Explain the history of programming languages
Explain the sequence, selection, and repetition structures
Write simple algorithms using the sequence, selection, and repetition
structures

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
2
Chapter 1 An Introduction to Programming

Programming a Computer
In essence, the word programming means giving a mechanism the directions to accomplish a
task. If you are like most people, you’ve already programmed several mechanisms, such as your
digital video recorder (DVR), cell phone, or coffee maker. Like these devices, a computer also is a
mechanism that can be programmed.
The directions (typically called instructions) given to a computer are called computer ­programs
or, more simply, programs. The people who write programs are called p ­ rogrammers. Program-
mers use a variety of special languages, called programming languages, to ­communicate with the
computer. Some popular programming languages are C++, Visual Basic, C#, Java, and Python. In
this book, you will use the C++ programming language.

The Programmer’s Job


When a company has a problem that requires a computer solution, typically it is a programmer
who comes to the rescue. The programmer might be an employee of the company; or he or she
might be a freelance programmer, which is a programmer who works on temporary contracts
Ch01-Programmers rather than for a long-term employer.
To begin the process of developing a program, the programmer meets with the user, who is
the person (or persons) responsible for describing the problem. In many cases, this person or
­persons also will eventually use the ­solution. Depending on the complexity of the problem,
multiple programmers may be involved, and they may need to meet with the user several
times. Programming teams often contain ­subject matter experts, who may or may not be
­programmers. For example, an accountant might be part of a team working on a program that
requires accounting expertise. The purpose of the ­initial meetings with the user is to determine
the exact problem and to agree on a solution.
After the programmer and user agree on the solution, the programmer begins converting the solu-
tion into a computer program. During the conversion phase, the programmer meets ­periodically
with the user to determine whether the program fulfills the user’s needs and to refine any details
of the solution. When the user is satisfied that the program does what he or she wants it to do, the
programmer rigorously tests the program with sample data before releasing it to the user, who will
test it further to verify that it correctly solves the problem. In many cases, the programmer also
provides the user with a manual that explains how to use the program. As this process indicates,
the creation of a good computer solution to a problem—in other words, the creation of a good
program—requires a great deal of interaction between the programmer and the user.

Employment Opportunities
When searching for a job in computer programming, you will encounter ads for “computer
programmers” as well as for “computer software engineers.” Although job titles and descriptions
vary, computer software engineers typically are responsible for designing an ­appropriate ­solution
Ch01-Programmer to a user’s problem, while computer programmers are responsible for translating the solution
Qualities into a language that the computer can understand—a process called coding. Software engineer-
ing is a higher-level position that requires the ability to envision solutions. Using a construction
analogy, software engineers are the architects, while programmers are the carpenters.
Keep in mind that, depending on the employer and the size and complexity of the user’s ­problem,
the design and coding tasks may be performed by the same employee, no matter what his or her
job title is. In other words, it’s not unusual for a software engineer to code his or her solution, just
as it’s not unusual for a programmer to have designed the solution he or she is coding.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
3
A Brief History of Programming Languages 

Programmers and software engineers need to have strong problem-solving and analytical skills,
as well as the ability to communicate effectively with team members, end users, and other non-
technical personnel. Typically, computer software engineers are expected to have at least a bach-
elor’s degree in software engineering, computer science, or mathematics, along with practical
work experience, especially in the industry in which they are employed. Computer programmers
usually need at least an associate’s degree in computer science, mathematics, or information sys-
tems, as well as proficiency in one or more programming languages.
Computer programmers and software engineers are employed by companies in almost every
industry, such as telecommunications companies, software publishers, financial institutions,
insurance carriers, educational institutions, and government agencies. The Bureau of Labor
Statistics predicts that employment of computer software engineers will increase by 22 p ­ ercent
from 2012 to 2022. The employment of computer programmers, on the other hand, will
increase by 8 percent over the same period. In addition, consulting opportunities for freelance
­programmers and software engineers are expected to increase as companies look for ways to
reduce their payroll expenses.
There is a great deal of competition for programming and software engineering jobs, so jobseekers
will need to keep up to date with the latest programming languages and technologies. A competitive
edge may be gained by obtaining vendor-specific or language-specific certifications, as well as knowl-
edge of a prospective employer’s business. More information about computer programmers and
computer software engineers can be found on the Bureau of Labor Statistics Web site at www.bls.gov.

A Brief History of Programming Languages


Just as human beings communicate with each other through the use of languages such as E ­ nglish,
Spanish, Hindi, and Chinese, programmers use a variety of programming languages to commu-
nicate with the computer. In the next sections, you will follow the progression of ­programming
languages from machine languages to assembly languages, and then to high-level languages. Ch01-History

Machine Languages
Within a computer, all data is represented by microscopic electronic switches that can be either
off or on. The off switch is designated by a 0, and the on switch is designated by a 1. Because
computers can understand only these on and off switches, the first programmers had to write
the program instructions using nothing but combinations of 0s and 1s; for example, a program
might contain the instruction 00101 10001 10000. Instructions written in 0s and 1s are called
machine language or machine code. The machine languages (each type of machine has its
own language) represent the only way to communicate directly with the computer. As you can
imagine, programming in machine language is very tedious and error-prone and requires highly
trained programmers.

Assembly Languages
Slightly more advanced programming languages are called assembly languages. The assembly
languages simplify the programmer’s job by allowing the programmer to use mnemonics in
place of the 0s and 1s in the program. Mnemonics are memory aids—in this case, alphabetic
abbreviations for instructions. For example, most assembly languages use the mnemonic ADD
to represent an add operation and the mnemonic MUL to represent a multiply operation. An
­example of an instruction written in an assembly language is ADD bx, ax.
Programs written in an assembly language require an assembler, which also is a program,
to convert the assembly instructions into machine code—the 0s and 1s the computer can

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
4
Chapter 1 An Introduction to Programming

understand. Although it is much easier to write programs in assembly language than in machine
language, programming in assembly language still is tedious and requires highly trained
­programmers. Programs written in assembly language are machine specific and usually must be
rewritten in a different assembly language to run on different computers.

High-Level Languages
High-level languages represent the next major development in programming languages.
­ igh-level languages are a vast improvement over machine and assembly languages because
H
they allow the programmer to use instructions that more closely resemble the English language.
An example of an instruction written in a high-level language is grossPay = hours * rate. In
addition, high-level languages are more machine independent than are machine and assembly
languages. As a result, programs written in a high-level language can be used on many different
types of computers.
Programs written in a high-level language usually require a compiler, which also is a program,
to convert the English-like instructions into the 0s and 1s the computer can understand. Some
high-level languages also offer an additional program called an interpreter. Unlike a compiler,
which translates all of a program’s high-level instructions before running the program, an
­interpreter translates the instructions line by line as the program is running.
Like their predecessors, the first high-level languages were used to create procedure-oriented
programs. When writing a procedure-oriented program, the programmer concentrates on
the major tasks that the program needs to perform. A payroll program, for example, typically
performs several major tasks, such as inputting the employee data, calculating the gross pay,
calculating the taxes, calculating the net pay, and outputting a paycheck. The programmer must
instruct the computer every step of the way, from the start of the task to its completion. In a
procedure-oriented program, the programmer determines and controls the order in which the
computer processes the instructions. In other words, the programmer must determine not only
the proper instructions to give the computer but the correct sequence of those instructions as
well. Examples of high-level languages used to create procedure-oriented programs include
COBOL (Common Business-Oriented Language), BASIC (Beginner’s All-Purpose Symbolic
Instruction Code), and C.

Most objects More advanced high-level languages can be used to create object-oriented programs in ­addition
in an ­object- to procedure-oriented ones. Different from a procedure-oriented program, which focuses
oriented on the individual tasks the program must perform, an object-oriented program requires
program are the ­programmer to focus on the objects that the program can use to accomplish its goal. The
designed objects can take on many different forms. For example, programs written for the Windows
to perform multiple
­environment typically use objects such as check boxes, list boxes, and buttons. A payroll
tasks. These tasks are
­program, on the other hand, might utilize objects found in the real world, such as a time card
programmed using the
same techniques used object, an employee object, or a check object.
in procedure-oriented Because each object in an object-oriented program is viewed as an independent unit, an object
programming.
can be used in more than one program, usually with little or no modification. A check object
used in a payroll program, for example, also can be used in a sales revenue program (which
receives checks from customers) and an accounts payable program (which issues checks to
creditors). The ability to use an object for more than one purpose enables code reuse, which
saves ­programming time and money—an advantage that contributes to the popularity of

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
5
Control Structures 

­ bject-oriented programming. Examples of high-level languages that can be used to create both
o
procedure-oriented and object-oriented programs include C++, Visual Basic, Java, and C#. In this
book, you will learn how to use the C++ programming language to create ­procedure-oriented
and object-oriented programs.

The answers
Mini-Quiz 1-1 to Mini-Quiz
­questions are
contained in the
1. Instructions written in 0s and 1s are called _________________________ language.
Answers.pdf file.
2. When writing a(n) _________________________ program, the programmer
­concentrates on the major tasks needed to accomplish a goal.
a. procedure-oriented
b. object-oriented

3. When writing a(n) _________________________ program, the programmer breaks up a


­problem into interacting objects.
a. procedure-oriented
b. object-oriented

4. Most high-level languages use a(n) _________________________ to translate the


instructions into a language that the computer can understand.

Control Structures
All computer programs, no matter how simple or how complex, are written using one or more
of three basic structures: sequence, selection, and repetition. These structures are called c
­ ontrol
structures or logic structures because they control the flow of a program’s logic. In other
words, they control the order in which the computer executes the program’s instructions. You
will use the sequence structure in every program you write. In most programs, you also will
use the selection and repetition structures. This chapter gives you an introduction to the three
control structures. More detailed information about each structure, as well as how to implement
these structures using the C++ language, is provided in subsequent chapters.

The Sequence Structure


You use the sequence structure each time you follow a set of step-by-step instructions, in order,
from beginning to end. The instructions might be a recipe for making chocolate chip cookies.
Or, they might be the MapQuest directions to your favorite restaurant. They could also be the
instructions for assembling a robot, which are shown in Figure 1-1. The instructions shown in
the figure are called an algorithm, which is a set of step-by-step instructions for accomplishing
a task.

Copyright 2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.
Exploring the Variety of Random
Documents with Different Content
1648. Thomas Damme buried at Minshull, England, "being of the age of
seven score and fourteen" (154 years).
1725. A party of 40 New Hampshire volunteers on an excursion for
hunting Indians, discovered a party of ten encamped for the night
round a fire. Advancing cautiously at midnight, the enemy were
found asleep and the whole shot. They were marching from Canada
well furnished with new guns and ammunition, and a number of
spare blankets, moccasins and snow shoes, for the accommodation
of the prisoners they expected to take, and were within two miles of
the frontiers. The party entered Dover in triumph, with the ten
scalps stretched on hoops and elevated on poles; and received a
bounty of £100 for each scalp, at Boston, out of the public treasury.
1736. A bill was introduced into the British parliament, placing a duty
of 20 shillings a gallon on spirituous liquors, and £50 license for
selling them, in order to prevent their excessive use; but was
defeated so far as to tolerate punch at a low rate, the merchants of
Bristol and Liverpool fearing the lessening of consumption on rum
and other things distilled from molasses.
1737. Elizabeth Rowe died; an English lady distinguished for her piety
and literary talents.
1745. British ship Chester, Capt. Geary, captured the French ship
Elephant with $24,000 on board.
1749. Usher Gahagan, executed at Tyburn. He was a gentleman by
birth, and a scholar; he edited a beautiful edition of the classics, and
translated Pope's Messiah and Temple of Fame into Latin verse. His
crime was that of clipping coin!
1762. Tobias Mayer, a distinguished mathematician, died at
Gottingen. His lunar and solar tables, as well as his original
suggestions on the repeating circle are of much value.
1771. John James de Mairan, a French philosopher, died. He succeeded
Fontenelle as secretary to the academy of sciences, and is the
author of a Treatise on Phosphoric Light, &c.
1772. The royal marriage act of England was passed. This was
another of those attempts to perpetuate regal domination.
1778. Laura Bassi died; she was honored with the degree of doctor of
philosophy, for the great mental acquirements displayed in her
lectures on that subject, and was distinguished as possessing every
amiable virtue.
1780. British under General Clinton invaded South Carolina.
1781. Robert Morris appointed by congress superintendent of
finance.
1790. Joseph II, emperor of Germany, died. He was an able and
benevolent monarch, who devoted his attention closely to the affairs
of the kingdom, and introduced many useful institutions.
1790. At Blackwall, England, while excavations were being made for
a wet dock several hazel trees, with nuts, were found deeply
imbedded below several strata of sand and clay.
1797. Treaty of Tolentino between Bonaparte and the pope.
1799. El Arish, and subsequently Gaza, with most towns in western
Palestine, were taken by the French.
1799. Leopold II, died; grand duke of Tuscany 25 years, and elected
emperor of Germany, 1790. He evinced great abilities.
1802. John Moore, a distinguished Scottish physician, and popular
author, died. He wrote on the society and manners of different
countries in Europe, which his acute discernment and lively
imagination enabled him to describe with great accuracy and
pleasantry.
1803. British evacuated Egypt.
1808. Gerard Lake died. He was made a peer of Great Britain for his
successes as a general in India.
1809. Richard Gough, a learned and eminent English antiquary, died.
1809. Saragossa surrendered to the French. The garrison was
reduced to 12,000 men, who, when they marched out of the city,
had more the appearance of spectres than of human beings. During
this second siege 54,000 perished, of whom one fourth were
soldiers.
1810. Andrew Hofer, the leader of the Tyrolese insurrection,
executed. He was a brave patriot, and met his fate with heroic
firmness.
1811. Battle of San Christoval in Spain, in which general Mendizabal
was defeated with the loss of about 12,000 killed and prisoners, by
the French under Soult, whose loss was stated at 400 only.
1811. Francis II, of Germany, issued an edict, fixing the current value
of bank paper at one fifth of its nominal value.
1817. Samuel Meredith died at his seat in Wayne county, Pa.; first
treasurer of the United States under the federal constitution, which
office he resigned in 1801.
1820. Arthur Young died; a distinguished English author on
agriculture.
1822. John Stewart, commonly called walking John, died in London;
to gratify the "amor videndi," he had perambulated much of the
globe.
1835. A tremendous earthquake in Chili. The city of Conception,
containing 25,000 inhabitants, was reduced to a heap of ruins, not a
single house left standing; many other towns and villages were
demolished. At first the sea retired and left the vessels in the harbor
aground; but it soon rushed violently back 30 feet above its level.
1836. Mary Crawford, died at Castine, Me., aged 100 years and six
months; widow of Dr. Wm. Crawford, chaplain and surgeon at Fort
Point during the revolution.
1841. James G. Brooks died; known in early life as an American poet,
and later as an editor of several newspapers.
1843. Peter Augustus Jay, well known in the state of New York as a
statesman and historian, died.
1846. The first legislature of Texas under the U. S. met at Austin.
Gen. Henderson was elected the first governor.
1849. Newton M. Curtiss, author of a number of popular novels, died
at Charlton, N. Y., aged 34.
1854. Elliott Cresson, president of the Pennsylvania colonization
society, died, leaving $127,000 to charitable institutions.
1854. The most violent snow storm that had occurred since 1831,
commenced at Washington, and extended over the Middle and New
England states.
1855. Joseph Hume, the English statesman died, aged 78. He was a
member of the house of commons 37 years.

FEBRUARY 21.

1340. The king of England assumed the title of the king of France,
quartering his arms with the motto, "Dieu et mon Droit."
1513. Giuliano Della Rovera, (pope Julius II,) died. He was originally a
fisherman. He built St. Peter's at Rome, to procure means for which
he ordered the sale of indulgences, which was one of the immediate
causes of the reformation; so that it may be said without paradox,
that St. Peter's is the great monument of protestantism. He is
considered one of the most immoral of the popes, though a
generous patron of the polite arts.
1595. Robert Southwell, called sometimes the English Jesuit, died. He
was esteemed no inferior poet in his day.
1633. Order of the privy council to stay several ships in the Thames,
ready to sail for New England with passengers and provisions. The
jealousy of the government was early directed towards the infant
colony of Massachusetts. It was observed by one of the kings, that
the wheat of the population was sifting across the Atlantic. These
orders were ineffectual, for great numbers continued to emigrate,
and scarce a vessel arrived in the colony that was not crowded with
passengers.
1660. The secluded members of the long parliament again took their
seats and voted Monk to be general of the English, Scotch and Irish
forces.
1668. John Thurloe, secretary of state to the two Cromwells, died. He
was a man of very amiable character, and exercised all possible
moderation towards persons of every party.
1676. Two or three hundred Indians principally Narragansetts,
surprised the town of Medfield, Mass., killed 18 men, women and
children, and burnt half of the town.
1682. The following appears in the minutes of the governor and
council of Virginia: "John Buckner called before the Ld. Culpepper
and his counsel for printing the laws of 1680, without his
excellency's license, and he and the printer ordered to enter into
bond in £100 not to print anything hereafter until his majesty's
pleasure shall be known."
1684. Charles Spon, an ingenious and learned French physician, died
at Lyons. He wrote Latin verse with ease and elegance, and
corresponded with most of the learned men of Europe.
1717. Peter Alix, a French protestant of eminent piety and learning,
died. He resided in England, where he was greatly esteemed and
honored.
1730. Benedict XIII, pope of Rome, died. He was a Dominican of
Venice, and before his elevation bishop of Benevento, where his
palace was destroyed by an earthquake, and he narrowly escaped.
He filled the pontifical office six years, and sustained an excellent
character.
1746. Le Bourbon and La Charite, French ships, captured by Com.
Knowles in a heavy gale. The military chest belonging to the French
vessels contained £5,000.
1759. Action between the British frigate Vestal, Capt. Hood, and the
French frigate Bellona, which resulted in the capture of the latter,
with the loss of 42 killed. British loss 2 killed and 22 wounded.
1760. The neighborhood of Mt. Vesuvius overflowed by burning lava.
1760. Commodore Thourot arrived in the bay of Carrickfergus with a
43 gun ship and two sloops of war, and having landed 800 men,
attacked the town, which, with the castle, he carried after a smart
action. The French embarked a few days after, and meeting with a
British squadron, an action ensued in which Thourot and 300 of his
men were killed.
1792. Jacob Schnebbelie died at London. From the profession of a
Swiss confectioner, he rose to be one of the best draughtsmen in
England, but too intense application to his studies hastened his
death.
1796. Field Marshal Clairfait, the Austrian general, resigned, and was
succeeded by the Archduke Charles, for whom a new rank was
created, that of field-marshal-general, being the highest military rank
in the empire.
1799. Gilbert Wakefield was fined £100 and condemned to two years
confinement, for his pamphlet against the bishop of Landaff.
1805. Dominica attacked by a French squadron, which was repulsed
by the British under Gen. Provost.
1810. Action between the British ship Horatio, and French frigate
Necessity, 21 guns, which last was captured in one hour.
1812. Action between the British ship Victorious, Capt. Talbot, and
the Venitian ship Rivoli, 74 guns. The latter was captured, after an
engagement of 5 hours, with the loss of 400 killed and wounded;
British loss 42 k. 99 w.
1813. Ogdensburgh, N. Y., taken by the British.
1814. The British, about 2000 in number, under Col. Scott, crossed
over to the French mills, burnt the arsenal at Malone, N. Y., pillaged
the town and carried off some provisions. The enemy retreated in
great haste, and lost 200 men by desertion. Gen. Wilkinson
endeavored to come up with him, but was prevented by the weather.
1818. David Humphreys, an officer of the revolution, died. He was a
native of Connecticut, and successively aid to generals Putnam,
Greene and Washington. He is also known as a poet of very fair
pretensions.
1824. Eugene de Beauharnais, duke of Leuchtenberg, died. He was the
son of Josephine Tacher de la Pagerie, afterwards wife of Napoleon.
He distinguished himself in the army, and was made viceroy of Italy,
the government of which he managed with great prudence. With the
fall of Napoleon he lost his titles and offices, but was in a measure
indemnified by the articles of Fontainbleau, the congress of Vienna,
and the duke of Bavaria. Under a simple exterior prince Eugene
concealed a noble character and great talents.
1831. Robert Hall died at Bristol, England; a very eminent man and a
celebrated preacher.
1838. Anthony Isaac Sylvestre de Sacy died, aged 80; renowned
principally for his extensive critical knowledge, particularly in oriental
languages and literature; esteemed, in this department of learning,
the first scholar of his age.
1839. Charles Rossi, a celebrated sculptor, died at London, aged 77.
1840. William Frend, died in London, aged 84; a writer on algebra,
taxation and various other subjects.
1845. Sydney Smith, canon of St. Paul's in London, and well known to
Pennsylvania repudiators, died in London.
1855. Charles Roger Dod, assistant editor of The Times newspaper,
died aged 62.
1856. The students of South Carolina college, armed with rifles,
surrendered to the governor of the state and a posse of armed
citizens.

FEBRUARY 22.

1371. David II of Scotland died. He was the son of Robert Bruce, was
taken prisoner by the English in 1346 and detained in the tower 10
years.
1609. Ferdinand I, grand duke of Tuscany, died. He was eminent for
the wisdom and energy of his government.
1630. The first day of public thanksgiving in Massachusetts. The day
had been appointed, for a general fast. No ship had arrived in a
great length of time, and their stock of provisions was nearly
exhausted. At this critical moment a vessel arrived from England
laden with provisions; and they immediately changed the day of
public fasting into one of public feasting. And it is quite probable
that the day was observed with something more than an outward
show of thanksgiving on that occasion.
1644. Charles I, having summoned a royal parliament, they met this
day at Oxford to the number of 44 lords and 118 commoners; the
session was opened with a speech from the king.
1674. Jean Chapelain, died. He attracted the notice of Cardinal
Richelieu by a preface which he wrote for the Adonis of Marini.
Chapelain was talented and learned, obsequious and discreet, and
these made his fortune, for he could be of service to the cardinal,
who had the weakness to set up for a bel esprit. He became one of
the first members of the Academie Francaise, received a large
pension, and became the oracle of the poets of the time, and was
universally esteemed. It would have been better if he himself had
not set up for a poet. In 1630 he commenced an epic, La Pucelle. It
was announced twenty years before its appearance, and the public
expectation was greatly disappointed; it soon became an object of
ridicule.
1717. Great snow in New England; 6 feet deep in Boston. It
commenced on the 20th, on which day Dr. Brattle was buried, and
many who attended his funeral were unable to get home for several
days.
1731. Frederick Ruysch, an eminent Dutch anatomist, died.
1732. Birthday of George Washington. He was the third son of
Augustus Washington, and was born at Bridges Creek, Va.
1744. Partial action off Toulon between the combined French and
Spanish fleets under M. De Court, and the British fleet under
admirals Matthews and Rowley. The Poder, a Spanish 60 gun ship,
was burnt. British loss 92 killed, 185 wounded.
1746. William Couston, director of the French academy of painting
and sculpture, died.
1766. British stamp act repealed.
1770. A mob, principally boys, attacked the house of Mr. Richardson,
Boston, owing to his having attempted to remove the mark set
against the house of one Lille, who had contravened the non-
importation law. Richardson fired upon the mob and killed
Christopher Snider, a boy 11 years of age, who was recorded in the
public prints as the first martyr to American liberty.
1780. An ox roasted on the ice at Philadelphia, the ice being 17
inches thick.
1782. The island of Montserrat surrendered to the French, under
Count De Grasse.
1787. The assembly of notables of France assembled.
1797. The French made a descent on Wales.
1806. James Barry, an Irish painter, died. He was patronized by Burke.
His greatest effort is a series of allegorical pictures in possession of
the Society of arts, London.
1809. Louis, count of Cobentzel, died at Vienna. He was born at
Brussels 1753. He entered into the military service of Austria at an
early age, and was employed as an embassador to the court of
Copenhagen before he had attained his twentieth year; and was
continued in that capacity at some one of the European courts
during the whole of his life.
1810. Charles Brockden Brown, an American novelist, died aged 39.
He holds a distinguished rank among American authors.
1810. The island of St. Eustatia surrendered by the Dutch to the
British.
1811. The British ships Cerberus and Active captured 22 vessels
from Otranto, with provisions and troops.
1812. Ogdensburg, New York, attacked by the British and Indians
under Frazer and McDonnell. Forsythe was compelled to evacuate it.
The British took 12 cannons, 1400 stands of arms, 300 tents, some
provisions, and all the vessels and boats. American loss 27; British
loss 64 killed and wounded.
1814. Blucher defeated by the French under Boyer; the former set
the bridge and town of Mery on fire and fled.
1816. Adam Ferguson, an eminent Scottish writer, died. He was sent to
America as secretary to the mission in 1778 to effect a reconciliation
between the two countries.
1835. Jane Jarmon died near Wadesborough, N. C., aged 105.
1836. Joice Heth died at New York; a blind negro woman, who had
been carried about the country as a show, under the pretence that
she was 162 years of age and had been the nurse of General
Washington. On a post mortem examination it was found that she
could not have been more than 80 years old.
1841. A land slide in the commune of Gregano in Italy, by which 113
persons lost their lives. The town of Reggio, in Calabria, nearly
destroyed by an earthquake.
1855. The San Francisco bankers suspended payment, causing a
panic.

FEBRUARY 23.

303. The soldiers of Diocletian demolished the principal church of


Nicomedia, and committed the sacred volumes to the flames.
1447. Gabriel Condoimero (Pope Eugenius IV), died. He was elected to
the papal throne 1431, afterwards unjustly deposed, and again
restored.
1545. Francis de Bourbon, Count Enghien, killed. He was a celebrated
general in the service of Francis I, and was killed by accident.
1555. Thomas Wyat beheaded. He took the lead in an unsuccessful
insurrection against the "bloody Queen Mary."
1589. Andrew Dudith, a Hungarian divine, died. He was employed by
Ferdinand II, in important affairs of state, wrote on physic, poetry,
&c., and was a highly esteemed character.
1603. Andreas Cæsaralpinus, an Italian philosopher and physician, died
at Rome.
1619. Bartholomew Ziegenbalg, a celebrated German missionary, died.
He was sent to India by the king of Denmark, but meeting with
some opposition from the Danish authorities there, he placed himself
under the countenance of the British East India company, published
a dictionary of the Malabar language, and was fulfilling the object of
his mission with great zeal and success, when he was suddenly
interrupted by death at the age of 36.
1679. Thomas Goodwin, a theological writer of the puritan school,
died, aged 80. He was one of the members of the assembly of
divines at Westminster, and attended Cromwell on his death bed.
1717. Magnus Steinbock, an illustrious Swede, died at
Frederickshaven. He distinguished himself by his valor under Charles
XII, and in the absence of the king from Sweden, he managed the
affairs of the government with uncommon wisdom and moderation.
1750. A brilliant borealis appeared at Cork, about seven in the
evening. The tide at the same time rose far above its ordinary
height.
1766. Stanislaus I, king of Poland and elector of Saxony, died. He was
an author, and a good ruler, though an unfortunate one.
1775. The daily consumption of pulque, the fermented juice of the
maguei, in the city of Mexico, according to the custom house record,
was 6000 arrobas (150,000 lbs.), and the daily consumption of
tobacco for smoking, was reckoned at 1250 crowns. The population
then exceeded 200,000.
1779. St. Vincents surrendered with considerable stores, to the
Americans under Col. Clarke. British taken, 79.
1780. Action between the British ship Resolution, 74 guns, and
French ship La Prothee, 64 guns, which resulted in the capture of
the latter.
1792. Joshua Reynolds, the English painter, died in London, aged 69.
He rapidly acquired opulence by his profession, and on the
institution of the royal academy, was elected president. The lectures
which he delivered before this society have become a standard work.
1796. Nicholas Stofflet, the celebrated Vendean chief, shot at
Angers. At the beginning of the French revolution he was a private
soldier, but became one of the most intrepid and daring chiefs of the
royal army of La Vendee, and had been in no less than 150 actions,
10 of them pitched battles; and in more than 100 of them he proved
victorious. He met his fate with characteristic fortitude.
1796. Bonaparte appointed commander-in-chief of the army of Italy.
1798. Rockland county N. Y., erected.
1798. The pope withdrew from Rome to Sienna, having been
deprived of his temporal possessions by the French.
1800. Joseph Warton, an English prelate, died. He was also an
ingenious poet and critical writer.
1805. British frigate Leander, fell in with and captured the Ville de
Milan, and her prize the Cleopatra, captured a few days previous.
(See 17th.)
1814. The blacks under Christophe, took by assault fort Sabourin, in
St. Domingo.
1821. The counties of Monroe and Livingston N. Y., erected.
1822. Benavides executed; an outlaw and pirate, who for several
years proved the scourge of the southern part of Chili, where he
perpetrated the most horrid cruelties upon every age and sex that
fell in his way. In 1818 he had been condemned to be shot, and was
supposed to have been killed; but although shockingly wounded and
left for dead, he recovered and became a fiend incarnate.
1827. Walter Scott disclosed himself publicly for the first time as the
Great Unknown, at a dinner of the Edinburgh theatrical fund, himself
in the chair.
1831. Gertrude Elizabeth Maria, a favorite German vocalist, celebrated
the anniversary of her 83d year at Reval, where Goethe offered her
a poetical tribute.
1836. Battle of fort Alamo in Texas, in which the Mexican army of
4000, who made the assault, were repulsed.
1840. James Maury died at New York, aged 95. He was the first consul
from the United States to Liverpool, to which office he was
appointed by Washington, and which he held for nearly half a
century.
1847. Battle of Buena Vista in which the Mexican army, numbering
more than four to one of the Americans, was completely defeated.
Many of the American officers were slain.
1848. John Quincy Adams, ex-president of the United States, died in
the Capitol at Washington. It may well be questioned whether any
statesman in the world was better informed.
1851. Joanna Baillie, the Scottish poetress, died, aged 89. She was
born at Bothwell, near the Clyde, and lived in seclusion with her
maiden sister.
1854. The steamer from Stonington arrived at New York, having
been detained in the sound by ice during three days.
1856. A freshet commenced in the Ohio, which caused great
destruction of property, among which were several steam boats.

FEBRUARY 24.

303. Diocletian issued the first general edict of persecution against


the Christians, by which all their religious edifices in the empire were
to be leveled to their foundations, and the church property
confiscated and sold to the highest bidder. This abominable decree
was instantly torn from its column by a Christian of rank, who for his
audacity was burnt or rather roasted, by a slow fire.
1383. John Wickliffe presented seven articles to parliament
containing his doctrines.
1468. John Gutenberg, the inventor of printing, died. In connection
with Faust he contributed greatly to the improvement of the art,
then in a very rude state.
1495. Jem, son of Bayazid I the Osman sultan, died. He was defeated
by his brother in a contest for the throne, and took refuge with the
knights of St. John at Rhodes, who sent him to France, where he
was kept in confinement several years, and then delivered up to the
pope, Alexander VI, by whom he was poisoned.
1525. Battle of Pavia in Italy. The imperialists under Bourbon,
Pescara and Lannoy defeated the French and captured their king,
Francis I, whom they sent prisoner to Madrid. The king fought with
heroic valor, killing 7 men with his own hand.
1540. Charles V of Germany entered Ghent, which had been in a
state of insurrection; 26 of the principal citizens were put to death.
He was born at this place on this day 1500.
1541. Pedro de Valdivia, having been sent by Pizarro with 200
Spaniards and a numerous body of Peruvians to Chili for the purpose
of settling such provinces as he should conquer, succeeded in
overcoming the resistance of the natives and founded the city of
Santiago.
1563. Francis of Lorraine, duke of Guise, assassinated. He
distinguished himself in the wars with Charles V and the English; and
in the reigns of Henry II and Francis II of France, completely
governed the kingdom. After the death of Francis, he espoused the
side of the catholics in the civil wars.
1587. Thomas Cavendish passed the straits of Magellan.
1645. A treaty of peace, which was begun at Uxbridge on the 30th
January, between the commissioners of Charles I, and those of the
parliament, was broken off.
1665. A Dutch impostor whipped thro' the streets of London;
possibly only a little eccentric.
1665. Deerfield, Mass., purchased of the Indians. The deed, which is
still extant, was given "for the use and behoof of Major Eleazar
Lusher, Ensign Daniel Fisher, and other English at Dedham, their
associates and successors," by Chauk alias Chague, the sachem of
Pocomptuck, and his brother Wassahoale, and witnessed by
Wequonnock. It reserves to the Indians the right of fishing in the
rivers, hunting wild animals, and gathering nuts. It is capable of
proof, that the early settlers in New England, as well as New York,
made it a matter of course to purchase the lands upon which they
settled, in nearly all instances, and at prices which were considered
a fair equivalent at the time by the Indians. It may be mentioned as
a matter of curiosity, that the salary of the first minister settled at
this place was £60, to be paid in wheat at 3s. 6d., peas at 2s. 6d.,
corn at 2s. per bushel, and salted pork at 2½d. per pound.
1667. Thomas Adams died. He was born at Wem in England; went to
London, where he established himself in business as a draper; and in
1645 rose to the high honor of lord mayor of that city.
1676. Attack on Medfield, Mass., by a party of about 300 Indians.
The loss of Lancaster, a short time previous, had put the neighboring
towns on their guard, and Medfield had obtained a small garrison of
soldiers for greater security, although within 22 miles of Boston. The
Indians during the night had secreted themselves, according to
custom, under the fences and behind trees about the villages, so
that the people were shot down as they came out of their doors and
their houses immediately set on fire. The soldiers being lodged in
different parts of the town, could not get together until about 50
buildings were on fire. Some were killed as they attempted to pass
to their neighbors for shelter, and in some instances, the husband
flying with one child and the wife with another, one of them fell into
the hands of the savages or was killed, while the other escaped. Two
or three discharges of a field piece put the whole horde to flight,
who as they passed the river fired the bridge to prevent pursuit.
Loss 18 killed, and many wounded and carried away for torture.
(Holmes says Feb. 21.)
1684. Birthday of Handel, the music composer, at Halle.
1684. Boundary line between New York and Connecticut partially
run.
1716. The earls of Derwentwater and Kenmuir beheaded on Tower hill,
for treason in favoring the cause of the Pretender.
1721. John Sheffield, duke of Buckingham, died; a celebrated
general, critic and poet.
1724. A great storm attended with an uncommon tide, was
experienced in New England. The tide in some places rose ten feet
higher than it was ever known before, and rendered many of the
streets of Boston navigable.
1740. Providential delivery from death of a society of monks at
Palermo.
1752. Isaac Wood, an English painter, died. His principal pieces are in
oil and black lead upon vellum.
1758. Battle of Hoya in Westphalia, between the allies and French.
1762. Tremendous hurricane and fall of snow in England. Nearly 50
persons perished in the fields, and several whales were driven on
the Essex and Kentish coasts.
1766. Stanislaus, the last duke of Lorrain and Bar, as an independent
Duchy, died in consequence of burns from his robes de chambre
having accidentally caught fire.
1777. William Dodd, an English divine, convicted of forgery, and
sentenced to be hanged.
1777. Joseph, king of Portugal, died. He was of the house of
Braganza, ascended the throne in 1750; his reign was turbulent and
unfortunate.
1781. Edward Capell died; known as the editor of an edition of
Shakspeare in 10 vols., and 4 large quarto vols. of "Notes and
various readings of Shakspeare."
1785. Charles Bonaparte, father of Napoleon, died, leaving his family
in straightened circumstances.
1797. Resumption of hostilities in Italy between the French and
Austrians.
1799. George Christopher Lichtenberg, a famous German writer, died.
His commentary on Hogarth is said of itself to immortalize his fame.
1809. Drury-lane theatre burnt. It had been previously burnt, and
rebuilt 1671 by Sir Christopher Wren at a cost of £200,000.
1810. Henry Cavendish, an English philosopher, died. He made the
important discovery of the composition of water. Of diffident and
retiring manners, he devoted his days to experiments and
improvements in the arts and sciences. It has been said that he was
the richest among the learned, and the most learned among the rich
men of his time. He left a fortune of £5,000,000.
1813. Action between United States sloop Hornet, Capt. Lawrence,
and British man-of-war brig Peacock, Capt. Peake, off Demarara. The
action commenced at half past 5 P. M. and continued 15 minutes,
when the Peacock showed signals of distress. Exertions were made
to keep the vessel afloat till the prisoners could be got off, but she
sunk carrying down 13 of her crew and 3 Americans. The loss of the
crew of the Peacock could not be ascertained; but the captain was
killed in the latter part of the engagement, and the vessel was
literally cut to pieces. The Hornet lost 1 killed and 4 wounded; and
the vessel received trifling damage, except in her rigging.
1815. Robert Fulton died, aged 50. He was born at Little Britain, Pa.,
and early discovered a genius for painting and mechanics; and he
subsequently studied painting in London, under Benjamin West. He
also resided several years in Paris; after which he returned to
America, and presented to the world the phenomenon of the steam
boat.
1821. John Keats, an English poet, died, aged 25. He was of humble
origin, but was possessed of a fine genius. His productions were
made the subject of severe and unmerited criticism by Gifford, who
had leaped from a cobbler's bench into an editor's stool, and
presided over the pages of the Quarterly Review. These gross
attacks preyed upon his mind and hastened his death.
1821. Iturbide issued his proclamation, called the plan of Iguala, for
the pacification of the state of Mexico. It contemplated the
independence of Mexico, and still to preserve its union with Spain.
1826. Richard Dale, an American naval officer, died. He was born in
Virginia, 1756, and at the age of 12 went to sea. During the war of
the revolution he was captured, and imprisoned, but found means to
escape, and joined the celebrated Paul Jones. Under Jones he
distinguished himself in the sanguinary and desperate engagement
between the Bon Homme Richard and the British frigate Serapis, and
was the first who reached the deck of the latter when she was
boarded and taken. In 1802 he settled in Philadelphia, where he
passed the remainder of his days.
1828. Jacob Brown, who acted so prominent a part in the war of 1812
between England and the United States, and for some time
commander-in-chief of the United States army, died at Washington.
1838. Carl Heinrich Ludwig Politz, died at Leipsic. He was professor in
the university, and an eminent writer on statistics, history and
politics.
1843. John Owens, a soldier of the old French war and also of the
American revolution, died, aged 107.
1848. Revolution at Paris.
1852. David Kennison, the last of the Boston tea party, died at
Chicago, aged 117.
1854. Robert Armstrong died, aged 64; proprietor of the Washington
Union newspaper.
1854. At Niagara falls two men fell from the suspension bridge, a
distance of 240 feet and were dashed to pieces.

FEBRUARY 25.

52 B. C. Pompey elected sole consul of Rome.


1030. Adalbero, a French ecclesiastic, died. He has left a character
suited to bold and unscrupulous intrigue.
1464. The Lancasterians defeated by the Yorkists at Heagley Moor,
the white rose triumphing over the red.
1523. William Lily, an English grammarian, died at London of the
plague. He is highly praised by Erasmus, who revised the syntax of
his grammar, for his uncommon erudition in the languages, and
admirable skill in the instruction of youth.
1601. Robert Devereux, earl of Essex, executed. He obtained the favor
of the queen, Elizabeth, and distinguished himself on many
occasions. But having committed some indiscretions which required
reprimanding, his pride was wounded, which led him to open
rebellion. His fate has formed the subject of four tragedies.
1634. Albert, count Wallenstein, generalissimo of the Austrian army
during the thirty years war, assassinated.
1643. A barbarous massacre in the night of the Indians who were
encamped at Pavonia, opposite the Dutch fort of New Amsterdam,
instigated by Gov. Kieft. About 80 Indians lost their lives, and many
enormities were enacted by the Dutch.
1676. The Indiana assaulted the town of Weymouth, Mass., and
burned several houses and barns. This was a disastrous year with
the colonists. The Indians had risen in their utmost power, with the
determination of utterly extirpating the English, and almost every
day witnessed the smoke of town or cluster of dwellings on fire.
1703. Daniel de Foe prosecuted as the author of a book entitled, The
shortest way with the dissenters, and his book burned by the
hangman.
1712. Nicholas Catinat, an illustrious French general under Louis XIV,
died.
1713. Frederick I, of Prussia, died. He was elector of Brandenburg,
and ambitious of raising his duchy into a kingdom. To accomplish
this object, he joined Leopold, emperor of Germany, in a war against
several states.
1723. Christopher Wren, the English architect, died, aged 91. He built
St. Paul's and fifty other churches and monuments, which had been
destroyed by the great fire of 1666.
1724. Pope Innocent XIII died.
1754. Richard Mead, an eminent English physician and patron of
learning, died, aged 81. His library sold for about $75,000. His
income from his profession was about $25,000 a year.
1761. Joseph Francis Desmahis, a French author of great celebrity,
died.
1768. Mangalore, a seaport belonging to Hyder Ally, taken by the
British.
1776. Battle of Trenton. The American army under Washington
crossed the Delaware in the night during a violent storm of snow
and rain, and attacked the British on the north and west parts of the
town. A detachment had been ordered to cross the river and secure
a bridge to prevent the escape of the enemy; but owing to the
extreme difficulty of crossing, this part of the plan failed, and about
500 escaped. British loss 20 killed, 1000 prisoners; American loss 2
killed, 2 frozen, 5 wounded.
1779. The splendid bridge at Puerto Santo, in Spain, fell and killed a
great number of persons while the priests were in the act of
consecrating it.
1781. Battle near Haw river in North Carolina, between the
Americans under Pickens and Lee, and a considerable body of
royalists under Col. Pyle. The latter were cut to pieces, without the
loss of a man by the former.
1781. The French and Spanish fleets encountered a furious storm off
cape Francois in the West-Indies. Several ships sunk or foundered,
and about 2200 men perished.
1782. Denmark acknowledged the independence of the United
States.
1798. The French under Brune entered the canton of Berne in
Switzerland.
1799. El Arish in Egypt surrendered to the French under Bonaparte.
1805. William Buchan, an eminent Scottish physician, died near
London. He was educated for the pulpit, but made choice of the
medical profession, which he pursued during a long life. In 1771 he
published his Domestic Medicine; it has been attended with a degree
of success scarcely equaled by any other book in our language, and
is translated into every European tongue.
1807. Battle of Peterswalde, between the French and Russians, in
which the latter were defeated, with the loss of their general, Baron
De Korff, his staff and 400 men prisoners.
1814. Action between the British frigate Erotas and French frigate
Clorinde, 44 guns. The captain of the Erotas and 4 men were
wounded and 22 killed. The Clorinde was captured the next day by
the British ships Dryades and Achades, her loss supposed to have
been 120 men.
1816. A number of sailors belonging to the American squadron in
the Mediterranean, having been permitted to go on shore at Port
Mahon, were attacked by the Spanish guard and several killed and
wounded.
1816. Frederick William Bulow, count von Dennewitz, a Prussian
general, died. He is famous for his victories in the last French and
German war, the art of which he had learnt scientifically in early
youth. He was also devoted to literature and the fine arts, and
esteemed as a citizen and a man.
1817. Schooner Ocean of New York sunk at sea. Isaac Roget, a
merchant of high standing in New York, was convicted in conjunction
with others, of having loaded her at Havre de Grace with 97 boxes
of stones, with a view to defraud the insurance officers of $58,000.
1819. Francesco Manuel, a Portuguese poet, died. His opinions being
rather too liberal for the times, he was summoned to appear before
the inquisition, but instead of obeying the mandate he resisted the
officer sent to arrest him, and fled to Paris, where he resided till his
death. It has been said of him that no poet or writer since the time
of Camoens had done so much for the language.
1822. William Pinckney, a distinguished American statesman, died. It
is said that he possessed almost unequaled legal science and
eloquence.
1829. A violent hurricane in the island of Barbadoes, by which the
whole of the eastern end of the island was devastated, and great
damage done to the shipping.
1831. The Poles defeated near the walls of Warsaw by the Russians,
with the loss of 5000 men. Russian loss 4,500.
1841. Philip P. Barbour, an eminent American statesman and judge,
died at Washington, aged 60.
1841. The Bogue forts and the city of Canton captured by the
British. The number of Chinese killed and wounded was very great;
1000 were captured. Canton was almost deserted by its inhabitants.
1850. Tau Kwang, emperor of China, died, aged 69.
1856. Peace congress met at Paris, and agreed upon an armistice till
the 31st of March.

FEBRUARY 26.

747 B. C. The era of Narbonassar (a king of Babylon) called also the


Egyptian year, began on the first day of the month Thoth,
corresponding with this day in the Julian calendar. The years are
vague, containing 365 days without intercalation, so that in the year
31 B. C. the beginning of the year fell on the 29th August, and at the
end of 1460 years it ran through all the Julian months.
The Mexican year began also on the 26th February. It is also certain
that the Mexican calendar conformed greatly with the Egyptian.
387. In consequence of a sermon preached by John Chrysostom on
drunkenness and blasphemy, a sedition broke out at Antioch. The
statues of Theodosius and the imperial family were thrown from
their pedestals and demolished by the tumultuous citizens.
398. John Chrysostom, or the preacher with the golden mouth,
elected archbishop of Constantinople.
1426. John de Brogni died; originally a swine herd in Savoy; he
distinguished himself for learning, virtue and piety, and was raised to
the dignity of cardinal.
1512. Robert Fabyan, an English historian, died. He was brought up to
a trade, became a merchant, and an alderman of London. His
Chronicle was burnt by Wolsey.
1553. Four English noblemen, namely, Ralph Vane, Miles Partridge,
Michael Stanhope and Thomas Arundel, were executed as accomplices
to the duke of Somerset.
1611. Anthony Possevin, a Jesuit, died at Ferrara. He was
distinguished as a preacher, and employed by the pope in embassies
to different countries.
1616. Galileo appeared before Cardinal Bellarmine to renounce his
heretical opinions; and having declared that he abandoned the
doctrine of the earth's motion, and would neither defend nor teach
it, in his conversation or his writings, he was dismissed from the bar
of the inquisition.
1638. Claude Meziriac, a Jesuit, died; known as a poet in several
languages.
1686. Godfrey, count d'Estrades, died.
1696. Charles Scarborough, an eminent English physician and
mathematician, died. He succeeded Dr. Harvey as lecturer on
anatomy and surgery.
1723. Thomas d'Urfey, an English poet, died. He was a man of
sparkling talents, but his poetic and dramatic pieces are now
forgotten. His Pills to Purge Melancholy is yet upon the shelves of
many English libraries.
1726. Emanuel Maximilian, elector of Bavaria, died. He distinguished
himself under the emperor Leopold, was placed at the head of the
Hungarian army, and made governor of the Low Countries by the
king of Spain.
1729. The British parliament resolved that it was an indignity and a
breach of privilege for any one to publish the debates or report the
proceedings of the house.
1767. Hyder Ally and the nizam of Deccan defeated by the British at
Errour, near Trincomalee, in Ceylon.
1769. William Duncombe, an English dramatic author, died. He
translated Horace.
1770. Joseph Tartini died at Padua; an Italian musician, distinguished
for his extraordinary performances on the violin.
1774. John Tice died at Hagley, England, aged 125.
1775. Gen. Gage despatched 140 soldiers under Col. Leslie to seize
the military stores collected at Salem. The people foiled the
expedition by drawing up a bridge and causing other delays till it
was too late to effect any thing, and they returned bootless.
1789. The Cayugas sold their lands to the state of New York.
1802. Alexander Geddes died at Paddington, England. He was a
catholic and is represented as a man of profound research in biblical
literature, and employed himself many years in a new translation of
the Bible, which he did not live to finish.
1807. Battle of Braunsberg in Prussian Poland, in which a division of
10,000 Russians were overthrown by the French, who took 2,000
prisoners and 16 cannon.
1810. John Dalrymple, a Scottish author, died, aged 84. He was for
many years baron of the exchequer in Scotland.
1813. Robert R. Livingston, an American statesman, died. He was one
of the committee which drew up the Declaration of Independence.
He was afterwards chancellor of the state of New York, and minister
to France. He assisted Fulton with means to carry his experiments
into effect, which gave to this country the honor of the first
successful steam boat.
1815. Bonaparte escaped from the island of Elba, accompanied by
1000 of his old guards, who had followed him into exile.
1823. John Philip Kemble died; one of the most eminent tragedians of
the British stage since the days of Garrick. He possessed talent and
learning, and was an author.
1826. John Kay, caricaturist, engraver, barber, and miniature painter,
died in Edinburgh. His small shop in Parliament close, was a great
lounging place for the idlers of the town.
1827. William Kitchener, an English physician, died. He is
distinguished for his experiments in cookery; he treated eating and
drinking as the only serious business of life, and promulgated the
laws of the culinary art, under the title of the Cook's Oracle,
professedly founded on his own practice. He possessed an ample
fortune, which enabled him to follow the bent of his eccentricities.
1831. John Bell, who gave direction and name to Bell's Weekly
Messenger at London, died.
1833. Elizabeth Pearce died in Johnson county, North Carolina, aged
111.
1833. The spasmodic cholera appeared at Havana, and in about one
month from that time had destroyed 7000 persons.
1834. Aloys Senefelder, inventor of lithography, died at Munich, aged
63.
1852. Thomas Moore, the celebrated Irish poet, died, aged 73.
1854. The gallery of the French opera house at New Orleans fell
during the performance, carrying away the second tier, by which the
occupants were precipitated into the parquette, killing 3, and badly
wounding 56 persons.
1854. Three shocks of an earthquake at Manchester, Kentucky, by
which the houses were violently shaken.
1855. Gen. Jackson's sword presented to congress by the heirs of
Gen. Armstrong.
1855. Henry Pierpont Edwards, an American judge, died at New York,
aged 46.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like