100% found this document useful (1 vote)
32 views

C Programming From Problem Analysis To Program Design 6th Edition D S Malik pdf download

The document provides information about the 6th edition of 'C++ Programming: From Problem Analysis to Program Design' by D.S. Malik, including details on its content, structure, and various programming concepts covered. It also includes links to previous and subsequent editions of the book. Additionally, it mentions the availability of the electronic version and provides contact information for customer support and permissions.

Uploaded by

tautewitryet
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
100% found this document useful (1 vote)
32 views

C Programming From Problem Analysis To Program Design 6th Edition D S Malik pdf download

The document provides information about the 6th edition of 'C++ Programming: From Problem Analysis to Program Design' by D.S. Malik, including details on its content, structure, and various programming concepts covered. It also includes links to previous and subsequent editions of the book. Additionally, it mentions the availability of the electronic version and provides contact information for customer support and permissions.

Uploaded by

tautewitryet
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/ 90

C Programming From Problem Analysis To Program

Design 6th Edition D S Malik download

https://ebookbell.com/product/c-programming-from-problem-
analysis-to-program-design-6th-edition-d-s-malik-4334672

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

C Programming From Problem Analysis To Program Design 5th 5th Edition


D S Malik

https://ebookbell.com/product/c-programming-from-problem-analysis-to-
program-design-5th-5th-edition-d-s-malik-2336846

C Programming From Problem Analysis To Program Design 3rd Edition 3rd


Edition Barbara Doyle

https://ebookbell.com/product/c-programming-from-problem-analysis-to-
program-design-3rd-edition-3rd-edition-barbara-doyle-2416182

C Programming From Problem Analysis To Program Design 2nd Barbara


Doyle

https://ebookbell.com/product/c-programming-from-problem-analysis-to-
program-design-2nd-barbara-doyle-2444624

C Programming From Problem Analysis To Program Design 8th Edition Ds


Malik

https://ebookbell.com/product/c-programming-from-problem-analysis-to-
program-design-8th-edition-ds-malik-33556422
C Programming From Problem Analysis To Program Design 4th Edition Ds
Malik

https://ebookbell.com/product/c-programming-from-problem-analysis-to-
program-design-4th-edition-ds-malik-38548048

C Programming From Problem Analysis To Program Design 4th Edition


Barbara Doyle

https://ebookbell.com/product/c-programming-from-problem-analysis-to-
program-design-4th-edition-barbara-doyle-4178294

C Programming From Problem Analysis To Program Design 7th Edition Ds


Malik

https://ebookbell.com/product/c-programming-from-problem-analysis-to-
program-design-7th-edition-ds-malik-5163210

C Programming From Problem Analysis To Program Design 5th Edition


Barbara Doyle

https://ebookbell.com/product/c-programming-from-problem-analysis-to-
program-design-5th-edition-barbara-doyle-10810090

C Programming From Problem Analysis To Program Design Barbara Doyle

https://ebookbell.com/product/c-programming-from-problem-analysis-to-
program-design-barbara-doyle-5498550
C++ PROGRAMMING:
FROM PROBLEM ANALYSIS TO PROGRAM DESIGN

SIXTH EDITION

D.S. MALIK

Australia  Brazil  Japan  Korea  Mexico  Singapore  Spain  United Kingdom  United States
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.
C++ Programming: From Problem Analysis
to Program Design, Sixth Edition For product information and technology assistance, contact us at
Cengage Learning Customer & Sales Support,
D.S. Malik www.cengage.com/support
For permission to use material from this text or product,
Executive Editor: Marie Lee submit all requests online at www.cengage.com/permissions
Acquisitions Editor: Brandi Shailer Further permissions questions can be emailed to
Senior Product Manager: Alyssa Pratt [email protected]
Associate Product Manager: Stephanie
Lorenz Library of Congress Control Number:
Content Project Manager: Matthew ISBN- : -- - -
Hutchinson
Cengage Learning
Art Director: Faith Brosnan
Channel Center Street
Print Buyer: Julio Esperas Boston, MA
Cover Designer: Roycroft Design/ USA
www.roycroftdesign.com Some of the product names and company names used in this
Cover Photo: ª Masterfile Royalty Free book have been used for identification purposes only and may
Proofreader: Andrea Schein be trademarks or registered trademarks of their respective
manufacturers and sellers.
Indexer: Elizabeth Cunningham
Compositor: Integra Software Services Any fictional data related to persons or companies or URLs used
throughout this book is intended for instructional purposes only.
At the time this book was printed, any such data was fictional
and not belonging to any real persons or companies.
ª Cengage Learning
Cengage Learning reserves the right to revise this publication
ALL RIGHTS RESERVED. No part of this work
and make changes from time to time in its content without
covered by the copyright herein may be
notice.
reproduced, transmitted, stored or used in any
form or by any means graphic, electronic, or The programs in this book are for instructional purposes only.
mechanical, including but not limited to They have been tested with care, but are not guaranteed
photocopying, recording, scanning, digitizing, for any particular intent beyond educational purposes. The
taping, Web distribution, information author and the publisher do not offer any warranties or
networks, or information storage and retrieval representations, nor do they accept any liabilities with respect
systems, except as permitted under Section to the programs.
or of the United States Copyright
Cengage Learning is a leading provider of customized
Act, without the prior written permission of
learning solutions with office locations around the globe,
the publisher.
including Singapore, the United Kingdom, Australia, Mexico,
Brazil and Japan. Locate your local office at:
www.cengage.com/global
Cengage Learning products are represented in Canada
by Nelson Education, Ltd.
To learn more about Cengage Learning, visit
www.cengage.com
Purchase any of our products at your local college store or at
our preferred online store www.CengageBrain.com

Printed in the United States of America


1 2 3 4 5 6 7 16 17 16 15 14 13 12
TO

My Daughter

Shelly Malik
This page intentionally left blank
B RIEF C ONTENTS

PREFACE xxix

1. An Overview of Computers and Programming Languages 1

2. Basic Elements of C++ 27

3. Input/Output 121

4. Control Structures I (Selection) 183

5. Control Structures II (Repetition) 259

6. User-Defined Functions 335

7. User-Defined Simple Data Types, Namespaces,


and the string Type 451

8. Arrays and Strings 505

9. Records (structs) 591

10. Classes and Data Abstraction 629

11. Inheritance and Composition 709

12. Pointers, Classes, Virtual Functions, and Abstract Classes 781

13. Overloading and Templates 853

14. Exception Handling 943

15. Recursion 985

16. Searching, Sorting, and the vector Type 1015

17. Linked Lists 1057

18. Stacks and Queues 1149


vi | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

APPENDIX A Reserved Words 1249

APPENDIX B Operator Precedence 1251

APPENDIX C Character Sets 1253

APPENDIX D Operator Overloading 1257

APPENDIX E Additional C++ Topics 1259

APPENDIX F Header Files 1281

APPENDIX G Memory Size on a System and Random


Number Generator 1291

APPENDIX H Standard Template Library (STL) 1293

APPENDIX I Answers to Odd-Numbered Exercises 1335

INDEX 1371
TABLE OF C ONTENTS

Preface xxix

AN OVERVIEW OF COMPUTERS AND PROGRAMMING


1 LANGUAGES 1
Introduction 2

A Brief Overview of the History of Computers 2

Elements of a Computer System 3


Hardware 4
Central Processing Unit and Main Memory 4
Input /Output Devices 5
Software 6

The Language of a Computer 6

The Evolution of Programming Languages 8

Processing a C++ Program 10

Programming with the Problem


Analysis–Coding–Execution Cycle 12

Programming Methodologies 20
Structured Programming 20
Object-Oriented Programming 20

ANSI/ISO Standard C++ 22

Quick Review 22

Exercises 24
viii | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

BASIC ELEMENTS OF C++ 27


2 A Quick Look at a C++ Program 28

The Basics of a C++ Program 34


Comments 34
Special Symbols 35
Reserved Words (Keywords) 36
Identifiers 36
Whitespaces 37

Data Types 37
Simple Data Types 38
Floating-Point Data Types 41

Data Types and Variables 42

Arithmetic Operators, Operator Precedence,


and Expressions 43
Order of Precedence 46
Expressions 48
Mixed Expressions 49

Type Conversion (Casting) 51

string Type 53

Variables, Assignment Statements, and Input


Statements 54
Allocating Memory with Constants and Variables 54
Putting Data into Variables 57
Assignment Statement 57
Saving and Using the Value of an Expression 61
Declaring and Initializing Variables 62
Input (Read) Statement 63
Variable Initialization 66

Increment and Decrement Operators 70

Output 72

Preprocessor Directives 79
namespace and Using cin and cout in a Program 80
Using the string Data Type in a Program 81
Table of Contents | ix

Creating a C++ Program 81

Debugging: Understanding and Fixing Syntax Errors 85

Program Style and Form 89


Syntax 89
Use of Blanks 90
Use of Semicolons, Brackets, and Commas 90
Semantics 90
Naming Identifiers 90
Prompt Lines 91
Documentation 92
Form and Style 92

More on Assignment Statements 94

Programming Example: Convert Length 96

Programming Example: Make Change 99

Quick Review 103

Exercises 105

Programming Exercises 114

INPUT/OUTPUT 121
3 I/O Streams and Standard I/O Devices 122
cin and the Extraction Operator >> 123

Using Predefined Functions in a Program 128


cin and the get Function 131
cin and the ignore Function 133
The putback and peek Functions 134
The Dot Notation between I/O Stream Variables and I/O
Functions: A Precaution 137

Input Failure 138


The clear Function 140
x | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

Output and Formatting Output 142


setprecision Manipulator 142
fixed Manipulator 143
showpoint Manipulator 144
setw 147

Additional Output Formatting Tools 149


setfill Manipulator 149
left and right Manipulators 151

Input/Output and the string Type 153

Debugging: Understanding Logic Errors and Debugging


with cout Statements 154

File Input/Output 157

Programming Example: Movie Tickets Sale and


Donation to Charity 161

Programming Example: Student Grade 167

Quick Review 170

Exercises 171

Programming Exercises 177

CONTROL STRUCTURES I (SELECTION) 183


4 Control Structures 184

Relational Operators 185


Relational Operators and Simple Data Types 186
Comparing Characters 187
Relational Operators and the string Type 188

Logical (Boolean) Operators and Logical Expressions 190


Order of Precedence 192
int Data Type and Logical (Boolean) Expressions 195
bool Data Type and Logical (Boolean) Expressions 196

Selection: if and if...else 196


One-Way Selection 197
Two-Way Selection 200
Table of Contents | xi

Compound (Block of) Statements 203


Multiple Selections: Nested if 204
Comparing if...else Statements with a Series of if
Statements 206
Short-Circuit Evaluation 207
Comparing Floating-Point Numbers for Equality:
A Precaution 208
Associativity of Relational Operators: A Precaution 209
Avoiding Bugs by Avoiding Partially Understood Concepts
and Techniques 211
Input Failure and the if Statement 214
Confusion between the Equality Operator (==) and the
Assignment Operator (=) 217
Conditional Operator (?:) 219
Program Style and Form (Revisited): Indentation 219

Using Pseudocode to Develop, Test, and Debug


a Program 220

switch Structures 223


Avoiding Bugs by Avoiding Partially Understood Concepts
and Techniques (Revisited) 229

Terminating a Program with the assert Function 231

Programming Example: Cable Company Billing 233

Quick Review 239

Exercises 240

Programming Exercises 251

CONTROL STRUCTURES II (REPETITION) 259


5 Why Is Repetition Needed? 260

while Looping (Repetition) Structure 261


Designing while Loops 263
Case 1: Counter-Controlled while Loops 264
Case 2: Sentinel-Controlled while Loops 268
Telephone Digits 271
xii | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

Case 3: Flag-Controlled while Loops 273


Number Guessing Game 274
Case 4: EOF-Controlled while Loops 277
eof Function 277
More on Expressions in while Statements 282

Programming Example: Fibonacci Number 283

for Looping (Repetition) Structure 287

Programming Example: Classifying Numbers 295

do...while Looping (Repetition) Structure 298


Divisibility Test by 3 and 9 301
Choosing the Right Looping Structure 303

break and continue Statements 303

Nested Control Structures 305

Avoiding Bugs by Avoiding Patches 310

Debugging Loops 313

Quick Review 314

Exercises 315

Programming Exercises 328

USER-DEFINED FUNCTIONS 335


6 Predefined Functions 336

User-Defined Functions 340

Value-Returning Functions 341


Syntax: Value-Returning function 343
Syntax: Formal Parameter List 343
Function Call 343
Syntax: Actual Parameter List 344
return Statement 344
Syntax: return Statement 344
Function Prototype 348
Syntax: Function Prototype 349
Table of Contents | xiii

Value-Returning Functions: Some Peculiarities 350


More Examples of Value-Returning Functions 352
Flow of Execution 361

Void Functions 364

Value Parameters 370

Reference Variables as Parameters 371


Calculate Grade 372

Value and Reference Parameters and Memory Allocation 376

Reference Parameters and Value-Returning Functions 386

Scope of an Identifier 386

Global Variables, Named Constants, and Side Effects 390

Static and Automatic Variables 395

Debugging: Using Drivers and Stubs 396

Function Overloading: An Introduction 399

Functions with Default Parameters 400

Programming Example: Classify Numbers 403

Programming Example: Data Comparison 408

Quick Review 418

Exercises 422

Programming Exercises 436

USER-DEFINED SIMPLE DATA TYPES,


7 NAMESPACES, AND THE STRING TYPE 451

Enumeration Type 452


Declaring Variables 454
Assignment 454
Operations on Enumeration Types 455
Relational Operators 455
Input /Output of Enumeration Types 456
xiv | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

Functions and Enumeration Types 459


Declaring Variables When Defining the Enumeration Type 460
Anonymous Data Types 461
typedef Statement 461

Programming Example: The Game of Rock, Paper,


and Scissors 463

Namespaces 471

string Type 476


Additional string Operations 480

Programming Example: Pig Latin Strings 490

Quick Review 494

Exercises 496

Programming Exercises 501

ARRAYS AND STRINGS 505


8 Arrays 507
Accessing Array Components 509
Processing One-Dimensional Arrays 511
Array Index Out of Bounds 515
Array Initialization During Declaration 516
Partial Initialization of Arrays During Declaration 516
Some Restrictions on Array Processing 517
Arrays as Parameters to Functions 518
Constant Arrays as Formal Parameters 519
Base Address of an Array and Array in Computer Memory 521
Functions Cannot Return a Value of the Type Array 524
Integral Data Type and Array Indices 526
Other Ways to Declare Arrays 527

Searching an Array for a Specific Item 527


Selection Sort 530

C-Strings (Character Arrays) 535


String Comparison 537
Reading and Writing Strings 539
Table of Contents | xv

String Input 539


String Output 540
Specifying Input/Output Files at Execution Time 541
string Type and Input/Output Files 541

Parallel Arrays 542

Two- and Multidimensional Arrays 543


Accessing Array Components 545
Two-Dimensional Array Initialization During Declaration 546
Two-Dimensional Arrays and Enumeration Types 546
Initialization 549
Print 550
Input 550
Sum by Row 550
Sum by Column 551
Largest Element in Each Row and Each Column 551
Passing Two-Dimensional Arrays as Parameters to Functions 552
Arrays of Strings 555
Arrays of Strings and the string Type 555
Arrays of Strings and C-Strings (Character Arrays) 555
Another Way to Declare a Two-Dimensional Array 556
Multidimensional Arrays 557

Programming Example: Code Detection 559

Programming Example: Text Processing 565

Quick Review 572

Exercises 573

Programming Exercises 584

RECORDS ( STRUCTS) 591


9
Records ( structs) 592
Accessing struct Members 594
Assignment 596
Comparison (Relational Operators) 597
Input /Output 598
xvi | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

struct Variables and Functions 598


Arrays versus structs 599
Arrays in structs 600
structs in Arrays 602
structs within a struct 604

Programming Example: Sales Data Analysis 608

Quick Review 622

Exercises 622

Programming Exercises 626

CLASSES AND DATA ABSTRACTION 629


10
Classes 630
Unified Modeling Language Class Diagrams 634
Variable (Object) Declaration 634
Accessing Class Members 635
Built-in Operations on Classes 636
Assignment Operator and Classes 637
Class Scope 637
Functions and Classes 638
Reference Parameters and Class Objects (Variables) 638
Implementation of Member Functions 639
Accessor and Mutator Functions 644
Order of public and private Members of a Class 647
Constructors 649
Invoking a Constructor 651
Invoking the Default Constructor 651
Invoking a Constructor with Parameters 651
Constructors and Default Parameters 654
Classes and Constructors: A Precaution 654
Arrays of Class Objects (Variables) and Constructors 655
Destructors 657

Data Abstraction, Classes, and Abstract Data Types 658

A struct Versus a class 660


Table of Contents | xvii

Information Hiding 661

Executable Code 665

More Examples of Classes 667

Static Members of a Class 673

Programming Example: Juice Machine 679

Quick Review 693

Exercises 695

Programming Exercises 703

INHERITANCE AND COMPOSITION 709


11
Inheritance 710
Redefining (Overriding) Member Functions
of the Base Class 713
Constructors of Derived and Base Classes 720
Destructors in a Derived Class 729
Multiple Inclusions of a Header File 730
C++ Stream Classes 731
Protected Members of a Class 733
Inheritance as public, protected, or private 733
(Accessing protected Members in the Derived Class) 734

Composition (Aggregation) 737

Object-Oriented Design (OOD) and Object-Oriented


Programming (OOP) 742
Identifying Classes, Objects, and Operations 744

Programming Example: Grade Report 745

Quick Review 766

Exercises 767

Programming Exercises 776


xviii | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

POINTERS, CLASSES, VIRTUAL FUNCTIONS,


12 AND ABSTRACT CLASSES 781
Pointer Data Type and Pointer Variables 782
Declaring Pointer Variables 782

Address of Operator (&) 783

Dereferencing Operator (*) 784

Classes, Structs, and Pointer Variables 789

Initializing Pointer Variables 792

Dynamic Variables 792


Operator new 793
Operator delete 794

Operations on Pointer Variables 798

Dynamic Arrays 800


Functions and Pointers 803
Pointers and Function Return Values 803
Dynamic Two-Dimensional Arrays 804

Shallow versus Deep Copy and Pointers 807

Classes and Pointers: Some Peculiarities 809


Destructor 809
Assignment Operator 811
Copy Constructor 812

Inheritance, Pointers, and Virtual Functions 819


Classes and Virtual Destructors 826

Abstract Classes and Pure Virtual Functions 826

Address of Operator and Classes 835

Quick Review 837

Exercises 840

Programming Exercises 849


Table of Contents | xix

OVERLOADING AND TEMPLATES 853


13
Why Operator Overloading Is Needed 854

Operator Overloading 855


Syntax for Operator Functions 856
Overloading an Operator: Some Restrictions 856
Pointer this 857
Friend Functions of Classes 861
Operator Functions as Member Functions and Nonmember
Functions 864
Overloading Binary Operators 867
Overloading the Stream Insertion (<<) and Extraction (>>)
Operators 873
Overloading the Assignment Operator (=) 878
Overloading Unary Operators 886
Operator Overloading: Member versus Nonmember 892
Classes and Pointer Member Variables (Revisited) 893
Operator Overloading: One Final Word 893

Programming Example: clockType 893

Programming Example: Complex Numbers 902

Overloading the Array Index (Subscript) Operator ([]) 907

Programming Example: newString 909

Function Overloading 915

Templates 916
Function Templates 916
Class Templates 918

Quick Review 926

Exercises 928

Programming Exercises 934


xx | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

EXCEPTION HANDLING 943


14
Handling Exceptions within a Program 944
C++ Mechanisms of Exception Handling 948
try/catch Block 948
Using C++ Exception Classes 955

Creating Your Own Exception Classes 959


Rethrowing and Throwing an Exception 968

Exception-Handling Techniques 972


Terminate the Program 972
Fix the Error and Continue 972
Log the Error and Continue 974

Stack Unwinding 974

Quick Review 978

Exercises 980

Programming Exercises 984

RECURSION 985
15
Recursive Definitions 986
Direct and Indirect Recursion 988
Infinite Recursion 988

Problem Solving Using Recursion 989


Tower of Hanoi: Analysis 999

Recursion or Iteration? 999

Programming Example: Converting a Number from


Binary to Decimal 1001

Programming Example: Converting a Number from


Decimal to Binary 1005

Quick Review 1008

Exercises 1009

Programming Exercises 1012


Table of Contents | xxi

SEARCHING, SORTING, AND THE VECTOR TYPE 1015


16 List Processing 1016
Searching 1016
Bubble Sort 1017
Insertion Sort 1021
Binary Search 1025
Performance of Binary Search 1028

vector Type (class) 1029

Programming Example: Election Results 1034

Quick Review 1049

Exercises 1050

Programming Exercises 1053

LINKED LISTS 1057


17
Linked Lists 1058
Linked Lists: Some Properties 1059
Deletion 1065
Building a Linked List 1066

Linked List as an ADT 1071


Structure of Linked List Nodes 1072
Member Variables of the class linkedListType 1072
Linked List Iterators 1073
Print the List 1079
Length of a List 1079
Retrieve the Data of the First Node 1080
Retrieve the Data of the Last Node 1080
Begin and End 1080
Copy the List 1081
Destructor 1082
Copy Constructor 1082
Overloading the Assignment Operator 1083
xxii | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

Unordered Linked Lists 1083


Search the List 1084
Insert the First Node 1085
Insert the Last Node 1086
Header File of the Unordered Linked List 1091

Ordered Linked Lists 1092


Search the List 1093
Insert a Node 1094
Insert First and Insert Last 1098
Delete a Node 1099
Header File of the Ordered Linked List 1100

Print a Linked List in Reverse Order


(Recursion Revisited) 1103
printListReverse 1105

Doubly Linked Lists 1106


Default Constructor 1109
isEmptyList 1109
Destroy the List 1109
Initialize the List 1110
Length of the List 1110
Print the List 1110
Reverse Print the List 1110
Search the List 1111
First and Last Elements 1111

Circular Linked Lists 1117

Programming Example: DVD Store 1118

Quick Review 1138

Exercises 1138

Programming Exercises 1144


Table of Contents | xxiii

STACKS AND QUEUES 1149


18
Stacks 1150
Stack Operations 1152

Implementation of Stacks as Arrays 1154


Initialize Stack 1157
Empty Stack 1158
Full Stack 1158
Push 1158
Return the Top Element 1160
Pop 1160
Copy Stack 1162
Constructor and Destructor 1162
Copy Constructor 1163
Overloading the Assignment Operator (=) 1163
Stack Header File 1164

Programming Example: Highest GPA 1168

Linked Implementation of Stacks 1172


Default Constructor 1175
Empty Stack and Full Stack 1175
Initialize Stack 1176
Push 1176
Return the Top Element 1178
Pop 1178
Copy Stack 1180
Constructors and Destructors 1181
Overloading the Assignment Operator (=) 1181
Stack as Derived from the class unorderedLinkedList 1184

Application of Stacks: Postfix Expressions Calculator 1185


Main Algorithm 1188
Function evaluateExpression 1188
Function evaluateOpr 1190
Function discardExp 1192
Function printResult 1192
xxiv | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

Removing Recursion: Nonrecursive Algorithm to


Print a Linked List Backward 1195

Queues 1199
Queue Operations 1200
Implementation of Queues as Arrays 1202
Linked Implementation of Queues 1211
Queue Derived from the
class unorderedLinkedListType 1216

Application of Queues: Simulation 1217


Designing a Queuing System 1218
Customer 1219
Server 1222
Server List 1225
Waiting Customers Queue 1230
Main Program 1232

Quick Review 1237

Exercises 1238

Programming Exercises 1245

APPENDIX A: RESERVED WORDS 1249

APPENDIX B: OPERATOR PRECEDENCE 1251

APPENDIX C: CHARACTER SETS 1253


ASCII (American Standard Code for Information
Interchange) 1253

EBCDIC (Extended Binary Coded Decimal


Interchange Code) 1254

APPENDIX D: OPERATOR OVERLOADING 1257


Table of Contents | xxv

APPENDIX E: ADDITIONAL C++ TOPICS 1259


Binary (Base 2) Representation of a Nonnegative
Integer 1259
Converting a Base 10 Number to a Binary Number
(Base 2) 1259
Converting a Binary Number (Base 2) to Base 10 1261
Converting a Binary Number (Base 2) to Octal (Base 8)
and Hexadecimal (Base 16) 1262

More on File Input/Output 1264


Binary Files 1264
Random File Access 1270

Naming Conventions of Header Files in ANSI/ISO


Standard C++ and Standard C++ 1278

APPENDIX F: HEADER FILES 1281


Header File cassert (assert.h) 1281

Header File cctype (ctype.h) 1282

Header File cfloat (float.h) 1283

Header File climits (limits.h) 1284

Header File cmath (math.h) 1286


Header File cstddef (stddef.h) 1287
Header File cstring (string.h) 1287

APPENDIX G: MEMORY SIZE ON A SYSTEM AND


RANDOM NUMBER GENERATOR 1291
Random Number Generator 1292

APPENDIX H: STANDARD TEMPLATE LIBRARY (STL) 1293


Components of the STL 1293

Container Types 1294


Sequence Containers 1294
Sequence Container: Vectors 1294
xxvi | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

Member Functions Common to All Containers 1303


Member Functions Common to Sequence Containers 1305
copy Algorithm 1306
Sequence Container: deque 1310
Sequence Container: list 1313

Iterators 1318
IOStream Iterators 1319
Container Adapters 1319

Algorithms 1323
STL Algorithm Classification 1323
STL Algorithms 1326
Functions fill and fill_n 1326
Functions find and find_if 1328
Functions remove and replace 1329
Functions search, sort, and binary_search 1331

APPENDIX I: ANSWERS TO ODD-NUMBERED


EXERCISES 1335
Chapter 1 1335

Chapter 2 1338

Chapter 3 1340

Chapter 4 1341

Chapter 5 1344

Chapter 6 1347

Chapter 7 1350

Chapter 8 1351

Chapter 9 1353

Chapter 10 1354

Chapter 11 1358

Chapter 12 1360
Table of Contents | xxvii

Chapter 13 1361

Chapter 14 1362

Chapter 15 1364

Chapter 16 1364

Chapter 17 1366

Chapter 18 1367

INDEX 1371
This page intentionally left blank
P REFACE

WELCOME TO THE SIXTH EDITION OF C++ Programming: From Problem Analysis to Program
Design. Designed for a first Computer Science (CS1) C++ course, this text provides a
breath of fresh air to you and your students. The CS1 course serves as the cornerstone of
the Computer Science curriculum. My primary goal is to motivate and excite all CS1
students, regardless of their level. Motivation breeds excitement for learning. Motivation
and excitement are critical factors that lead to the success of the programming student. This
text is a culmination and development of my classroom notes throughout more than fifty
semesters of teaching successful programming to Computer Science students.

Warning: This text can be expected to create a serious reduction in the demand for
programming help during your office hours. Other side effects include significantly
diminished student dependency on others while learning to program.

C++ Programming: From Problem Analysis to Program Design started as a collection of brief
examples, exercises, and lengthy programming examples to supplement the books that were
in use at our university. It soon turned into a collection large enough to develop into a text.
The approach taken in this book is, in fact, driven by the students’ demand for clarity and readability.
The material was written and rewritten until the students felt comfortable with it. Most of the
examples in this book resulted from student interaction in the classroom.
As with any profession, practice is essential. Cooking students practice their recipes.
Budding violinists practice their scales. New programmers must practice solving
problems and writing code. This is not a C++ cookbook. We do not simply list the
C++ syntax followed by an example; we dissect the ‘‘why’’ behind all the concepts. The
crucial question of ‘‘why?’’ is answered for every topic when first introduced. This
technique offers a bridge to learning C++. Students must understand the ‘‘why?’’ in
order to be motivated to learn.
Traditionally, a C++ programming neophyte needed a working knowledge of another
programming language. This book assumes no prior programming experience. However,
some adequate mathematics background, such as college algebra, is required.
xxx | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

Changes in the Sixth Edition


The sixth edition contains 200 new exercises, and more than 25 new programming exercises.
Earlier editions contain two chapters on user-defined functions. In this edition, without
sacrificing the rigor, these chapters are combined into one chapter so that user-defined functions
can be learned without interruption. Since Chapters 6 and 7 of earlier editions have been
combined into one chapter, the sixth edition contains one less chapter than the earlier editions.
The first part of Chapter 2 is rewritten and reorganized. Chapter 10, on searching and sorting
algorithms and the class vector is now Chapter 16. However, the selection sorting algorithm is
moved from Chapter 10 to Chapter 8 (arrays and string). So in addition to learning about array
and strings, the reader can also study a sequential search algorithm and a selection sort algorithm.
Even though additional searching and sorting algorithms are covered in Chapter 16, Chapter 16
can be studied right after studying Chapter 8. This edition also includes various new examples,
such as Examples 3-4, 3-8, 3-9, 4-8, 5-3, 5-4, 6-1, 8-4, 10-8, 11-2, 12-5, and 14-14.

Approach
The programming language C++, which evolved from C, is no longer considered an
industry-only language. Numerous colleges and universities use C++ for their first program-
ming language course. C++ is a combination of structured programming and object-oriented
programming, and this book addresses both types.
This book can be easily divided into two parts: structured programming and object-oriented
programming. The first 9 chapters form the structured programming part; Chapters 10
through 14, 17, and 18 form the object-oriented part. However, only the first six chapters
are essential to move on to the object-oriented portion.
In July 1998, ANSI/ISO Standard C++ was officially approved. This book focuses on ANSI/
ISO Standard C++. Even though the syntax of Standard C++ and ANSI/ISO Standard C++
is very similar, Chapter 7 discusses some of the features of ANSI/ISO Standard C++ that are
not available in Standard C++.
Chapter 1 briefly reviews the history of computers and programming languages. The reader can
quickly skim through this chapter and become familiar with some of the hardware components
and the software parts of the computer. This chapter contains a section on processing a C++
program. This chapter also describes structured and object-oriented programming.
Chapter 2 discusses the basic elements of C++. After completing this chapter, students
become familiar with the basics of C++ and are ready to write programs that are complicated
enough to do some computations. Input/output is fundamental to any programming
language. It is introduced early, in Chapter 3, and is covered in detail.
Chapters 4 and 5 introduce control structures to alter the sequential flow of execution.
Chapter 6 studies user-defined functions. It is recommended that readers with no prior
programming background spend extra time on Chapter 6. Several examples are provided to
help readers understand the concepts of parameter passing and the scope of an identifier.
Preface | xxxi

Chapter 7 discusses the user-defined simple data type (enumeration type), the namespace
mechanism of ANSI/ISO Standard C++, and the string type. The earlier versions of C did
not include the enumeration type. Enumeration types have very limited use; their main
purpose is to make the program readable. This book is organized such that readers can skip
the section on enumeration types during the first reading without experiencing any disconti-
nuity, and then later go through this section.
Chapter 8 discusses arrays in detail. This chapter also discusses a sequential search algorithm
and a selection sort algorithm. Chapter 9 introduces records (structs). The introduction of
structs in this book is similar to C structs. This chapter is optional; it is not a prerequisite
for any of the remaining chapters.
Chapter 10 begins the study of object-oriented programming (OOP) and introduces classes.
The first half of this chapter shows how classes are defined and used in a program. The second
half of the chapter introduces abstract data types (ADTs). This chapter shows how classes in
C++ are a natural way to implement ADTs. Chapter 11 continues with the fundamentals of
object-oriented design (OOD) and OOP and discusses inheritance and composition. It
explains how classes in C++ provide a natural mechanism for OOD and how C++ supports
OOP. Chapter 11 also discusses how to find the objects in a given problem.
Chapter 12 studies pointers in detail. After introducing pointers and how to use them in a
program, this chapter highlights the peculiarities of classes with pointer data members and
how to avoid them. Moreover, this chapter also discusses how to create and work with
dynamic two-dimensional arrays. Chapter 12 also discusses abstract classes and a type of
polymorphism accomplished via virtual functions.
Chapter 13 continues the study of OOD and OOP. In particular, it studies polymorphism in C++.
The chapter specifically discusses two types of polymorphism—overloading and templates.
Chapter 14 discusses exception handling in detail. Chapter 15 introduces and discusses recursion.
Moreover, this is a stand-alone chapter, so it can be studied anytime after Chapter 9. Chapter 16
describes various searching and sorting algorithms as well as an introduction to the vector class.
Chapters 17 and 18 are devoted to the study of data structures. Discussed in detail are linked
lists in Chapter 17 and stacks and queues in Chapter 18. The programming code developed in
these chapters is generic. These chapters effectively use the fundamentals of OOD.
Appendix A lists the reserved words in C++. Appendix B shows the precedence and
associativity of the C++ operators. Appendix C lists the ASCII (American Standard Code
for Information Interchange) and EBCDIC (Extended Binary Coded Decimal Interchange
Code) character sets. Appendix D lists the C++ operators that can be overloaded.
Appendix E has three objectives. First, we discuss how to convert a number from decimal to
binary and binary to decimal. We then discuss binary and random access files in detail.
Finally, we describe the naming conventions of the header files in both ANSI/ISO Standard
C++ and Standard C++. Appendix F discusses some of the most widely used library
routines, and includes the names of the standard C++ header files. The programs in
Appendix G show how to print the memory size for the built-in data types on your system
as well as how to use a random number generator. Appendix H gives an introduction to
xxxii | C++ Programming: From Problem Analysis to Program Design, Sixth Edition

the Standard Template Library, and Appendix I provides the answers to odd-numbered
exercises in the book.

How to Use the Book


This book can be used in various ways. Figure 1 shows the dependency of the chapters.

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7 Chapter 8*

Chapter 16 Chapter 9 Chapter 10

Chapter 11 Chapter 12 Chapter 14

Chapter 13

Chapter 15

Chapter 17

Chapter 18

FIGURE 1 Chapter dependency diagram


Preface | xxxiii

In Figure 1, dotted lines mean that the preceding chapter is used in one of the sections of the
chapter and is not necessarily a prerequisite for the next chapter. For example, Chapter 8
covers arrays in detail. In Chapters 9 and 10, we show the relationship between arrays and
structs and arrays and classes, respectively. However, if Chapter 10 is studied before
Chapter 8, then the section dealing with arrays in Chapter 10 can be skipped without any
discontinuation. This particular section can be studied after studying Chapter 8.
It is recommended that the first six chapters be covered sequentially. After covering the first
six chapters, if the reader is interested in learning OOD and OOP early, then Chapter 10 can
be studied right after Chapter 6. Chapter 7 can be studied anytime after Chapter 6.
After studying the first six chapters in sequence, some of the approaches are:
1. Study chapters in the sequence: 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18.
2. Study chapters in the sequence: 8, 10, 12, 13, 11, 15, 17, 18, 16, 15.
3. Study chapters in the sequence: 10, 8, 16, 12, 13, 11, 15, 17, 18, 14.
4. Study chapters in the sequence: 10, 8, 12, 13, 11, 15, 17, 18, 16, 14.
FEATURES OF THE BOOK

Four-color interior
design shows
accurate C++
code and related
comments.

One video is
available for each
chapter on the
optional
CourseMate that
accompanies this
text. Each video is
designed to
explain how a
program works.
More than 300
visual diagrams,
both extensive
and exhaustive,
illustrate difficult
concepts.
Numbered Examples
illustrate the key
concepts with their
relevant code. The
programming code in
these examples is
followed by a Sample
Run. An explanation
then follows that
describes what each
line in the code does.

Notes highlight
important facts
about the concepts
introduced in the
chapter.
Programming Examples are
where everything in the
chapter comes together.
These examples teach
problem-solving skills and
include the concrete stages
of input, output, problem
analysis and algorithm
design, class design, and
a program listing. All
programs are designed to
be methodical, consistent,
and user-friendly. Each
Programming Example
starts with a problem
analysis that is followed
by the algorithm design
and/or class design, and
every step of the algorithm
is coded in C++. In
addition to helping
students learn problem-
solving techniques, these
detailed programs show
the student how to
implement concepts in
an actual C++ program.
We strongly recommend
that students study the
Programming Examples
carefully in order to learn
C++ effectively. Students
typically learn much from
completely worked-out
programs. Further,
programming examples considerably reduce the students’ need for help outside the classroom and bolster the
students’ self-confidence.
Exercises further
reinforce learning
and ensure that
students have, in
fact, mastered the
material.
Programming
Exercises challenge
students to write
C++ programs with
a specified
outcome.
S UPPLEMENTAL
R ESOURCES

CourseMate
Make the most of your study time with everything you need to succeed in one place. Read
your textbook, highlight and take notes, review flashcards, watch videos, and take practice
quizzes online. Learn more at www.cengage.com/coursemate.
The C++ Programming CourseMate includes the following features:
• Videos step you through programs in each chapter, while integrated quizzes provide
immediate feedback to gauge your understanding.
• Lab Manual lets you apply material with a wealth of practical, hands-on exercises.
• Interactive Quizzes and Study Games drill key chapter concepts, while open-
ended Assignments develop critical thinking skills.
• Interactive eBook, flashcards, and more!
Instructors may add CourseMate to the textbook package, or students may purchase
CourseMate directly through www.cengagebrain.com.

Source Code
The source code, in ANSI/ISO Standard C++, is available for students to download at
www.cengagebrain.com and through the CourseMate available for this text. These files are also
available to instructors on the Instructor Resources CD and at login.cengage.com. The input
files needed to run some of the programs are also included with the source code.

Instructor Resources
The following supplemental materials are available when this book is used in a classroom
setting. All instructor teaching tools are available with this book on a single CD-ROM. Many
are also available for download at login.cengage.com.
Supplemental Resources | xli

Electronic Instructor’s Manual


The Instructor’s Manual follows the text chapter-by-chapter and includes material to assist in
planning and organizing an effective, engaging course.
The Manual includes Overviews, Chapter Objectives, Teaching Tips, Quick Quizzes, Class
Discussion Topics, Additional Projects, Additional Resources, and Key Terms. A Sample
Syllabus is also available.

ExamViewâ
This textbook is accompanied by ExamView, a powerful testing software package that allows
instructors to create and administer printed, computer (LAN-based), and Internet exams.
ExamView includes hundreds of questions that correspond to the topics covered in this
text, enabling students to generate detailed study guides that include page references for
further review. These computer-based and Internet testing components allow students to
take exams at their computers, and save the instructor time because each exam is graded
automatically. The test banks are also available in Blackboard, WebCT, and Angel
compatible formats.

PowerPoint Presentations
This book comes with PowerPoint slides to accompany each chapter. Slides may be used to
guide classroom presentation, to make available to students for chapter review, or to print as
classroom handouts. Instructors can add their own slides for additional topics that they
introduce to the class, as well as customize the slides with the complete Figure Files from
the text.

Solution Files
The solution files for all Programming Exercises, in ANSI/ISO C++, are available at
login.cengage.com, and are also available on the Instructor Resources CD-ROM. The input files
needed to run some of the Programming Exercises are also included with the solution files.
A CKNOWLEDGMENTS

There are many people that I must thank who, one way or another, contributed to the success
of this book. First, I would like to thank all the students who, during the preparation, were
spontaneous in telling me if certain portions needed to be reworded for better understanding
and clearer reading. Next, I would like to thank those who e-mailed numerous comments to
help improve upon the next edition. I am thankful to Professors S.C. Cheng and Randall
Crist for constantly supporting this project. I am also very grateful to the reviewers who
reviewed earlier versions of this book and offered many critical suggestions on how to
improve it.
I owe a great deal to the following reviewers who made helpful, critical suggestions for
improving this edition of the text: Gary Bricher, Lane Community College; Cliff Brozo,
Monroe College; and Marie Pullan, Farmingdale State College.
Next, I express thanks to Brandi Shailer, Acquisition Editor, for recognizing the importance
and uniqueness of this project. All this would not have been possible without the careful
planning of Senior Product Manager, Alyssa Pratt. I extend my sincere thanks to Alyssa, as
well as to Content Project Manager, Mathew Hutchinson. My special thanks are to Stephanie
Lorenz for using her expertise in carefully editing the videos. I also thank Sreemannarayana
Reddy of Integra Software Services for assisting us in keeping the project on schedule.
I would like to thank Chris Scriver and Serge Palladino of the QA department at Cengage
Learning for patiently and carefully testing the code and discovering typos and errors.
I am thankful to my parents for their blessings.
Finally, I am thankful for the support of my wife Sadhana and especially my daughter, Shelly,
to whom this book is dedicated. They cheered me up whenever I was overwhelmed during
the writing of this book.
I welcome any comments concerning the text. Comments may be forwarded to the following
e-mail address: [email protected]
D. S. Malik
1
CHAPTER

A N O VERVIEW OF
COMPUTERS AND
P ROGRAMMING
L ANGUAGES
I N T H I S C H A P T E R , YO U W I L L :
. Learn about different types of computers
. Explore the hardware and software components of a computer system
. Learn about the language of a computer
. Learn about the evolution of programming languages
. Examine high-level programming languages
. Discover what a compiler is and what it does
. Examine a C++ program
. Explore how a C++ program is processed
. Learn what an algorithm is and explore problem-solving techniques
. Become aware of structured design and object-oriented design programming methodologies
. Become aware of Standard C++ and ANSI/ISO Standard C++
2 | Chapter 1: An Overview of Computers and Programming Languages

Introduction
Terms such as ‘‘the Internet,’’ which were unfamiliar just 20 years ago are now common.
Students in elementary school regularly ‘‘surf ’’ the Internet and use computers to design their
classroom projects. Many people use the Internet to look for information and to commu-
nicate with others. This is all made possible by the availability of different software, also
known as computer programs. Without software, a computer is useless. Software is devel-
oped by using programming languages. The programming language C++ is especially well
suited for developing software to accomplish specific tasks. Our main objective is to help you
learn how to write programs in the C++ programming language. Before you begin
programming, it is useful to understand some of the basic terminology and different
components of a computer. We begin with an overview of the history of computers.

A Brief Overview of the History of Computers


The first device known to carry out calculations was the abacus. The abacus was invented in
Asia but was used in ancient Babylon, China, and throughout Europe until the late middle
ages. The abacus uses a system of sliding beads in a rack for addition and subtraction. In 1642,
the French philosopher and mathematician Blaise Pascal invented the calculating device
called the Pascaline. It had eight movable dials on wheels and could calculate sums up to
eight figures long. Both the abacus and Pascaline could perform only addition and subtrac-
tion operations. Later in the 17th century, Gottfried von Leibniz invented a device that was
able to add, subtract, multiply, and divide. In 1819, Joseph Jacquard, a French weaver,
discovered that the weaving instructions for his looms could be stored on cards with holes
punched in them. While the cards moved through the loom in sequence, needles passed
through the holes and picked up threads of the correct color and texture. A weaver could
rearrange the cards and change the pattern being woven. In essence, the cards programmed a
loom to produce patterns in cloth. The weaving industry may seem to have little in common
with the computer industry. However, the idea of storing information by punching holes on
a card proved to be of great importance in the later development of computers.
In the early and mid-1800s, Charles Babbage, an English mathematician and physical
scientist, designed two calculating machines: the difference engine and the analytical
engine. The difference engine could perform complex operations such as squaring numbers
automatically. Babbage built a prototype of the difference engine, but did not build the
actual device. The first complete difference engine was completed in London in 2002,
153 years after it was designed. It consists of 8,000 parts, weighs five tons, and measures 11
feet long. A replica of the difference engine was completed in 2008 and is on display at the
Computer History Museum in Mountain View, California (http://www.computerhistory.org/
babbage/). Most of Babbage’s work is known through the writings of his colleague Ada
Augusta, Countess of Lovelace. Augusta is considered the first computer programmer.
At the end of the 19th century, U.S. Census officials needed help in accurately tabulating
the census data. Herman Hollerith invented a calculating machine that ran on electricity
and used punched cards to store data. Hollerith’s machine was immensely successful.
Elements of a Computer System | 3

Hollerith founded the Tabulating Machine Company, which later became the computer
and technology corporation known as IBM. 1
The first computer-like machine was the Mark I. It was built, in 1944, jointly by IBM and
Harvard University under the leadership of Howard Aiken. Punched cards were used to feed
data into the machine. The Mark I was 52 feet long, weighed 50 tons, and had 750,000 parts.
In 1946, the ENIAC (Electronic Numerical Integrator and Calculator) was built at the
University of Pennsylvania. It contained 18,000 vacuum tubes and weighed some 30 tons.
The computers that we know today use the design rules given by John von Neumann in
the late 1940s. His design included components such as an arithmetic logic unit, a control
unit, memory, and input/output devices. These components are described in the next
section. Von Neumann’s computer design makes it possible to store the programming
instructions and the data in the same memory space. In 1951, the UNIVAC (Universal
Automatic Computer) was built and sold to the U.S. Census Bureau.
In 1956, the invention of transistors resulted in smaller, faster, more reliable, and more
energy-efficient computers. This era also saw the emergence of the software development
industry, with the introduction of FORTRAN and COBOL, two early programming
languages. In the next major technological advancement, transistors were replaced by tiny
integrated circuits, or ‘‘chips.’’ Chips are smaller and cheaper than transistors and can contain
thousands of circuits on a single chip. They give computers tremendous processing speed.
In 1970, the microprocessor, an entire CPU on a single chip, was invented. In 1977,
Stephen Wozniak and Steven Jobs designed and built the first Apple computer in their
garage. In 1981, IBM introduced its personal computer (PC). In the 1980s, clones of the
IBM PC made the personal computer even more affordable. By the mid-1990s, people
from many walks of life were able to afford them. Computers continue to become faster
and less expensive as technology advances.
Modern-day computers are powerful, reliable, and easy to use. They can accept spoken-word
instructions and imitate human reasoning through artificial intelligence. Expert systems assist
doctors in making diagnoses. Mobile computing applications are growing significantly. Using
hand-held devices, delivery drivers can access global positioning satellites (GPS) to verify
customer locations for pickups and deliveries. Cell phones permit you to check your e-mail,
make airline reservations, see how stocks are performing, and access your bank accounts.
Although there are several categories of computers, such as mainframe, midsize, and
micro, all computers share some basic elements, described in the next section.

Elements of a Computer System


A computer is an electronic device capable of performing commands. The basic commands
that a computer performs are input (get data), output (display result), storage, and perfor-
mance of arithmetic and logical operations. There are two main components of a computer
system: hardware and software. In the next few sections, we give a brief overview of these
components. Let’s look at hardware first.
4 | Chapter 1: An Overview of Computers and Programming Languages

Hardware
Major hardware components include the central processing unit (CPU); main memory
(MM), also called random access memory (RAM); input/output devices; and secondary
storage. Some examples of input devices are the keyboard, mouse, and secondary storage.
Examples of output devices are the screen, printer, and secondary storage. Let’s look at
each of these components in greater detail.

Central Processing Unit and Main Memory


The central processing unit is the ‘‘brain’’ of the computer and the single most expensive
piece of hardware in a computer. The more powerful the CPU, the faster the computer.
Arithmetic and logical operations are carried out inside the CPU. Figure 1-1(a) shows some
hardware components.

. .
Input . .
Central . .
Device
Processing 1000 54
Unit (CPU) 1001
Output A
. .
Device . .
. .
Main Memory 2000
2001
. .
. .
. .
Secondary Storage Main Memory

(a) (b)

FIGURE 1-1 Hardware components of a computer and main memory

Main memory, or random access memory, is connected directly to the CPU. All
programs must be loaded into main memory before they can be executed. Similarly, all
data must be brought into main memory before a program can manipulate it. When the
computer is turned off, everything in main memory is lost.
Main memory is an ordered sequence of cells, called memory cells. Each cell has a
unique location in main memory, called the address of the cell. These addresses help
you access the information stored in the cell. Figure 1-1(b) shows main memory with
some data.
Elements of a Computer System | 5

Today’s computers come with main memory consisting of millions to billions of cells.
Although Figure 1-1(b) shows data stored in cells, the content of a cell can be either a 1
programming instruction or data. Moreover, this figure shows the data as numbers and
letters. However, as explained later in this chapter, main memory stores everything as
sequences of 0s and 1s. The memory addresses are also expressed as sequences of 0s and 1s.

SECONDARY STORAGE
Because programs and data must be stored in main memory before processing and
because everything in main memory is lost when the computer is turned off, information
stored in main memory must be transferred to some other device for permanent storage.
The device that stores information permanently (unless the device becomes unusable or
you change the information by rewriting it) is called secondary storage. To be able to
transfer information from main memory to secondary storage, these components must
be directly connected to each other. Examples of secondary storage are hard disks, flash
drives, floppy disks, ZIP disks, CD-ROMs, and tapes.

Input /Output Devices


For a computer to perform a useful task, it must be able to take in data and programs and
display the results of calculations. The devices that feed data and programs into computers
are called input devices. The keyboard, mouse, and secondary storage are examples of
input devices. The devices that the computer uses to display results are called output
devices. A monitor, printer, and secondary storage are examples of output devices.
Figure 1-2 shows some input and output devices.

Input devices Output devices

FIGURE 1-2 Some input and output devices


6 | Chapter 1: An Overview of Computers and Programming Languages

Software
Software are programs written to perform specific tasks. For example, word processors
are programs that you use to write letters, papers, and even books. All software is written
in programming languages. There are two types of programs: system programs and
application programs.
System programs control the computer. The system program that loads first when you
turn on your PC is called the operating system. Without an operating system, the
computer is useless. The operating system monitors the overall activity of the computer
and provides services. Some of these services include memory management, input/output
activities, and storage management. The operating system has a special program that
organizes secondary storage so that you can conveniently access information.
Application programs perform a specific task. Word processors, spreadsheets, and
games are examples of application programs. The operating system is the program that
runs application programs.

The Language of a Computer


When you press A on your keyboard, the computer displays A on the screen. But what is
actually stored inside the computer’s main memory? What is the language of the
computer? How does it store whatever you type on the keyboard?
Remember that a computer is an electronic device. Electrical signals are used inside the
computer to process information. There are two types of electrical signals: analog and
digital. Analog signals are continuous wave forms used to represent such things as
sound. Audio tapes, for example, store data in analog signals. Digital signals represent
information with a sequence of 0s and 1s. A 0 represents a low voltage, and a 1
represents a high voltage. Digital signals are more reliable carriers of information than
analog signals and can be copied from one device to another with exact precision. You
might have noticed that when you make a copy of an audio tape, the sound quality of
the copy is not as good as the original tape. On the other hand, when you copy a CD,
the copy is as good as the original. Computers use digital signals.
Because digital signals are processed inside a computer, the language of a computer, called
machine language, is a sequence of 0s and 1s. The digit 0 or 1 is called a binary digit,
or bit. Sometimes a sequence of 0s and 1s is referred to as a binary code or a binary
number.
Bit: A binary digit 0 or 1.
A sequence of eight bits is called a byte. Moreover, 210 bytes = 1024 bytes is called
a kilobyte (KB). Table 1-1 summarizes the terms used to describe various numbers
of bytes.
Another Random Document on
Scribd Without Any Related Topics
Skeleton, 166
Skull, 171
Slack, crest, 258
Sledge, 456
Slipped, 265, 267, 269;
leaved, 269
Slips, 265
Smallshaw, arms, 270
Smert, John, 28, 41
Smith, 68, 202, 288;
arms, 289;
crest, 245
Smith-Cunningham, 426
Smitheman, arms, 238
Smyth, arms, 272
Snail, 258
Sneds, 298
Sneyd, arms, 298
Snowdon, 39
Sodor and Man, 160, 285
Soldanieri, arms, 83
Soles, 256
Sollerets, 55
Soluthurn, supporters, 409
Somers, crest, 263, 293
Somerscales, arms, 261
Somerset, 520;
Duke of, Henry Fitzroy, 37;
Duke of, John Beaufort, Garter plate,
416;
arms, 466;
Dukes of, 513;
Herald, 37, 620
Sophia, Princess, label, 499
Soudan, de la Tran, K.G., Sir Bermond
Arnaud de Presac, arms, crest,
mantling, 387
Southampton, arms, 270;
city of, arms, crest, supporters and
compartment, 445
Southwark, borough of, 605
Southwell, See of, 160;
Viscount, supporters, 437
Soutiens, 407
Sovereign, helmet of, 318
Sovereign's Privy Seals, 467;
grand-children of, coronets, 363;
sons and daughters or brothers and
sisters of a, coronets of, 363
Spain, 61, 81, 83;
crests, 343;
marks of cadency, 482;
Queen Victoria Eugenie of, 139, 474,
596;
Philip of, 607;
quarterings of, 543
Sparlings, 256
Spear and spear-head, 285
Specified, number, 89
Speke, crest and supporters, 217;
augmentation, 420, 595
Spelman, Sir Henry, 30, 31, 32, 33, 34
Spener, 324, 481
Spenser, 221
Sphinx, 4, 9, 171, 228
Spider, 261
Spikes, 223
Spokes, arms, 291
Springbok, 208, 217;
as supporters, 436
Sprot, 255
Spry, arms, 124
Spur-nowels, or Spur-revels, 286, 296
Spurs, 54, 286
Squirrel, 214, 430
SS, collar of, 44
St. Adrian, 162
St. Ægidius, 162
St. Albans, Boke of, 2;
Duke of, 515;
monastery, 143
St. Andrew, 47, 160, 162, 614
St. Andrew, Saltire of, 25;
Cross of, 131;
flag of, 472
St. Anthony's Cross, 129
St. Asaph, Bishop of, 78
St. Aubin, cloister of, 228
St. Boniface, 164
St. Britius, 160
St. Bryse, 160
St. Catherine, wheel of, 473, 606
St. Columba, 162
St. Cricq, Comtes de, arms, 281
St. Cuthbert, cross of, 606
St. David's, 588
St. Denis, 165, 220, 473;
Abbey of, 16, 219
St. Duthacus, 162
St. Edmund, cross and martlets of, 473
St. Edward, 360
St. Edward the Confessor, 596, 607;
arms, 244
St. Edward's Crown, 358
St. Elizabeth, 62
St. Etheldreda, 298
St. Etienne, Abbey of, 525
St. George, 162, 614;
arms of, 46;
banner of, 471;
Cross of, 25, 38;
flag of, 472;
Chapel, 78, 149, 505;
stall plates, 559
St. Giles, 162
St. Helens, borough of, arms, 292
St. Ives (Cornwall), arms, 264
St. John the Baptist, 165
St. John of Jerusalem, Order of the
Hospital of, 568;
Knights of Justice of the Order, insignia
of, 585
St. John of Malta, Celibate Order of, 569
St. Kentigern, 163
St. Lawrence, 550
St. Leonards, Lord, 68
St. Mark, 185, 186, 220
St. Martin, 162, 164
St. Mary, lily of, 473;
the Virgin, College of, arms, 271
St. Maur, arms, 239
St. Michael, 162, 163;
and All Angels, 54;
St George, Most Distinguished Order
of, 29, 566, 584
St. Mungo, 163
St. Neots, 75
St. Ninian, 162
St. Oswald, Lord, supporters, 437
St. Patrick, 614;
Order of, 46;
Knights of, rules, 563;
supporters, 563;
insignia of, 584;
Order of Prelate of the, insignia of,
584;
Deans of, insignia of, 584;
Chancellor of, insignia of, 584
St. Patrick, flag of, 473
St. Paul, 164;
sword of, 473, 606
St. Peter, emblem, 291;
keys of, 473, 606
St. Petersburg, 351
St. Stephen of Tuscany, Knights of the,
569
St. Vincent, Lord, crest, 377
Stable, arms, 277
Stafford, 56;
crest, 246;
knot, 469;
Earl of, 73
Stafford, Earl of, supporters, 461;
Earl of, Sir Humphrey Stafford, arms,
crest, mantling, 388;
Lord, badge, 458;
crest, 374
Stags, 208, 432
Stains, 72, 73
Stalbridge, Lord, 345
Standard, 28, 59, 474;
badges upon, 464;
bearer (Würtemburg), hereditary
insignia of, 582
Standish, arms, 289
Staniland, arms, 286
Stanley, 209;
Lord, badge, 240, 469;
Torse, arms, 404
Staple, 302
Stapleton, Sir Miles, K.G., arms, crest,
mantling, 387
Stapylton, supporters, 421
Starckens, 163
Star of India, Most Exalted Order of the,
565, 584
Stars, 11, 295
Statant, 102, 172, 213, 226
State liveries, badges on, 464
Statute of Resumptions, 30
Steamer, 294
Stephen, coins, 354
Stephen de Windesore, 31
Sterling, William, seal, 417
Steuart, Bart., crest, 375
Steward, Lord High, insignia of, 582
Stewart, arms, 86;
crest, 164;
of Ochiltree, 502, 513
Stilwell, crest, 246
Stirling-Maxwell, supporters, 431
Stirrups, 286
Stoat, 215
Stockfish, 255
Stockings, 293
Stocks of Trees, 264
Stodart, 144, 145, 502, 514
Stoke-Lyne, Lord of the Manor, arms, 413
Stones, 286
Storey, 256
Stork, 247, 440
Stothard, C., 15
Stourton, arms, 152, 153, 294;
badge as a crest, 456;
barony of, supporters, 205;
crest, 341, 385;
Lord, supporters, 437;
seal, 153
Strange, arms of, 175
Strangman, 111
Strathcona, Lord, crest, 263;
arms, 216
Stratheden, Baroness, late, 533
Stratherne, Countess of, Muriel, seal, 410
Strigoil and Chepstow, Earls of, 32
Struan, 197
Stuart-French, arms, 254
Stuart-Menteith, 414
Stubbs, arms, 264
Stukele, arms, 277
Sturgeon, 256
Sturzkrückenfeh, 85
Sturzpfahlfeh, 82
Styleman, arms, 222
Styria, arms, 194, 417
Sub-ordinaries, 91, 102, 106, 107, 108,
155, 156;
complete list of, 108;
sub-quarters, 104, 544
Suchenwirt, 40
Suffolk, 32;
Duke of, William de la Pole, badge,
469;
Garter plate, 372
Sugar-cane, 263
Sun, 11, 77;
burst, badge, 468, 469;
in splendour, 296
Sunflower, 272
Superimposed, 86, 554
Supporters, 58, 86, 158, 162, 164, 165,
166, 185, 186, 193, 201, 204,
209, 213, 215, 216, 217, 225, 227,
286, 319, 346, 407, 411, 412,
413, 414, 415, 416, 428, 475,
519, 532, 533, 564, 572;
the first, 432;
differencing on, 492;
crested, 417;
by prescriptive right, 421;
in England, right to bear, 419;
honourable, 446;
origin of, 417;
position of, 430;
single, 410
Surcoat, 18, 57, 108
Surgeons, College of, arms, 167
Surrey, 50;
Duke of (Thomas de Holland),
bordure, 596;
Earl of, augmentation, 590
Sussex, Duke of, label, 498;
Earl of, 32
Sutton, arms, 258
Swaby, crest, 245
Swallow, 244, 245
Swan, 245
Swanne, Adam Fitz, 467
Swansea, Lord, crest, 349
Sweetland, arms, 263
Swindon, arms, crest, 301
Swinton, 503, 504;
arms, 453;
crest, 199;
supporters, 425;
Henry de, seal, 504;
Captain Archibald, 506;
Captain George C., 506;
Sir John de, 505;
John Edulf Blagrave, Laird, 506;
arms, 507;
Robert, 505
Switzerland, 83
Sword, 5, 11, 286
Swynnerton, 113
Sydenham, arms, 211
Sykes, 207;
arms, 151, 280
Symbolism, 5, 11
Symonds-Taylor, arms, 254
Syphium-plant, 272
Tabard, 41
"Table Book," 413
Tacitus, 6, 9
Tain, Royal Burgh of, 162
Talbot, 175, 203, 204, 554;
arms of, 70;
Earl of, 70;
Lord, crest, 341
Tallow Chandlers' Company, 41;
arms, 28;
crest, 165
Tamworth, seals, 275
Tancred, crest, 263
Tankerville, Earl of (Bennet), arms, 189;
(Sir John Grey), Torse, arms, 404
Tannenvels, arms, 188
Tarleton, crest, 374
Tarn or loch, 294
Tarragone, arms, 81
Tarsell, arms, 277
Tartsche, or Tartscher, 64
Tassa, 85
Tasselled Hat, 61
Tatshall, 55
Taunton, 278
Taylor, 193
Tea-plant, 266
Teck, Duke of, 187
Teesdale, arms, 271
Telescope, 297
Temperance, 164
Temple, 282
Temple-Nugent-Brydges-Chandos-
Grenville, crests, 348
Templer, arms, 282
Tenants, 407
Tenné, 72, 74, 76
Tenremonde, arms, 83
Teutonic Order, 63;
Masters of the, 569
Teviot, Viscount (Livingstone), 276
Thackeray, 165;
arms, 86
Thebes, King of, 6
Theme, arms, 266
Theodosia, Empress, 351
Thierry, 14
Third son, 488
Thistle, 270;
Order of the, 271, 561;
Knight of the, insignia of, 584;
Knights of the, rules, 563;
supporters, 563
Thorndyke, crest, 261
Thornhill, crest, 168
Thornton, arms, 250, 263, 597;
supporters, 250
Thunderbolt, 295
Thuringia, 63
Thurston, crest, 295
Tichborne, supporters, 421
Tiger, 191;
as supporters, 436
Tigress, 192
Tilting-helm, 54
Tinctures, 70, 476, 483, 502;
change of, 483
Tindal, 30
Tityron, 231
Tjader, 250
Toad, 258
Tobacco-Pipe Makers, the Company of,
arms, 265
Todmorden, town of, arms, 293
Tokugawa, 13
Toledo, arms of, 298
Tollemache, arms, 149
Topaz, 77
Topsell, 221
Torches, or Firebrands, 287
Torphichen, Lord, arms, 271
Torrington, Lord, supporters, 442
Torse, 287, 402, 403, 406;
colours of, 404
Torteau, 151
Tortoise, 217
Tournament helmet, 311
Tournay, 83
Tournebu, Pierre de, supporter, 411
Tourney, 333
Towers, 282, 376
Towns, rules as to supporters, 429
Toymote, 13
Trafford, De, crest, 167;
mottoes, 451
Transposed, 103
Trapaud, 124
Trappe, arms, 283
Trasegnies, arms, 188
Trayner, arms, 293
Treacher, arms, 261
Treason, 73
Treasurer, insignia of, 588
"Treatise on Heraldry," 14, 16, 69, 74,
318, 399, 407, 410
Trees, 11, 94, 262, 407
Trefoil, 266
Tregent, arms, 261;
crest, 228
Trelawney, arms, 266
Trente Deux Quartiers, 619
Tresmes, Ducs de, supporters, 231
Tressure, 108, 112, 133, 142, 143, 146
Trevelyan, arms, 201;
supporters, 254
Treves, Bart., 232;
arms, 292;
augmentation, 598
Treves, Elector and Archbishop of, 559
Trick, 77, 99
Tricorporate, 180
Triple-towered, 282
Trippant, 102, 208
Trist, crest, 241
Triton, 227
Trononnée, 186
Trotter, arms of, 5
Trotting, 201
Trout, 255
Troutbeck, arms, 255
Trumpeter, costume of, 43
Trumpington, Sir Roger de, 54
Trunk of a tree, 264
Trunked, 96
Trupour, or Trumpour, John, 40
Trussing, 242
Trussley, 214
Trutemne, Banville de, arms, 82
Truth, 164
Tuam, See of, arms, 160
Tucker, Stephen, 620
Tudor, Royal House, badge, 284
Tulips, 272
Tuns, 301
Tunstall, arms, 299, 404
Tupper, 428
Turbots, 256
Turner, arms, 302
Turnierkragen, 479
Turnip, 268
Tuttebury, Earl of, 32
Tweedy, 249
Tynes, 209
Tynte, crest, 222
Tyrol, 234
Tyrrell, crest, 200, 247
Tyrwhitt, 249;
arms, 249
Tyson, crest, 287

Udine, 83
Udney, 204
Ulster, canton of, 136, 137;
King of Arms, 29, 33, 46, 47, 421;
badges of, 598;
arms and insignia of, 587;
official arms of, 48;
office, 72, 86, 180, 267, 416, 439
Umbo, 64
Umfraville, 89;
arms, 268
Undy, 91
Unguled, 207
Unicorn, 39, 202, 219, 220, 221, 232
United Kingdom, Royal Arms,
compartment, 444
Union Banner, 611, 614, 615
Union Jack, 471, 611
Unmarried lady, lozenge of, 572
Unter-Walden, supporter, 409
Uphaugh, Duppa de, arms, 284
Upton, 36
Urbino, Duke of, Frederick, 392;
mantling, 388
Urcheon, 216
Urdy, 91, 95;
at the foot, 155
Utermarch, arms, 266
Vaile, 113, 207
Vaillant, 34
Vair, 50, 77, 79, 81, 84;
appointé, 82;
in bend, 82;
bellies, 85;
ondé, 81;
en pal, 82;
in pale, 82
Vairé, 79, 81, 94;
corrupted form of, 81;
en pal, 82
Vairpière, 83
Valence, De, 155;
William, 525
Vallary, Coronet, 378
Vambraced, 171
Vambraces, 45
Van Eiden, Sir Jacob, 145
Van Houthem, Barons, arms, 82
Van Schorel, 163
Vane, arms, 171, 293
Varano, 83
Varenchon, 83
Varroux, arms, 82
Varry, tassy, 85;
cuppy, 85
Varus, 79
Vase, 288
Vaughan, 169
Vavasseur, arms, 284
Veitch, arms, 207
Venus, 77
Vera, De, 83
Verden, 49
Verdon, arms, 149
Verdun, Alix de, 410
Vere, arms, 134, 296
Verelst, crest, 214
Veret, 83
Verhammes, 200
Vernon, motto, 451
Verona, 83, 163
Verre, 79
Verschobenes, 85
Vert, 70, 76, 90
Veruled, 292
Vervelled, 241
Vesci, de, Viscount, supporters, 433
Vesentina, 163
Vesili's, Andreas, 439
Vested, 170
Vestments, 5
Vice-Admiral, insignia of, 581
Vice-Connétable, insignia of, 582
Victoria, Queen, 41, 358, 361, 364, 421,
488, 496;
seal, 475;
Cross, 567;
those entitled to the, insignia of, 584;
Princess, label, 496, 497;
and Albert, Order of, members of,
insignia of, 584
Victorian Order, Royal, 567;
insignia of, 584
Victory, 164
Viennois, Dauphin de, Charles, supporter,
411
Vigilance, 247, 286
Vine, 264
Virgil de Solis, 144
Virgin Mary, 159;
lilies of the, 606
Virolled, 292
Visconti, arms, 257
Viscountess robe or mantle, 366;
coronet, 366
Viscounts, robe or mantle of, 365, 367;
coronet of, 365, 368
Visitations, mottoes in, 449
Vivian, crest, 166
Vohlin, arms, 411
Void, 73
Voiders, 150
Vol, 240
Volant, 34, 245;
en arrière, 266
Volunteer Officer's Decoration, 568;
insignia of, 584
"Von," German, 68
Von Burtenback, Captain Sebastian
Schärtlin (Schertel), arms, 185
Von Dälffin, Grauff, arms, 254
Von Fronberg, Herr, 203
Von Lechsgemünd, Count Heinrich von,
seal, 195
Von Pauli, 164
Vree, 84
Vulned, 187, 242
Vulture, 241
Vyner, Sir Robert, 358

Wade, crest, 217


Wake, knot, 469
Wakefield, crest, 217
Wakefield, town of, arms, 275
Waldeck-Pyrmont, Prince of, crests, 343
Waldegrave, arms of, 69;
Lord, arms, 252
Wales, badge of, 38, 225, 457;
Herald of, 33, 36;
ruddy dragon of, 225;
Prince of, 85, 254, 486;
coronet, 363;
badge, 225, 458;
label, 497;
mantling, 391, 392;
Princess of, coronet, 363
Walker, arms, 281;
Sir Edward, 358;
Trustees, insignia of, 586
Walkinshaw, arms, 262
Wallenrodt, Counts, arms, 288
Waller, 112;
arms, 266;
crest, 263, 434;
Sir Jonathan
Wathen, supporters, 433;
Richard, augmentation, 596
Wallop, 111
Walnut-leaves, 266;
tree, 263
Walpole, 106
Walrond, arms, 207
Walsh, 86
Wands, 41
Wandsworth, 294
Wappen und Stammbuch, 185
Wappenbuch, 203, 224, 234
Wappencodex, 28
Wappenkönige, 40
Wappenrolle, von Zurich, 188
Warde-Aldam, arms, 114, 275
Wareham, arms, 275
Warnecke's, 176
Warren, 70;
Sir John de, 521;
William de, arms, 486;
Mantling, 389
Warrington, town of, 174;
arms, 288
Warwick, Lord, 458;
Earls of, differences, 484;
Earl of, Richard Beauchamp, 541;
Earl of, Waleran, 484;
Earl of, Thomas, 484;
and Albemarle, Earl of, Richard
Beauchamp, 540
Water, 88, 94;
colour, 74, 76;
bougets, 299
Waterford, supporters, 245;
Earl of, 70;
Marquess of, supporters, 433;
city of, supporters, 439
Waterlow, arms, 298
Watermen and Lightermen's Livery Co.,
supporters, 439
Watkin, Bart., arms, 261
Watney, crest, 205
Watson-Taylor, supporters, 420
Wattled, 227, 246
Wave, vair, 81
Wavy, 91, 116;
or undy, 94
Waye, arms, 119
Weasel, 215
Wechselfeh, 82
Weirwolf, 171, 229
Welby, Lord, 196
Weldon, Sir Anthony, 164
Wellington, Duke of, 541;
Duke of, augmentation, 594
Wells, 294
Welsh dragon, 225;
arms, 545
Were, arms, 290
West Riding, 56
Westbury, arms of, 188
Westcar, crest, 217
Westmeath, Earl of, supporters, 227, 438
Westminster, Dukes of, arms, 554;
crest, 345;
Marquess of, augmentation, 598;
city of, arms, 554;
Abbey, 284, 524, 543;
Dean of, 585
Westphalia, 608;
arms, 201
Westworth, arms, 296
Whale, 245, 253, 256
Whalley, arms, 245
Wharton, 292
Wheat, 278
Wheel, 302
Whelks, 256
Whitby, arms, 258
White, supposed to be, 78;
ensign, 471;
ermine spots, 78;
label, 71;
staff, 41
White-Thomson, arms, 270
Whitgreave, crest, 298;
augmentation, 592
Widow, arms, 146, 533, 573
Wiergman, 164
Wife, impalements, 535, 536, 537, 538
Wigan, crest, 263, 295
Wilczek, Count Hans, 316
Wild cat, 195
Wildenvels, arms, 188
Wildmen, 433
Wildwerker, 83
Wilkinson, 256
Wilson, 196
William I., 15, 354, 355
William II., seal, 354
William III., 276, 596, 607
William IV., 412, 608;
State Crown, 356
Williams, arms, 181
Williams-Drummond, Bart., supporters,
433
Willoughby, 282
Winchester, Bishops of, insignia of, 584;
Dean of, 588;
Earl of, 32, 148;
Earl of, Seiher de Quincy, 147;
Marquesses of, 379;
Captain Peter, arms, 264
Windsor, 30, 31, 78, 149;
badge of, 48;
Henry of, 469;
Dean of, insignia of, 584;
Herald, 37;
Castle Bookplates, 183;
Library, 372
Wingate, arms, 284
Winged, 286
Winged ape, 215;
lions, 436;
stags, 209
Winlaw, 255;
motto, 451
Winnowing fans, 55
Winterstoke, Lord, supporters, 437
Winwick, 50
Wogenfeh, 81, 82
Wolf, 196
Wolf-hunter, Grand, insignia of, 581
Wolfe, 181, 541;
crest, 298;
Francis, 196, 592
Wolkenfeh, 81
Wolseley, arms, 204;
Lord, 196, 204, 594
Wolverhampton, town of, arms, 284, 291
Woman, grant to a, 57, 62, 574;
illegitimate, Royal Licence, 554;
married, arms, 534
Wood, 165;
late Sir Albert, 264;
crests granted, 339;
Sir William, 349
Woodbine-leaves, 266
Woodman, 433
Wood-pigeon, 244
Woodstock, borough of, arms, 264
Woodstock, De, 56;
Thomas of, 494
Woodward, 14, 75, 80, 83, 85, 90, 136,
150, 162, 185, 188, 197, 200,
250, 253, 254, 255, 261, 318,
324, 343, 399, 405, 467, 469,
513, 514, 598;
and Burnett, 69, 74, 94, 95, 407;
arms, 261, 266
Woollan, 292
Woolpack, 5
Worcester, 78
Wordsworth, 287
"Workes of Armorie," 489
Worms, Baron de, supporters, 444
Wortford, arms, 266
Wreath, 157
Wright, 126
Wriothesley, 41
Wursters, arms, 200
Wurtemburg, supporters, 187;
Queen of, label, 498
Wyatt, arms, 287
Wylcote, Sir John, brass, 389
Wyndham, crest, 291
Wyndham-Campbell-Pleydell-Bouverie,
crests, 348
Wynn, Sir Watkin Williams, 198
Wyon, 353
Wyvern, 186, 225, 226, 227;
as supporters, 437, 438

Xantoigne, 34

Yacht, 294
Yarborough, Earl of, 205, 590;
badge, 288, 458;
supporter, 437
Yarmouth, 525;
arms, 182
Yeates, 255
Yeatman-Biggs, arms, 141
Yellow, 70
Yerburgh, crest, 242
Yeropkin, 250
Yockney, arms, 266
Yonge, crest, 222
York, 588;
Archbishop of, 127;
arms, 297, 601, 602;
pallium, 583;
Cardinal, 359;
Herald, 37;
badge of, 48;
Duke of, 37, 488;
Duke of, label, 498;
Duke of (Edward), seal, 466;
blazing sun of, badge, 468;
white rose of, badge, 468;
and Lancaster, badges, 468
Yorke, 112;
crest, 215
Youghal, Provosts of, seal, 525
Young, Sir Charles, crest, 226, 348

Zachary, 514
Zebra, 217, 438
Zobel, 77
Zoë, Queen, 351
Zorke, 112
Zorn, crests, 344
Zug, supporters, 409
Zurich, 384;
supporter, 409;
Wappenrolle, 397
THE END

Printed by Ballantyne, Hanson & Co.


Edinburgh & London

NOTES

[1]
"Norreys and Surreis, that service aught the
kyng,
With horse and harneis at Carlele, made
samning."

See Langtoft's Chronicle treating of the Wars of Edward I.


against the Scots.

"Bot Sir John de Waleis taken was, in a pleyne,


Throgh Spring of Norreis men that were
certeyn."

Ibid., Australes se Norensibus opposuerunt. M. Oaris, under


the year 1237.
[2] Robertson's Index to "Missing Charters."
[3] Here lieth Sir John D'Aubernoun, knight. On his soul
may God have mercy.
[4] "Monumental Brasses of Gloucestershire," by C. T.
Davis. London: Phillimore & Co., 1899.
[5] The arms are quoted by Mr. Davis from Bigland's
"Gloucestershire," p. 539.
[6] The arms of Clayhills of Invergowrie: Parted per bend
sanguine and vert, two greyhounds courant bendwise
argent. Mantling gules doubled argent; and upon a wreath
of the liveries is set for crest, an arm holding an Imperial
crown proper; and in an escroll over the same, this motto,
"Corde et animo." Matriculated in Lyon Office circa 1672.
[7] Armorial bearings of Sir Henry Seymour King, K.C.I.E.:
Quarterly, argent and azure, in the second and third
quarters a quatrefoil of the first, over all a bend barry of six
of the second, charged with a quatrefoil also of the first,
and gules.
[8] Armorial bearings of William Warde-Aldam, Esq.:
Quarterly, 1 and 4, party per fesse azure and ermine, in the
sinister chief and dexter base an eagle displayed or, in the
dexter canton issuant towards the sinister base seven rays,
the centre one gold, the others argent (for Aldam); 2 and 3
(for Warde).
[9] Armorial bearings of Isham: Gules, a fesse wavy, and in
chief three piles in point also wavy, the points meeting in
fesse argent.
[10] Collectanea, ed. 1774, ii. 611.
[11] In M. Victor Bouton's edition of the Armorial de Gelre
(Paris 1881) the bonnet is described as a mount.
[12] Arms of Rutherglen: Argent, in a sea proper an ancient
galley sable, flagged gules, therein two men proper, one
rowing, the other furling the sail. Above the shield is placed
a suitable helmet, with a mantling gules, doubled argent;
and on a wreath of the proper liveries is set for crest, a
demi-figure of the Virgin Mary with the Infant Saviour in
her arms proper; and on a compartment below the shield,
on which is an escroll containing this motto, "Ex fumo
fama," are placed for supporters, two angels proper, winged
or.
[13] Arms of Sandwich: Party per pale gules and azure,
three demi-lions passant guardant or, conjoined to the
hulks of as many ships argent.
[14] Arms of Hastings: Party per pale gules and azure, a
lion passant guardant or, between in chief and in base a
lion passant guardant or, dimidiated with the hulk of a ship
argent.
[15] Arms of Ramsgate: Quarterly gules and azure, a cross
parted and fretty argent between a horse rampant of the
last in the first quarter, a demi-lion passant guardant of the
third conjoined to the hulk of a ship or in the second, a
dolphin naiant proper in the third, and a lymphad also or in
the fourth. Crest: a naval crown or, a pier-head, thereon a
lighthouse, both proper. Motto: "Salus naufragis salus
ægris."
[16] Arms of Yarmouth: Party per pale gules and azure,
three demi-lions passant guardant or, conjoined to the
bodies of as many herrings argent. Motto: "Rex et nostra
jura."
[17] Armorial bearings of Dodge: Barry of six or and sable,
on a pale gules, a woman's breast distilling drops of milk
proper. Crest: upon a wreath of the colours, a demi sea-dog
azure, collared, maned, and finned or.
[18] Armorial bearings of James Joseph Louis Ratton, Esq.:
Azure, in base the sea argent, and thereon a tunny sable,
on a chief of the second a rat passant of the third. Upon
the escutcheon is placed a helmet befitting his degree, with
a mantling azure and argent; and for his crest, upon a
wreath of the colours, an ibex statant guardant proper,
charged on the body with two fleurs-de-lis fesswise azure,
and resting the dexter foreleg on a shield argent charged
with a passion cross sable. Motto: "In Deo spero."
[19] Upon a wreath of the colours, from a plume of five
ostrich feathers or, gules, azure, vert, and argent, a falcon
rising of the last; with the motto, "Malo mori quam fœdari."
[20] Armorial bearings of Peebles (official blazon): Gules,
three salmon naiant in pale, the centre towards the dexter,
the others towards the sinister. Motto: "Contra nando
incrementum."
[21] Arms of Accrington: Gules, on a fess argent, a shuttle
fesswise proper, in base two printing cylinders, issuant
therefrom a piece of calico (parsley pattern) also proper, on
a chief per pale or and vert, a lion rampant purpure and a
stag current or; and for the crest, an oak-branch bent
chevronwise, sprouting and leaved proper, fructed or.
Motto: "Industry and prudence conquer."
[22] Out of a ducal coronet gules, a lion's head ermine
(Nicholson).
[23] Crest of Bentinck: Out of a marquess's coronet proper,
two arms counter-embowed, vested gules, on the hands
gloves or, and in each hand an ostrich feather argent.
[24] Plate XI. Fig. 10, Laing's "Catalogue," No. 29. At each
side of the King's seated figure on the counter-seal of
Robert II. (1386) the arms of Scotland are supported from
behind by a skeleton within an embattled buttress
("Catalogue," No. 34).
[25] Armorial bearings of William Speke, Esq.: Argent, two
bars azure, over all an eagle displayed with two heads
gules, and as an honourable augmentation (granted by
Royal Licence, dated July 26, 1867, to commemorate the
discoveries of the said John Hanning Speke), a chief azure,
thereon a representation of flowing water proper,
superinscribed with the word "Nile" in letters gold. Upon
the escutcheon is placed a helmet befitting his degree, with
a mantling azure and argent; and for his crests: 1. (of
honourable augmentation) upon a wreath of the colours, a
crocodile proper; 2. upon a wreath of the colours, a
porcupine proper; and as a further augmentation for
supporters (granted by Royal Licence as above to the said
William Speke, Esq., for and during his life)—on the dexter
side, a crocodile; and on the sinister side, a hippopotamus,
both proper; with the motto, "Super æthera virtus."
[26] Arms of Glasgow: Argent, on a mount in base vert an
oak-tree proper, the stem at the base thereof surmounted
by a salmon on its back also proper, with a signet-ring in its
mouth or, on the top of the tree a redbreast, and in the
sinister fess point an ancient hand-bell, both also proper.
Above this shield is placed a suitable helmet, with a
mantling gules, doubled argent; and issuing from a wreath
of the proper liveries is set for crest, the half-length figure
of St. Kentigern affronté, vested and mitred, his right hand
raised in the act of benediction, and having in his left hand
a crosier, all proper. On a compartment below the shield are
placed for supporters, two salmon proper, each holding in
its mouth a signet-ring or, and in an escroll entwined with
the compartment this motto, "Let Glasgow flourish."
[27] Supporters of Lord Hawke: Dexter, Neptune, his
mantle of a sea-green colour, edged argent, crowned with
an Eastern coronet or, his dexter arm erect, darting
downwards his trident sable, headed silver, resting his
sinister foot on a dolphin, also sable; sinister a sea-horse or,
sustaining in his forefins a banner argent the staff broken
proper.
[28] Arms of Boston: Sable, three coronets composed of
crosses patté and fleurs-de-lis in pale or. Crest: A woolpack
charged with a ram couchant all proper, ducally crowned
azure.
[29] The caltrap was an instrument thrown on the ground
to injure the feet of horses, and consisted of four iron
spikes, of which one always pointed upwards.
[30] Arms borne on a sinister canton suggest illegitimacy.
[31] Gutté-de-poix.

CORRECTIONS MADE TO PRINTED ORIGINAL


Page 6. "herald (κηρυξ)" corrected from "herald (κηργξ)"

Page 47. "The reverse exhibits the arms of the Office of Ulster"
corrected from "The reserve exhibits ..."
Page 327. "Then it was found that" corrected from "Then it was
found than"
Page 482. "the bearer was not the person chiefly entitled" corrected
from "the hearer ..."
Index "Layland-Barratt" corrected from "Llanday-Burratt" to match
text, and placed in correct sequence
*** END OF THE PROJECT GUTENBERG EBOOK A COMPLETE
GUIDE TO HERALDRY ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like