100% found this document useful (8 votes)
29 views

Readings from Programming with C++ 1st Edition Kyla Mcmullen - eBook PDF 2024 scribd download

from

Uploaded by

komovatsader
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (8 votes)
29 views

Readings from Programming with C++ 1st Edition Kyla Mcmullen - eBook PDF 2024 scribd download

from

Uploaded by

komovatsader
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Visit https://ebookluna.

com to download the full version and


explore more ebooks

Readings from Programming with C++ 1st Edition Kyla


Mcmullen - eBook PDF

_____ Click the link below to download _____


https://ebookluna.com/download/readings-from-
programming-with-c-ebook-pdf/

Explore and download more ebooks at ebookluna.com


Here are some recommended products that might interest you.
You can download now and explore!

Readings from Programming with C++ 1st Edition Kyla


Mcmullen - eBook PDF

https://ebookluna.com/download/readings-from-programming-with-c-ebook-
pdf/

ebookluna.com

Programming With STM32: Getting Started With the Nucleo


Board and C/C++ - eBook PDF

https://ebookluna.com/download/programming-with-stm32-getting-started-
with-the-nucleo-board-and-c-c-ebook-pdf/

ebookluna.com

(eBook PDF) Programming, Problem Solving and Abstraction


with C

https://ebookluna.com/product/ebook-pdf-programming-problem-solving-
and-abstraction-with-c/

ebookluna.com

Programming in C 1st Edition - eBook PDF

https://ebookluna.com/download/programming-in-c-ebook-pdf/

ebookluna.com
(eBook PDF) C++ Programming: From Problem Analysis to
Program Design 7th

https://ebookluna.com/product/ebook-pdf-c-programming-from-problem-
analysis-to-program-design-7th/

ebookluna.com

(Original PDF) C++ Programming From Problem Analysis to


Program Design 8th

https://ebookluna.com/product/original-pdf-c-programming-from-problem-
analysis-to-program-design-8th/

ebookluna.com

C++ Programming: From Problem Analysis to Program Design


8th Edition Edition D.S. Malik - eBook PDF

https://ebookluna.com/download/c-programming-from-problem-analysis-to-
program-design-ebook-pdf/

ebookluna.com

Programming and Problem Solving with Python 1st Edition -


eBook PDF

https://ebookluna.com/download/programming-and-problem-solving-with-
python-ebook-pdf/

ebookluna.com

(eBook PDF) Starting Out with C++ from Control Structures


to Objects 9th Edition

https://ebookluna.com/product/ebook-pdf-starting-out-with-c-from-
control-structures-to-objects-9th-edition/

ebookluna.com
Programming with

C++ KYLA McMULLEN


Elizabeth matthews
June Jamrich Parsons

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

Copyright 2022 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 2022 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.
Readings from Programming with C++ © 2022 Cengage Learning, Inc.
Kyla McMullen, Elizabeth Matthews, WCN: 02-300
June Jamrich Parsons
Unless otherwise noted, all content is © Cengage.
SVP, Higher Education Product Management:
ALL RIGHTS RESERVED. No part of this work covered by the copyright herein
Erin Joyner
may be reproduced or distributed in any form or by any means, except as
VP, Product Management: Thais Alencar permitted by U.S. copyright law, without the prior written permission of the
copyright owner.
Product Team Manager: Kristin McNary

Associate Product Manager: Tran Pham For product information and technology assistance, contact us at
Cengage Customer & Sales Support, 1-800-354-9706
Product Assistant: Tom Benedetto
or support.cengage.com.
Learning Designer: Mary Convertino

Senior Content Manager: Maria Garguilo For permission to use material from this text or product, submit all requests
online at www.cengage.com/permissions.
Digital Delivery Lead: David O’Connor

Technical Editor: John Freitas Library of Congress Control Number: 2020922802

Developmental Editor: Lisa Ruffolo ISBN: 978-0-357-63775-3

Vice President, Marketing – Science, Technology,


Cengage
& Math: Jason Sakos
200 Pier 4 Boulevard
Senior Director, Marketing: Michele McTighe Boston, MA 02210
USA
Marketing Manager: Cassie L. Cloutier

Marketing Development Manager: Cengage is a leading provider of customized learning solutions with
Samantha Best employees residing in nearly 40 different countries and sales in more than
125 countries around the world. Find your local representative at
Product Specialist: Mackenzie Paine
www.cengage.com.
IP Analyst: Ashley Maynard
To learn more about Cengage platforms and services, register or access
IP Project Manager: Cassidie Parker your online learning solution, or purchase materials for your course, visit
www.cengage.com.
Production Service: SPi Global
Notice to the Reader
Designer: Erin Griffin Publisher does not warrant or guarantee any of the products described

Cover Image Source: echo3005/ShutterStock.com herein or perform any independent analysis in connection with any of the
product information 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 Mexico
Print Number: 01 Print Year: 2020

Copyright 2022 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.
Brief Contents

prefacexiii Module 17
Polymorphism 309
Module 1
Computational Thinking 1 Module 18
Templates 319
Module 2
Programming Tools 15 Module 19
Linked List Data Structures 333
Module 3
Literals, Variables, and Constants 35 Module 20
Stacks and Queues 353
Module 4
Numeric Data Types and Expressions 49 Module 21
Trees and Graphs 371
Module 5
Character and String Data Types 63 Module 22
Algorithm Complexity and Big-O Notation 395
Module 6
Decision Control Structures 83 Module 23
Search Algorithms 411
Module 7
Repetition Control Structures 103 Module 24
Sorting Algorithms 427
Module 8
Arrays 125 Module 25
Processor Architecture 455
Module 9
Functions 145 Module 26
Data Representation 469
Module 10
Recursion 165 Module 27
Programming Paradigms 491
Module 11
Exceptions 185 Module 28
User Interfaces 507
Module 12
File Operations 205 Module 29
Software Development Methodologies 525
Module 13
Classes and Objects 231 Module 30
Pseudocode, Flowcharts, and Decision Tables 541
Module 14
Methods 245 Module 31
Unified Modeling Language 557
Module 15
Encapsulation 271
GLOSSARY 569
Module 16 Index 583
Inheritance 291

Copyright 2022 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.
Table of Contents

prefacexiii Build Tools 22


The Toolset 22
Module 1 Compilers 23
COMPUTATIONAL THINKING 1 Preprocessors and Linkers 24
Virtual Machines 25
Algorithms2 Interpreters 26
Algorithm Basics 2 Debugging Tools 27
Programming Algorithms 2 Programming Errors 27
“Good” Algorithms 3 Syntax Errors 28
Selecting and Creating Algorithms 4 Runtime Errors 29
Decomposition4 Semantic Errors 29
Decomposition Basics 4 Debugging Utilities 30
Structural Decomposition 5 IDEs and SDKs 32
Functional Decomposition 6 Integrated Development Environments 32
Object-Oriented Decomposition 7 Software Development Kits 32
Dependencies and Cohesion 7
Summary 33
Pattern Identification 8
Key Terms  34
Pattern Identification Basics 8
Repetitive Patterns 8
Module 3
Classification Patterns 9
Abstraction9 LITERALS, VARIABLES, AND
Abstraction Basics 9 CONSTANTS35
Classes and Objects 10
Literals36
Black Boxes 11
Numeric Literals 36
Levels of Abstraction 12
Character and String Literals 37
Summary12 Tricky Literals 38
Key Terms  13 Variables and Constants 38
Variables 38
Module 2 Constants 40
PROGRAMMING TOOLS 15 The Memory Connection 41
Assignment Statements 41
Programming Languages 16 Declaring Variables  41
Hello World! 16 Initializing Variables 42
Programming Language Basics 16 Assigning Variables 43
Syntax and Semantics 17
Input and Output 44
Core Elements 19
Your Toolbox 19 Input to a Variable  44
Output from a Variable 46
Coding Tools 20
Program Editors 20 Summary 46
Basic Structure 21 Key Terms  47

Copyright 2022 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.
Table of Contents v

Module 4 Module 6
Numeric Data Types and Decision Control
Expressions 49 Structures 83
Primitive Data Types 50 If-Then Control Structures 84
Data Types 50 Control Structures 84
Primitive Data Types 50 Decision Logic 85
Composite Data Types 51 If-Then Structures 85
Numeric Data Types 52 Relational Operators 87
Integer Data Types 52 The Equal Operator 87
Floating-Point Data Types 53 Using Relational Operators 88
Mathematical Expressions 54 Boolean Expressions and Data Types 89
Arithmetic Operators 54 Multiple Conditions 91
Order of Operations 56 If-Then-Else Structures 91
Compound Operators 56 Nested-If Structures 93
Numeric Data Type Conversion 58 Else If Structures 96
Convert Integers and Floating-Point Numbers 58 Fall Through 97
Rounding Quirks 59 Conditional Logical Operators 100
Formatting Output 60 The AND Operator 100
Formatted Output 60 The OR Operator 101
Formatting Parameters 60 Summary 102
Summary 62 Key Terms 102
Key Terms 62

Module 7
Module 5 Repetition Control
CHARACTER AND STRING DATA TYPES 63 Structures 103
Character Data Types 64 Count-Controlled Loops 104
Working with Character Data 64 Loop Basics 104
Character Memory Allocation 65 Control Statements 105
Digits 66 For-Loops 105
Character Output Format 67 User-Controlled Loops 108
Character Manipulation 68
Counters and Accumulators 109
String Data Types 69 Loops That Count 109
Working with String Data 69 Loops That Accumulate 111
Escape Characters 70
String Indexes 71
Nested Loops 112
Loops Within Loops 112
String Functions 72
Inner and Outer Loops 113
String Manipulation 72
String Length 72 Pre-Test Loops 116
Change Case 73 While-Loops 116
Find the Location of a Character 74 Infinite Loops 117
Retrieve a Substring 75 Breaking Out of Loops 118
Concatenation and Typecasting 76 Post-Test Loops 120
Concatenated Output 76 Do-Loops 120
Concatenated Variables 77 Test Conditions and Terminating
Coercion and Typecasting 78 Conditions 123
Summary 80 Summary 124
Key Terms 81 Key Terms 124

Copyright 2022 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 Programming with C++

Module 8 Pass by Reference 161


Namespaces 162
Arrays 125
Summary 163
Array Basics 126
Key Terms 163
Magic Rectangles 126
Array Characteristics 127
Array Use Cases 128 Module 10
One-Dimensional Arrays 128 Recursion 165
Initialize Numeric Arrays 128
Key Components of Recursion 165
Initialize String Arrays 130
The Recursive Mindset 165
Array Input and Output 130 Recursion Basics 167
Output an Array Element 130 When to Use Recursion 171
Index Errors 131
Using Recursion to Solve Complex
Traverse an Array 132
Problems 171
Input Array Elements 133
Designing Recursive Structures 171
Array Operations 135 Linear Recursion 174
Change an Array Element 135 Branching Recursion 175
Find an Array Element 135
Managing Memory during Recursion 179
Sum Array Elements 137
Memory Management 179
Two-Dimensional Arrays 137 Stable Recursion 182
Two-Dimensional Array Basics 137
Summary 183
Initialize a Two-Dimensional Array 138
Output a Two-Dimensional Array 139 Key Terms 183
Sum Array Columns and Rows 141
Summary 143 Module 11
Key Terms 144 Exceptions 185
Defining Exceptions 185
Module 9 Errors in Code 185
Functions 145 Exception Types 187

Function Basics 146 Dealing with Exceptions 189


Function Classifications 146 Handling Others’ Exceptions 189
Programmer-Defined Functions 146 Try and Catch Blocks 189
Flow of Execution 147 Using Exceptions 198
Function Advantages 147 Throwing Exceptions 198
Void Functions 148 When to Bail 202
Void Function Basics 148 Summary 203
Function Pseudocode 149
Key Terms 203
Functions with Parameters 150
Function Parameters 150
Module 12
Function Arguments 150
The Handoff 152 File Operations 205
Return Values 153 File Input and Output 206
Return Values 153 The Purpose of Files 206
Return Type 156 Anatomy of a File 210
Function Signature 157 File Usage 212
Scope 157 Processing a File 214
Scope Basics 157 Accessing Files 214
Pass by Value 160 Streaming and Buffering 214

Copyright 2022 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.
Table of Contents vii

Reading from a File 216 Method Cascading and Method Chaining 263
Opening a File for Reading 216 Calling Multiple Methods on the Same Object 263
Reading from a File 218 Using Constructors 266
Closing a File 222 Specifying How to Construct an Object 266
Closing Files after Use 222 Constructing an Object from Another Object 268
Trying to Close a File 222 Summary 269
Creating and Writing New Files 222
Key Terms 269
Creating a File 222
Opening a File for Writing 223 Module 15
Writing to and Appending a File 224
Anticipating Exceptions 228 Encapsulation 271
Summary 229 Components of Class Structure 271
Key Terms 230 Data Hiding 271
Designing Objects 273
Self-Reference Scope 276
Module 13 Accessor and Mutator Context 277
Classes and Objects 231 Viewing Data from an Object 277
Classes in Object-Oriented Programming 232 Changing Data in an Object 278
Representing the Real World with Code 232 Using Constructors 280
Using Classes 232 Parameters and Arguments 280
Class Components 233 Default Parameters and Constructor
Using Objects 236 Overloading 281
Creating Objects 236 Encapsulation Enforcement
Objects as Variables 238 with Access Modifiers 283
Object-Oriented Features and Principles 238 Access Modifiers 283
Using Static Elements in a Class 239 Public Variables and Methods 283
Private Variables and Methods 284
Static Member Variables 239
Static Methods 240 Interfaces and Headers 286
Static Classes 241 Interfaces 286
Characteristics of Objects Programming an Interface 287
in Object-Oriented Programs 242 Summary 290
Object Identity 242 Key Terms 290
Object State 242
Object Behavior 243 Module 16
Summary 244 Inheritance 291
Key Terms 244 Using Inheritance 291
Creating Classes from Other Classes 291
Module 14 Family Trees in OOP 292
Methods 245 Levels of Access 295
Necessary Components for Inheritance 296
Using Methods 245
Defining a Parent Class 296
Why Use Methods? 245 Defining a Child Class 297
Anatomy of a Method 251
Creating a Child Class That Inherits
Using Methods 251
from a Parent Class 298
Changing the Default Behavior
Inheritance Syntax 298
of an Object 255 Customizing Behavior 301
Using Objects as Regular Variables 255
Overloading Methods 258 Summary 307
Setting One Object to Equal Another 262 Key Terms 307

Copyright 2022 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 Programming with C++

Module 17 The Find Method 346


The Insert Method 347
Polymorphism 309
Summary 350
The Purpose of Polymorphism 309
Key Terms 351
Flexibility While Coding 309
Dynamic Binding Under the Hood 314
Polymorphism Basics 314 Module 20
Classes Within Classes 314 Stacks and Queues 353
Objects as Other Objects 315 Stacks 353
Virtual Functions 316 Stack Basics 353
Anticipating Customization 316 Stack Use Cases 355
Abstract Classes 317 Built-in Stacks 356
Summary 318 Code a Stack 357

Key Terms 318


Queues 362
Queue Basics 362
Module 18 Queue Use Cases 363
Code a Queue 364
Templates 319
Summary 369
Template Basics 319
Key Terms 369
Data Abstraction 319
Template Structure and Use 322
Module 21
Tricky Templating 328
Advanced Templating 328
Trees and Graphs 371
Templated Objects as Arguments 330 Nonlinear Data Structures 371
Templates as a Problem-Solving Linear versus Nonlinear Structures 371
Approach 331 Nonlinear Building Blocks 373
Designing a Template 331 Tree Structures 373
When to Use Templates 331 Tree Basics 373
Summary 331 Tree Properties 376
Trees as Recursive Structures 376
Key Terms 332
Solving Problems Using Trees 379
Module 19 Tree Applications 379
Linked List Data Data Storage in Trees 380
Graph Structures 387
Structures 333
Graph Basics 387
Linked List Structures 334 Directed and Undirected Graphs 388
Data Structure Selection 334 Solving Problems with Graphs 388
Data Structure Implementation 335 Graph Applications 388
Linked List Basics 336 Computing Paths 389
Types of Linked Lists 337
Summary 394
Singly Linked Lists 337
Doubly Linked Lists 338 Key Terms 394
Circular Linked Lists 339
Linked List Characteristics 339 Module 22
Code a Linked List 342 Algorithm Complexity
The Node Class 342 and Big-O Notation 395
The LinkedList Class 343
The Append Method 343 Big-O Notation 396
Linked List Traversal 345 Algorithm Complexity 396

Copyright 2022 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.
Visit https://ebookluna.com
now to explore a diverse
collection of ebooks available
in formats like PDF, EPUB, and
MOBI, compatible with all
devices. Don’t miss the chance
to enjoy exciting offers and
quickly download high-quality
materials in just a few simple
steps!
Table of Contents ix

Asymptotic Analysis 397 Quicksort 438


Asymptotic Notation 398 Defining the Quicksort Algorithm 438
Time Complexity 398 Quicksort Properties 446
Big-O Metrics 398 Merge Sort 447
Constant Time 399 Defining the Merge Sort Algorithm 447
Linear Time 399 Merge Sort Properties 453
Quadratic Time 400
Summary 454
Logarithmic Time 401
Key Terms 454
Space Complexity 403
Memory Space 403 Module 25
Constant Space Complexity 404
Linear Space Complexity 404 Processor Architecture 455
Complexity Calculations 405 Processor Organization 456
Line-by-Line Time Complexity 405 Integrated Circuits 456
Combine and Simplify 406 Moore’s Law 458
A Mystery Algorithm 407 CPUs 458
Low-Level Instruction Sets 459
Summary 409
Microprocessor Instruction Sets 459
Key Terms 409 RISC and CISC 460
Machine Language 460
Module 23 Assembly Language 461

Search Algorithms 411 Microprocessor Operations 462


Processing an Instruction 462
Using Search Algorithms 412 The Instruction Cycle 462
Search Basics 412 High-Level Programming Languages 464
Performing a Linear Search 413 Evolution 464
Looking for a Needle in a Haystack 413 Teaching Languages 465
Evaluating Search Time 416 The C Family 465
Web Programming Languages 466
Performing a Binary Search 416 Characteristics 466
Shrinking the Search Space 416 Advantages and Disadvantages 467
Implementing Binary Search 418
Summary 467
Using Regular Expressions
Key Terms 468
in Search Algorithms 423
Specifying a Search Pattern 423 Module 26
Regular Expression Search Operators 423
Data Representation 469
Summary 426
Bits and Bytes 470
Key Terms 426
Digital Data 470
Bits 471
Module 24 Bytes 472
Sorting Algorithms 427 Binary 474
Binary Numbers 474
Qualities of Sorting Algorithms 428 Binary to Decimal 475
Ordering Items 428 Decimal to Binary 476
Time Complexity in Sorting Algorithms 428 Binary Addition 477
Sorting Properties 430 Negative Numbers 478
Bubble Sort 431 Hexadecimal 480
Defining the Bubble Sort Algorithm 431 Colors 480
Bubble Sort Properties 437 Hexadecimal Numbers 481

Copyright 2022 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 Programming with C++

Binary-Hex-Binary Conversions 481 Speech Synthesis 516


Hex-Decimal Conversion 482 Designing Programs for Voice User Interfaces 517
Information Density 483 Virtual Environment Interfaces 517
ASCII and Unicode 483 Virtual Environments 517
ASCII 483 Virtual Environment Interface Components 518
Extended ASCII 484 Programming the Virtual Interface 519
Unicode 485 Accessibility and Inclusion 520
Memory Allocation 486 Accessibility Guidelines 520
Memory and Storage 486 Inclusive Design 521
Storage Devices 487 Summary 524
Memory 487
Key Terms 524
Summary 489
Key Terms 489
Module 29
Software Development
Module 27
Methodologies 525
Programming Paradigms 491
Software Development 526
Imperative and Declarative Paradigms 492
The Software Development Life Cycle 526
Think Outside the Box 492
Efficiency, Quality, and Security 527
The Procedural Paradigm 493 The Waterfall Model 528
Procedural Basics 493
Structured Analysis and Design 528
Characteristics of Procedural Programs 494
Waterfall Advantages and Disadvantages 529
Procedural Paradigm Applications 496
The Agile Model 530
The Object-Oriented Paradigm 497
Incremental Development 530
Objects, Classes, and Methods 497
Agile Methodologies 530
Characteristics of Object-Oriented Programs 499
Agile Advantages and Disadvantages 531
Object-Oriented Applications 501
Coding Principles 532
Declarative Paradigms 501
Efficient Coding 532
Declarative Basics 501
Modularized Code 533
Characteristics of the Declarative
Clean Coding 534
Paradigm 504
Secure Coding 534
Applications for Declarative Paradigms 504
Success Factors 536
Summary 505 Testing 536
Key Terms 505 Levels of Testing 536
Unit Testing 537
Module 28 Integration Testing 538
System Testing 539
User Interfaces 507 Acceptance Testing 539
User Interface Basics 508 Regression Testing 539
UI and UX 508 Summary 540
UI Components 508
Key Terms 540
Selecting a UI 510
Command-Line User Interfaces 510
Module 30
Command-Line Basics 510
Command-Line Program Design 510 Pseudocode, Flowcharts,
Graphical User Interfaces 512 and Decision Tables 541
GUI Basics 512 Pseudocode 542
GUI Program Design 514
From Algorithms to Pseudocode 542
Voice User Interfaces 515 Pseudocode Basics 544
Voice Interface Basics 515 Pseudocode Guidelines 545
Speech Recognition 515 Writing Pseudocode 547

Copyright 2022 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.
Table of Contents xi

Flowcharts 548 UML Diagram Parts 558


Flowchart Basics 548 Class Diagram Basics 558
Drawing Flowcharts 548 Use Case Diagram Basics 559
Flowchart Tools 549 Sequence Diagrams 561
Decision Tables 551 Using UML to Structure Programs 562
Decision Table Basics 551 UML Associations 562
List the Conditions 551 Translating UML to Code 564
List All Possible Alternatives 552 Summary 568
Specify Results and Rules 552
Interpret Rules 553 Key Terms 568
Optimize the Rules 554
Check for Completeness and Accuracy 555
GLOSSARY 569
Summary 555
index 583
Key Terms 556

Module 31
Unified Modeling Language 557
Purpose of Unified Modeling
Language (UML) 557
Communicating Ideas to Other Programmers 557

Copyright 2022 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 2022 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.
Preface

Welcome to Readings from Programming with C11.


This text includes the stand-alone lessons and read-
C11 Version
ings from MindTap for Programming with C11 and is We recommend downloading the latest version of
intended to be used in conjunction with the MindTap C11 before beginning this text. C1114 was used to
Reader for a complete learning experience. test all C11 code presented in the module figures.

MindTap Overview MindTap Features


Programming with C 11 presents conceptual, lan- In addition to the readings included within this text,
guage-agnostic narrative with language-specific assets, the MindTap includes the following:
ungraded C11 coding Snippets, language-agnostic test Course Orientation: Custom videos and readings pre-
banks, and additional instructor resources. The goal of pare students for the material and coding experiences
this digital product is to develop content around the they will encounter in their course.
concepts that are essential for understanding Com-
Videos: Animated videos demonstrate new program-
puter Science from a language-agnostic perspective.
ming terms and concepts in an easy-to-understand for-
Learners will gain a foundational understanding of
mat, increasing student confidence and learning.
procedural programming, computer science concepts,
and object-oriented programming. Instructors have Coding Snippets: These short, ungraded coding activities
identified the need for language-agnostic, conceptual are embedded within the MindTap Reader and provide
content that can be paired with hands-on practice in students an opportunity to practice new programming
a specific language. This 31-module text is designed to concepts “in-the-moment.” Additional language-specific
provide that conceptual content paired with language- “bridge content” helps transition the student from con-
specific examples and hands-on learning activities in ceptual understanding to application of C11 code.
C11. Language-specific Examples: Figures within the nar-
rative illustrate the application of general concepts in
C11 code.
Course Objectives:
• Develop a foundational knowledge of
coding principles, vocabulary, and core Instructor & Student Resources
concepts. Additional instructor and student resources for
• Use new foundational knowledge to this product are available online. Instructor assets
learn C11 programming skills. include an Instructor’s Manual, Teaching Online
• Practice emerging coding skills in a low- Guide, ­PowerPoint® slides, and a test bank powered
risk environment. by ­Cognero®. Student assets include source code
• Apply learned concepts and skills to files and coding Snippets ReadMe. Sign up or sign in
assignments/activities that mimic real- at www.cengage.com to search for and access this
world experiences and environments. product and its online resources.

Copyright 2022 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 2022 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.
About the Authors

Dr. Kyla McMullen is a tenure-track faculty member published research in the areas of procedural genera-
in the University of Florida’s Computer & Information tion, video game enjoyment factors, and freshwater
Sciences & Engineering Department, specializing in algae identification with HCI.
Human-Centered Computing. Her research interests June Jamrich Parsons is an educator, digital book
are in the perception, applications, and development pioneer, and co-author of Texty and McGuffey Award-
of 3D audio technologies. Dr. McMullen has authored winning textbooks. She co-developed the first com-
over 30 manuscripts in this line of research and is the mercially successful multimedia, interactive digital
primary investigator for over 2 million dollars’ worth textbook; one that set the bar for platforms now
of sponsored research projects. being developed by educational publishers. Her
Dr. Elizabeth A. Matthews is an Assistant Professor of career includes extensive classroom teaching, prod-
Computer Science at Washington and Lee University. uct design for eCourseware, textbook authoring for
She has taught computer science since 2013 and has Course Technology and Cengage, Creative Strategist
been an active researcher in human–computer inter- for MediaTechnics Corporation, and Director of Con-
action and human-centered computing. Matthews has tent for Veative Virtual Reality Labs.

Copyright 2022 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 2022 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.
Acknowledgments

The unique approach for this book required a ­seasoned friends who help me to remain sane, remind me of who
team. Our thanks to Maria Garguilo who ushered the I am, and never let me forget whose I am.
manuscripts through every iteration and kept tight Elizabeth Matthews: I want to thank my parents,
rein on the schedule; to Mary E. Convertino who sup- Drs. Geoff and Robin Matthews, for their support and
plied her expertise in learning design; to Lisa R
­ uffolo understanding in my journey. I would also like to thank
for her excellent developmental edit; to Courtney my advisor, Dr. Juan Gilbert, for seeing my dream to
Cozzy who coordinated the project; to Kristin McNary the end. Finally, I would like to thank my cats, Oreo
for her leadership in Cengage’s computing materials; and Laptop, who made sure that writing this book was
to Rajiv Malkan (Lone Star College) for his instruc- interrupted as often as possible.
tional input; to Wade Schofield (Liberty University) June Jamrich Parsons: Computer programming can
for his reviewing expertise; and to John Freitas for his be a truly satisfying experience. The reward when a
meticulous code review. It was a pleasure to be part program runs flawlessly has to bring a smile even
of this professional and talented team. We hope that to the most seasoned programmers. Working with
instructors and students will appreciate our efforts three programming languages for this project at the
to provide this unique approach to computer science same time was certainly challenging but provided
and programming. insights that can help students understand com-
Kyla McMullen: Above all things, I would like to thank putational thinking. I’ve thoroughly enjoyed work-
God for giving me the gifts and talents that were uti- ing with the team to create these versatile learning
lized to write this book. I would like to thank my amaz- resources and would like to dedicate my efforts to
ing husband Ade Kumuyi for always being my rock, my mom, who has been a steadfast cheerleader for
sounding board, and biggest cheerleader. I thank my me throughout my career. To the instructors and stu-
parents, Rita and James McMullen for all of their sacri- dents who use this book, my hope is that you enjoy
fices to raise me. Last but not least, I thank my spirited programming as much as I do.

Copyright 2022 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 2022 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.
Visit https://ebookluna.com
now to explore a diverse
collection of ebooks available
in formats like PDF, EPUB, and
MOBI, compatible with all
devices. Don’t miss the chance
to enjoy exciting offers and
quickly download high-quality
materials in just a few simple
steps!
MODULE

1
COMPUTATIONAL
THINKING
LEARNING OBJECTIVES:
1.1 ALGORITHMS 1.2.3 Differentiate the concepts of algorithms and
decomposition.
1.1.1 Define the term “algorithm” as a series of steps for
solving a problem or carrying out a task. 1.2.4 Identify examples of structural decomposition.
1.1.2 State that algorithms are the underlying logic for 1.2.5 Identify examples of functional decomposition.
computer programs. 1.2.6 Identify examples of object-oriented decomposition.
1.1.3 Define the term “computer program.” 1.2.7 Provide examples of decomposition in technology
1.1.4 Provide examples of algorithms used in everyday applications.
technology applications. 1.2.8 Explain how dependencies and cohesion relate to
1.1.5 Confirm that there can be more than one algorithm decomposition.
for a task or problem and that some algorithms 1.3 PATTERN IDENTIFICATION
may be more efficient than others.
1.3.1 Define the term “pattern identification” as a technique
1.1.6 Explain why computer scientists are interested in for recognizing similarities or characteristics among
algorithm efficiency. the elements of a task or problem.
1.1.7 List the characteristics of an effective algorithm. 1.3.2 Identify examples of fill-in-the-blank patterns.
1.1.8 Write an algorithm for accomplishing a simple, 1.3.3 Identify examples of repetitive patterns.
everyday technology application.
1.3.4 Identify examples of classification patterns.
1.1.9 Write an alternate algorithm for an everyday
technology task. 1.3.5 Provide examples of pattern identification in the real
world and in technology applications.
1.1.10 Select the more efficient of the two algorithms you
have written. 1.4 ABSTRACTION
1.2 DECOMPOSITION 1.4.1 Define the term “abstraction” as a technique for
generalization and for simplifying levels of complexity.
1.2.1 Define the term “decomposition” as a technique for
dividing a complex problem or solution into smaller 1.4.2 Explain why abstraction is an important computer
parts. science concept.
1.2.2 Explain why decomposition is an important tool for 1.4.3 Provide an example illustrating how abstraction can
computer scientists. help identify variables.

Copyright 2022 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 PROGRAMMING WITH C++

1.4.4 Provide examples of technology applications that 1.4.6 Explain how the black box concept is an
have abstracted or hidden details. implementation of abstraction.
1.4.5 Provide an example illustrating the use of a class as 1.4.7 Identify appropriate levels of abstraction.
an abstraction of a set of objects.

1.1 ALGORITHMS
Algorithm Basics (1.1.1, 1.1.4)
A password might not be enough to protect your online accounts. Two-factor authentication adds an extra layer
of protection. A common form of two-factor authentication sends a personal identification number (PIN) to your
cell phone. To log in, you perform the series of steps shown in Figure 1-1.

Connect to the site’s login page.


Enter your user ID.
Enter your password.
Wait for a text message containing a PIN
to arrive on your smartphone.
On the site’s the login page, enter the PIN.

Figure 1-1 Steps for two-factor authentication

The procedure for two-factor authentication is an example of an algorithm. In a general sense, an algorithm
is a series of steps for solving a problem or carrying out a task.
Algorithms exist for everyday tasks and tasks that involve technology. Here are some examples:

• A recipe for baking brownies


• The steps for changing a tire
• The instructions for pairing a smart watch with your phone
• The payment process at an online store
• The procedure for posting a tweet

Programming Algorithms (1.1.2, 1.1.3, 1.1.5)


Algorithms are also an important tool for programmers. A programming algorithm is a set of steps that speci-
fies the underlying logic and structure for the statements in a computer program. You can think of programming
algorithms as the blueprints for computer programs.
A computer program is a set of instructions, written in a programming language such as C++, Python, or
Java, that performs a specific task when executed by a digital device. A computer program is an implementation
of an algorithm.

Copyright 2022 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.
Module 1 Computational Thinking 3

Q Programming algorithms tell the computer what to do. Can you tell which of these algorithms
is a programming algorithm?
Algorithm 1: Algorithm 2:
Connect to the website’s login page. Prompt the user to enter a user ID.
Enter your user ID. Prompt the user to enter a password.
Enter your password. Make sure that the user ID and password match.
Wait for a text message containing a PIN to If the user ID and password match:
arrive on your smartphone. Generate a random PIN.
On the website’s login page, enter the PIN. Send the PIN to user’s phone.
Prompt the user to enter the PIN.
If the PIN is correct:
Allow access.

A Algorithm 1 is not a programming algorithm because it outlines instructions for the user.
Algorithm 2 is a programming algorithm because it specifies what the computer is supposed
to do. When you formulate a programming algorithm, the instructions should be for the
computer, not the user.

There can be more than one programming algorithm for solving a problem or performing a task, but some
algorithms are more efficient than others.

Q Here are two algorithms for summing the numbers from 1 to 10. Which algorithm is more
efficient?
Algorithm 1: Algorithm 2:
Add 1 1 2 to get a total. Get the last number in the series (10).
Repeat these steps nine times: Divide 10 by 2 to get a result.
Get the next number. Add 10 1 1 to get a sum.
Add this number to the total. Multiply the result by the sum.

A Both algorithms contain four instructions, but Algorithm 2 is more efficient. You can use it to
amaze your friends by quickly calculating the total in only four steps. Algorithm 1 is also four
lines long, but two of the instructions are repeated nine times. Counting the first step, that’s
19 steps to complete this task!

“Good” Algorithms (1.1.6, 1.1.7)


Computer scientists are interested in designing what they call “good” algorithms. A good algorithm tends
to produce a computer program that operates efficiently, quickly, and reliably. Good algorithms have these
characteristics:
Input: The algorithm applies to a set of specified inputs.
Output: The algorithm produces one or more outputs.
Finite: The algorithm terminates after a finite number of steps.
Precise: Each step of the algorithm is clear and unambiguous.
Effective: The algorithm successfully produces the correct output.

Copyright 2022 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 PROGRAMMING WITH C++

When formulating an algorithm, you can easily check to make sure it satisfies all the criteria for a good algo-
rithm. You can see how these criteria apply to an algorithm in Figure 1-2.

Is there input? Yes.

Get the last number in the series (10).


Divide 10 by 2 to get a RESULT. Are the steps precise and
Add 10 + 1 to get a SUM. unambiguous? Yes.
Multiply the RESULT by the SUM to
Does the algorithm terminate? Does the algorithm produce
produce a total.
Yes, after the fourth step. the correct output?
Yes, it is 55.
Is there output? Yes.

Figure 1-2 Is this a good algorithm?

Selecting and Creating Algorithms (1.1.8, 1.1.9, 1.1.10)


Before coding, programmers consider various algorithms that might apply to a problem. You can come up with
an algorithm in three ways:
Use a standard algorithm. Programmers have created effective algorithms for many computing
tasks, such as sorting, searching, manipulating text, encrypting data, and finding the shortest path.
When you are familiar with these standard algorithms, you can easily incorporate them in programs.
Perform the task manually. When you can’t find a standard algorithm, you can formulate an
algorithm by stepping through a process manually, recording those steps, and then analyzing their
effectiveness.
Apply computational thinking techniques. Computational thinking is a set of techniques designed
to formulate problems and their solutions. You can use computational thinking techniques such as
decomposition, pattern identification, and abstraction to devise efficient algorithms. Let’s take a look
at these techniques in more detail.

1.2 DECOMPOSITION
Decomposition Basics (1.2.1)
A mobile banking app contains many components. It has to provide a secure login procedure, allow users to
manage preferences, display account balances, push out alerts, read checks for deposit, and perform other tasks
shown in Figure 1-3.
The algorithm for such an extensive app would be difficult to formulate without dividing it into smaller parts,
a process called decomposition. When devising an algorithm for a complex problem or task, decomposition can
help you deal with smaller, more manageable pieces of the puzzle.

Copyright 2022 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.
Module 1 Computational Thinking 5

Fraud alerts

Change user
Secure login
preferences

Account balance Deposits

iStock.com/vector.S
Pay bills Withdrawals

Transfer money

Figure 1-3 A mobile banking app handles many


interacting tasks

Structural Decomposition (1.2.2, 1.2.3, 1.2.4, 1.2.7)


The first step in decomposition is to identify structural units that perform distinct tasks. Figure 1-4 illustrates
how you might divide a mobile banking app into structural units, called modules.

Mobile banking

Passcode/challenge Account Payments and


Secure login
question changes management transfers

Two-factor
Balances Bill pay
authentication

Fingerprint Mobile check


Alerts
sign-in deposits

Direct Money
deposits transfers

Figure 1-4 Structural decomposition diagram

Structural decomposition is a process that identifies a hierarchy of structural units. At the lowest levels
of the hierarchy are modules, indicated in yellow in Figure 1-4, that have a manageable scope for creating
algorithms.

Copyright 2022 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.
6 PROGRAMMING WITH C++

Q Which module of the hierarchy chart is not fully decomposed?


A The module for modifying passwords and challenge questions could be further decomposed
into two modules: one module that allows users to change their passwords and one for
changing their challenge questions.

Here are some tips for creating a structural decomposition diagram:

• Use a top-down approach. The nodes at the top break down into component parts in the nodes below them.
• Label nodes with nouns and adjectives, rather than verbs. For example, “Account management” is the
correct noun phrase, rather than a verb phrase, such as “Manage accounts.”
• Don’t worry about sequencing. Except for the actual login process, the components in a mobile bank-
ing system could be accessed in any order. This is a key difference between an algorithm and decom-
position. An algorithm specifies an order of activities, whereas decomposition specifies the parts of
a task.

Functional Decomposition (1.2.5)


Functional decomposition breaks down modules into smaller actions, processes, or steps. Figure 1-5 illustrates
a functional decomposition of the two-factor authentication module.

Verify login attempts

Verify password Verify PIN

Validate Compare
Generate Send PIN
Prompt for Prompt for user ID and Prompt user user-entered Handle
one-time to
user ID password password for PIN PIN to mismatches
PIN mobile
match generated PIN

Look up Compare Look up Generate


stored entered Handle user text Nodes in green are
user ID and date with mismatches mobile message specific enough to
password stored data number with PIN become steps in an
algorithm.

Nodes in yellow
require further
decomposition.

Figure 1-5 Functional decomposition diagram

Notice how the levels of the functional decomposition diagram get more specific until the nodes in the lowest
levels begin to reveal instructions that should be incorporated in an algorithm.
Here are some tips for constructing functional decomposition diagrams and deriving algorithms from them:

• Label nodes with verb phrases. In contrast to the nodes of a structural decomposition diagram, the
nodes of a functional decomposition are labeled with verb phrases that indicate “what” is to be done.
• Sequence from left to right. Reading left to right on the diagram should correspond to the sequence in
which steps in the algorithm are performed.

Copyright 2022 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.
Module 1 Computational Thinking 7

Object-Oriented Decomposition (1.2.6)


Another way to apply decomposition to a module is to look for logical and physical objects that a computer
program will manipulate. Figure 1-6 illustrates an object-oriented decomposition of the two-factor authentica-
tion module.

Each node
represents an
object.
PIN generator
Methods
Login screen Attribute: One-time PIN describe what an
object can do.
Attribute: Entered user ID Method: Generate random PIN
Attribute: Entered password Method: Send PIN to mobile
number
Method: Display login boxes
Method: Verify entered user ID
and password
Method: Verify PIN
Method: Handle mismatches

Valid user

Attribute: Valid user ID


Attribute: Valid password Attributes
Attribute: Mobile number describe an
object.

Figure 1-6 Object-oriented decomposition diagram

An object-oriented decomposition does not produce a hierarchy. Instead it produces a collection of objects
that can represent people, places, or things.
Tips for object-oriented decomposition:

• Node titles are nouns. Each node in the object-oriented decomposition diagram is labeled with a noun.
• Attributes are nouns. A node can contain a list of attributes, which relate to the characteristics of an object.
• Methods are verb phrases. An object can also contain methods, which are actions that an object can
perform. You may need to devise an algorithm for each method.
• Sketch in connection arrows. Connection arrows help you visualize how objects share data.

Dependencies and Cohesion (1.2.8)


You might wonder if there is a correct way to decompose a problem or task. In practice, there may be several
viable ways to apply decomposition, but an effective breakdown minimizes dependencies and maximizes cohe-
sion among the various parts.
The principles of decomposition are:

• Minimize dependencies. Although input and output may flow between nodes, changing the instructions
in one module or object should not require changes to others.
• Maximize cohesion. Each object or module contains attributes, methods, or instructions that perform a
single logical task or represent a single entity.

Copyright 2022 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.
8 PROGRAMMING WITH C++

1.3 PATTERN IDENTIFICATION


Pattern Identification Basics (1.3.1, 1.3.2)
The Amaze-Your-Friends math trick for quickly adding numbers from 1 to 10 is very simple:
Get the last number in the series (10).
Divide 10 by 2 to get a result.
Add 10 1 1 to get a sum.
Multiply the result by the sum.

Q Try the algorithm yourself. What is your answer?


A If your math is correct, your answer should be 55.

Now, what if the challenge is to add the numbers from 1 to 200? That algorithm looks like this:
Get the last number in the series (200).
Divide 200 by 2 to get a result.
Add 200 1 1 to get a sum.
Multiply the result by the sum.
Notice a pattern? This fill-in-the-blank algorithm works for any number:
Get the last number in the series (____________________).
Divide ____________________ by 2 to get a result.
Add ____________________ 1 1 to get a sum.
Multiply the result by the sum.
The process of finding similarities in procedures and tasks is called pattern identification. It is a useful com-
putational thinking technique for creating algorithms that can be used and reused on different data sets. By recog-
nizing the pattern in the Amaze-Your-Friends math trick, you can use the algorithm to find the total of any series
of numbers.

Repetitive Patterns (1.3.3)


In addition to fill-in-the-blank patterns, you might also find repetitive patterns as you analyze tasks and problems.
Think about this algorithm, which handles logins to a social media site:
Get a user ID.
Get a password.
If the password is correct, allow access.
If the password is not correct, get the password again.
If the password is correct, allow access.
If the password is not correct, get the password again.
If the password is correct, allow access.
If the password is not correct, get the password again.
If the password is correct, allow access.
If the password is not correct, lock the account.

Copyright 2022 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.
Module 1 Computational Thinking 9

Q How many repetition patterns do you recognize?


A Two lines are repeated three times:
If the password is not correct, get the password again.
If the password is correct, allow access.

Recognizing this repetition, you can streamline the algorithm like this:
Get a password.
Repeat three times:
If the password is correct, allow access.
If the password is not correct, get the password again.
If the password is correct, allow access.
If the password is not correct, lock the account.

Classification Patterns (1.3.4, 1.3.5)


Everyone who subscribes to a social media site has a set of login credentials. Here are Lee’s and Priya’s:
Lee’s login credentials: Priya’s login credentials:
Lee’s user ID: LeezyBranson@gmail.com Priya’s user ID: PriyaMontell@gmail.com
Lee’s password: MyCat411 Priya’s password: ouY52311v
Lee’s mobile number: 415-999-1234 Priya’s mobile number: 906-222-0987
The series of attributes that define each user’s login credentials have a pattern of similarities. Each user
has three attributes: a user ID, a password, and a mobile number. By recognizing this pattern, you can create a
template for any user’s login credentials like this:
User ID: ____________________
Password: ____________________
Mobile number: ____________________
You can often discover classification patterns in the attributes that describe any person or object. Identify-
ing classification patterns can help you design programs that involve databases because the template identifies
fields, such as User ID, that contain data.
Classification patterns also come in handy if you want to design programs based on the interactions among
a variety of objects, rather than a step-by-step algorithm. In some programming circles, templates are called
classes because they specify the attributes for a classification of objects. For example, people classified as social
media subscribers have attributes for login credentials. Vehicles classified as cars have attributes such as color,
make, model, and VIN number. Businesses classified as restaurants have a name, hours of operation, and a menu.

1.4 ABSTRACTION
Abstraction Basics (1.4.1, 1.4.2, 1.4.3)
Think back to the Amaze-Your-Friends math trick. By identifying a pattern, you formulated a general algorithm
that works for a sequence of any length, whether it is a sequence of 1 to 10 or 1 to 200.
Get the last number in the series (____________________).
Divide ____________________ by 2 to get a result.

Copyright 2022 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.
10 PROGRAMMING WITH C++

Add ____________________ 1 1 to get a sum.


Multiply the result by the sum.
In this algorithm, the blank line is an abstraction that represents the last number in the sequence. An abstraction
hides details, simplifies complexity, substitutes a generalization for something specific, and allows an algorithm to
work for multiple inputs.
Abstraction is a key element of computational thinking and helps programmers in a multitude of ways.
If you’ve programmed before, you’ll recognize that in the Amaze-Your-Friends algorithm, the blanks could
become a variable with a name such as last_number. Result and sum are also variables because they represent
values that change depending on the numbers in the sequence
Get the last_number
Divide last_number by 2 to get a result.
Add last_number 1 1 to get a sum.
Multiply the result by the sum.
A variable is an abstraction because rather than representing a specific number, it can be used to represent
many different numbers.

Classes and Objects (1.4.4, 1.4.5)


Abstraction has uses other than identifying variables. It is important for understanding how to represent real-
world and conceptual objects. Remember the pattern you discovered for social media login credentials? With a
little modification, it becomes a template that can be applied to any subscriber:
Class: LoginCredentials
Attribute: user_ID
Attribute: user_password
Attribute: mobile_number
The LoginCredentials class is an abstraction that contains a set of attributes. The class was formed by
abstracting away, or removing, details for any specific subscriber.
Abstractions are handy for any programs that deal with real-world objects in addition to technology objects,
such as login credentials.

Q Can you envision a class that’s an abstraction of the collection of objects shown in Figure 1-7?
Budnyi/Shutterstock.com

12 oz water glass 5 oz martini glass 8 oz wine glass 10 oz water goblet

Figure 1-7 Abstract the details from this collection of glassware

Copyright 2022 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.
Visit https://ebookluna.com
now to explore a diverse
collection of ebooks available
in formats like PDF, EPUB, and
MOBI, compatible with all
devices. Don’t miss the chance
to enjoy exciting offers and
quickly download high-quality
materials in just a few simple
steps!
Other documents randomly have
different content
of great value as to the life of the population, the influence of external
conditions, etc.
The most important investigation of this kind carried out at
Rothamsted was organised by Mr. Cutler.[3] A team of six workers was
assembled, and for 365 days without a break they counted every day
the ciliates, the amœbæ, the flagellates, and the bacteria in a plot of
arable ground, distinguishing no less than seventeen different kinds of
protozoa. The conclusions arrived at were carefully tested by the
Statistical Department.
Of the protozoa the flagellates were found to be the most numerous,
the amœbæ came next, and the ciliates were by far the fewest. The
numbers of each organism varied from day to day in a way that
showed conclusively the essentially trophic nature of the protozoan
population. The numbers of amœbæ—especially Dimastigamœba and
of a species called α—were sharply related to the numbers of
bacteria: when the amœbae were numerous the bacteria were few,
and vice versa. Detailed examination showed that the amœbæ were
probably the cause of the fluctuations in the bacterial numbers, but Mr.
Cutler has not yet been able to find why the amœbæ fluctuated; it
does not appear that temperature, moisture content, air supply or food
supply were determining causes. The flagellates and ciliates also
showed large fluctuations, amounting in one case—Oicomonas—to a
definite periodicity, apparently, however, not related to bacterial
numbers, or, so far as can be seen, to external conditions of moisture,
temperature and food supply, and showing no agreement with the
fluctuations of the amœbæ. However, one cannot be certain that lack
of agreement between curves expressing protozoan numbers and
physical factors implies absence of causal relationships: the
observations (though the best that can yet be made) are admittedly
not complete. If we saw only the end of the bough of a tree, and could
see no connection with a trunk, we might have much difficulty in
finding relationships between its motion and the wind; whatever the
direction of the wind it would move backwards and forwards in much
the same way, and even when the wind was blowing along the plane
of its motion it would just as often move against the wind as with it.
Meanwhile evidence was obtained that the twenty-four hour interval
adopted by the protozoological staff was too long for bacteria, and
accordingly the Bacteriological Department, under Mr. Thornton,
refined the method still further. Bacterial counts were made every two
hours, day and night, for several periods of sixty or eighty hours
without a break. The shape of the curve suggests that two hours is
probably close enough, and for the present counts at shorter intervals
are not contemplated. But there is at least one maximum and one
minimum in the day, although the bacterial day does not apparently
correspond with ours, nor can any relationship be traced with the
diurnal temperature curve.
The nitrate content of the soil was simultaneously determined by Mr.
Page and found to vary from hour to hour, but the variations did not
sharply correspond with the bacterial numbers; this, however, would
not necessarily be expected. The production of nitrate involves various
stages, and any lag would throw the nitrate and bacterial curves out of
agreement. There is a suggestion of a lag, but more counts are
necessary before it can be regarded as established.
Examination of these and other nitrate curves obtained at
Rothamsted has brought out another remarkable phenomenon. No
crop is growing on these plots, and no rain fell during the eighty hours,
yet nitrate is disappearing for a considerable part of the time. Where is
it going to? At present the simplest explanation seems to be that it is
taken up by micro-organisms. A similar conclusion had to be drawn
from a study of the nitrogen exhaustion of the soil. The whole of the
nitrate theoretically obtainable from the organic matter of the soil is not
obtained in the course of hours or even days; in one of our
experiments at Rothamsted nitrification is still going on, and is far from
complete, even after a lapse of fifty-three years. The explanation at
present offered is that part of the nitrate is constantly being absorbed
by micro-organisms and regenerated later on.
Now what organisms could be supposed to absorb nitrates from the
soil? Certain bacteria and fungi are known to utilise nitrates, and one
naturally thinks of algæ as possible agents also. Dr. Muriel Bristol was
therefore invited to study the algæ of the soil. Her account is given in
Chapter VI. She has found them not only on the surface, but scattered
throughout the body of the soil, even in the darkness of 4 inches, 5
inches, or 6 inches depth, where no light can ever penetrate, and
where photosynthesis as we understand it could not possibly take
place. Some modification in their mode of life is clearly necessary, and
it may well happen that they are living saprophytically. Dr. Bristol has
not yet, however, been able to count the algæ in the soil with any
certainty, although she has made some estimates of the numbers.
The quantitative work on the soil population indicates other
possibilities which are being investigated. There is not only a daily
fluctuation in the numbers, but so far as measurements have gone, a
seasonal one also. There seems to be some considerable uplift in
numbers of bacteria, protozoa, and possibly algæ and fungi in the
spring-time, followed by a fall in summer, a rise in autumn, and a fall
again in winter. At present we are unable to account for the
phenomenon, nor can we be sure that it is general until many more
data are accumulated.
In the cases of the protozoa and the algæ, there was a definite
reason for seeking them in the soil.
Another section of the population, the fungi, was simply found, and
at present we have only limited views as to their function. The older
workers considered that they predominated in acid soils, while
bacteria predominated in neutral soils. Present-day workers have
shown that fungi, including actinomycetes, are normal inhabitants of
all soils. The attempts at quantitative estimations are seriously
complicated by the fact that during the manipulations a single piece of
mycelium may break into fragments, each of which would count as
one, while a single cluster of spores might be counted as thousands.
Little progress has therefore been made on the quantitative lines
which have been so fruitful with protozoa. Dr. Brierley gives, in
Chapters VII. and VIII., a critical account of the work done on fungi.
In addition to the organisms already considered there are others of
larger size. The nematodes are almost visible to the unaided eye,
most of them are free living and probably help in the disintegration of
plant residues, though a few are parasitic on living plants and do much
injury to clover, oats, and less frequently to onions, bulbs, and
potatoes. Further, there are insects, myriapods and others, the effects
of which in the soil are not fully known. Special importance attaches to
the earthworms, not only because they are the largest in size and in
aggregate weight of the soil population, but because of the great part
they play in aerating the soil, gradually turning it over and bringing
about an intimate admixture with dead plant residues, as first
demonstrated by Darwin. Earthworms are the great distributors of
energy material to the microscopic population. Systematic quantitative
work on these larger forms is only of recent date, and Dr. Imms, in
Chapter IX., discusses our present knowledge.
TABLE I.
Soil Population, Rothamsted, 1922.
(The figures for algæ and fungi are first approximations only, and have considerably
less value than those for bacteria and protozoa.)

Approximate Weight
per Acre of—
Numbers Dry MatterNitrogen
per Gram Living in in
of Soil. Organisms. Organisms. Organisms.
Bacteria— lb. lb. lb.
High level 45,000,000 50
25 }
2 0·2
Low level 22,500,000
Protozoa—
Ciliates—
High level 1,000 — — —
Low level 100 — — —
Amœbæ—
High level 280,000 320
Low level 150,000 170 } 12 1·2
Flagellates—
High level 770,000 190
Low level 350,000 85 } 7 0·7
Algæ (not blue-green) [100,000] 125 6 0·6
Blue-green Say
Not known. — 6 Say 0·6
Fungi—
High level [1,500,000] 1700
Low level [700,000] 800 } 60 6·0
93 9·3
= 4 parts nitrogen per
1,000,000 of soil.

Larger Organisms.

Numbers Approximate Weight


per Acre.[D] per Acre of—
Living Dry Matter Nitrogen
Organisms. in in
Organisms. Organisms.
Un- Un- Un- Un-
Ma- ma- Ma- ma- Ma- ma- Ma- ma-
nured. nured. nured. nured. nured. nured. nured. nured.
Oligochaeta
(Limicolae)— lb. lb. lb. lb. lb. lb.
Nematoda,
etc. 3,609,000 794,000 9 2 3 1 — —
Myriapoda 1,781,000 879,000 203 99 85 42 4 2
Insects 7,727,000 2,475,000 34 16 14 6 1 1
Earthworms 1,010,000 458,000 472 217 108 50 10 5
Total 210 99 15 9
Total organic matter (dry weight) in this soil = 126,000 lb. per acre.
Total nitrogen = 5700 lb. per acre. (1 lb. nitrogen per acre = 0·4 parts per 1,000,000
of soil.)
[D] To a depth of 9 inches. The weight of soil is approximately 1,000,000 kilos.

Are there any other members of the soil population that are of
importance? As already shown, the method of investigating the soil
population in use at Rothamsted is to find by chemical methods the
changes going on in the soil; to find by biological methods what
organisms are capable of bringing about these changes; and then to
complete the chain of evidence by tracing the relationships between
the numbers or activities of these organisms and the amount of
change produced. The list as we know it to-day is given in Table I.
The method, however, does not indicate whether the account is
fairly complete, or whether there are other organisms to be found. We
might, of course, trust to empirical hunting for organisms, or to chance
discoveries such as led Goodey to find the mysterious Proteomyxan
Rhizopods, which cannot yet be cultured with certainty, so that they
are rarely found by soil workers. It is possible that there are many
such organisms, and it is even conceivable that these unknown forms
far outnumber the known. The defect of the present method is that it
always leaves us in doubt as to the completeness of the list, and so
we may have to devise another.
Reverting to Table I., it obviously serves no purpose to add the
numbers of all the organisms together. We can add up the weights of
living organisms, of their dry matter or nitrogen, so as to form some
idea of the proportion of living to non-living organic matter, and this
helps us to visualise the different groups and place them according to
their respective masses. But a much better basis for comparing the
activities of the different groups would be afforded by the respective
amounts of energy they transform, if these could be determined. It is
proposed to attempt such measurements at Rothamsted. The results
when added would give the sum of the energy changes effected by
the soil population as we know it: the figure could be compared with
the total energy change in the soil itself as determined in a
calorimeter. If the two figures are of the same order of magnitude, we
shall know that our list is fairly well complete; if they are widely
different, search must be made for the missing energy transformers.
There are, of course, serious experimental difficulties to be overcome,
but we believe the energy relationships will afford the best basis for
further work on the soil population.
Finally, it is necessary to refer to the physical conditions obtaining in
the soil. These make it a much better habitat for organisms than one
might expect. At first sight one thinks of the soil as a purely mineral
mass. This view is entirely incorrect. Soil contains a considerable
amount of plant residues, rich in energy, and of air and water. The
usual method of stating the composition of the soil is by weight, but
this is misleading to the biologist because the mineral matter has a
density some two and a half times that of water and three times that of
the organic matter. For biological purposes composition by volume is
much more useful, and when stated in this way the figures are very
different from those ordinarily given. Table II. gives the results for two
Broadbalk arable plots, one unmanured and the other dunged; it
includes also a pasture soil.
The first requirement of the soil population is a supply of energy,
without which it cannot live at all. All our evidence shows that the
magnitude of the population is limited by the quantity of energy
available. The percentage by weight of the organic matter is about two
to four or five, and the percentage by volume runs about four to
twelve. Not all of this, however, is of equal value as source of energy.
About one-half is fairly easily soluble in alkalis, and may or may not be
of special value, but about one-quarter is probably too stable to be of
use to soil organisms.
A second requirement is water with which in this country the soil is
usually tolerably well provided. Even in prolonged dry weather the soil
is moist at a depth of 3 inches below the surface. It is not uncommon
to find 10 per cent. or 20 per cent. by volume of water present, spread
in a thin film over all the particles, and completely saturating the soil
atmosphere.
TABLE II.
Volume of Air, Water and Organic Matter in 100 Volumes of
Rothamsted Soil.
In Pore Space.
Values Commonly
Solid Matter. Pore Obtained.
Mineral. Organic. Space. Water. Air.
(1) 62 4 34 23 11
(2) 51 11 38 30 8
(3) 41 12 47 40 7

(1) Arable, no manure applied to soil. (2) Arable, dung applied to soil. (3) Pasture.

The air supply is usually adequate owing to the rapidity with which
diffusion takes place. Except when the soil is water-logged, the
atmosphere differs but little from that of the one we breathe. There is
more CO2, but only a little less oxygen.[8] The mean temperature is
higher than one would expect, being distinctly above that of the air,
while the fluctuations in temperature are less.[5]
The reaction in normal soils is neutral to faintly alkaline; pH values
of nearly 8 are not uncommon. Results from certain English soils are
shown on p. 18.
The soil reaction is not easily altered. A considerable amount of acid
must accumulate before any marked increase in intensity of pH value
occurs; in other words, the soil is well buffered. The same can be said
of temperature, of water, and of energy supply. Like the reaction, they
alter but slowly, so that organisms have considerable time in which to
adapt themselves to the change.
Hydrogen Ion Concentration and Soil Fertility.
pH
Alkaline 10 Sterile: Alkali soil.
9

8 Fertile: Arable.

Neutral 7

5 Potato Scab fails.


Nitrification hindered.
4 Barley fails.

Acid 3 Sterile: Peat.

A SELECTED BIBLIOGRAPHY.
[1] Berthelot, Marcellin, “Fixation directe de l’azote atmosphérique libre par
certains terrains argileux,” Compt. Rend., 1885, ci., 775-84.
[2] Boussingault, J. B., and Léwy, “Sur la composition de l’air confiné dans
la terre végétale,” Ann. Chim. Phys., 1853, xxxvii., 5-50.
[3] Cutler, D. W., Crump, L. M., and Sandon, H., “A Quantitative
Investigation of the Bacterial and Protozoan Population of the Soil, with an
Account of the Protozoan Fauna,” Phil. Trans. Roy. Soc., Series B, 1922,
ccxi., 317-50.
[4] Hellriegel, H., and Wilfarth, H., “Untersuchungen über die
Stickstoffnahrung der Gramineen und Leguminosen,” Zeitsch. des Vereins
f. d. Rübenzucker-Industrie, 1888.
[5] Keen, B. A., and Russell, E. J., “The Factors determining Soil
Temperature,” Journ. Agric. Sci., 1921, xi., 211-37.
[6] Lawes, J. B., and Gilbert, J. H., “On Agricultural Chemistry, Especially
in Relation to the Mineral Theory of Baron Liebig,” Journ. Roy. Agric. Soc.,
1851, xii., 1-40.
[7] Liebig, Justus, “Chemistry in its Application to Agriculture and
Physiology,” 1st and 2nd editions (1840 and 1841), 3rd and 4th editions
(1843 and 1847); “Natural Laws of Husbandry,” 1863.
[8] Russell, E. J., and Appleyard, A., “The Composition of the Soil
Atmosphere,” Journ. Agric. Sci., 1915, vii., 1-48; 1917, viii., 385-417.
[9] Russell, E. J., and Hutchinson, H. B., “The Effect of Partial Sterilisation
of Soil on the Production of Plant Food,” Journ. Agric. Sci., 1909, iii., 111-
14; Part II., Journ. Agric. Sci., 1913, v., 152-221.
[10] Schloesing, Th., and Müntz, A., “Sur la Nitrification par les ferments
organisés,” Compt. Rend., 1877, lxxxiv., 301-3; 1877, lxxxv., 1018-20; and
1878, lxxxvi., 892-5. “Leçons de chimie agricole,” 1883.
[11] Warington, R., “On Nitrification,” Part I., Journ. Chem. Soc., 1878,
xxxiii., 44-51; Part II, Journ. Chem. Soc., 1879, xxxv., 429-56; Part III.,
Journ. Chem. Soc., 1884, xlv., 637-72; Part IV., Journ. Chem. Soc., 1891,
lix., 484-529.
[12] Way, J. T., “On the Composition of the Waters of Land Drainage and of
Rain,” Journ. Roy. Agric. Soc., 1856, xvii., 123-62.
[13] Winogradsky, S., “Recherches sur les organismes de la nitrification,”
Ann. de l’Inst. Pasteur, 1890, iv., 1e Mémoire, 213-31; 2e Mémoire, 257-75;
3e Mémoire, 760-71.
“Recherches sur l’assimilation de l’azote libre de l’atmosphère par les
microbes.” Arch. des Sci. Biolog. St. Petersburg, 1895, iii, 297-352.
For further details and fuller bibliography, see E. J. Russell, “Soil Conditions and
Plant Growth,” Longmans, Green & Co.
CHAPTER II.
SOIL BACTERIA.

A. Occurrence and Methods of Study.

To understand the development of our knowledge of soil bacteria,


it must be remembered that bacteriology is under the disadvantage
that it started as an applied science. Although bacteria were first
seen by Leeuwenhoeck about the middle of the seventeenth century,
and some of their forms described by microscopists of the eighteenth
and early nineteenth centuries, it was only with the work of Pasteur
on fermentation, and of Duvaine, Pasteur, and their contemporaries
on disease bacteria, that bacteriology may be said to have started.
From the outset, therefore, attention has been directed mainly to the
bacteria in their specialised relationship to disease or to fermentation
and similar processes. As a result, little research was done on the
pure biology of the bacteria, so that even now many of the most
fundamental and elementary problems concerning them are quite
unsolved.
In their work on fermentations and disease bacteria, the earlier
workers were assisted by the fact that under both sets of conditions
the causative bacteria exist, as a rule, either in practically pure
culture, or else in preponderating numbers. The study and
elucidation of such a mixed micro-population as exists in the soil,
became possible only when methods had been devised for isolating
the different kinds of bacteria, and thus studying them apart from
each other. It was the development of the gelatine plate method of
isolating pure cultures by Koch[36] in 1881 that made the study of the
soil bacteria practicable. The plating method opened up two lines of
research. In the first place, it provided a simple means of isolating
organisms from the mixed population of the soil, and thus enabled a
qualitative study to be made of each organism in pure culture, and,
in the second place, from it was developed a counting technique for
estimating differences in bacterial numbers between samples of soil,
from which has sprung much of our knowledge of the quantitative
side.
The earliest studies of the soil bacteria consisted of such
estimations of numbers, and showed that the soil contained a very
numerous population of bacteria. About 20,000,000 bacteria per
gram of soil is now considered a fair average number. The number
and variety of bacteria existing in the soil is so enormous that the
method of separating out all the different forms, and of discovering
their characters and functions, has proved impracticable. In practice,
therefore, the problem has been approached from the biochemical
standpoint. That is to say, the special chemical changes that the
bacteria produce in the soil have first been investigated, and this has
been followed by the isolation and study of the various groups of
bacteria that bring about the changes under investigation.
The method commonly employed in isolating the organisms that
produce a given chemical change in the soil is called the “elective”
method. The soil is inoculated into a culture medium that will
especially favour the group of bacteria to be isolated, to the
exclusion of others. For example, if it is desired to isolate the
organisms that attack cellulose, a medium is made up containing no
other organic carbon compounds except cellulose. Such a selective
medium encourages the growth of the group of organisms to be
investigated, so that after several transfers to fresh medium a culture
is obtained containing only two or three different types of organisms.
These are separated by plating and pure cultures obtained.
Another difficulty which has not yet been completely overcome is
that of adequately describing an organism when it is isolated. The
morphology of bacteria is not the constant thing that is seen in the
more stable higher organisms. In many cases the appearance of a
single strain is entirely different on different media, and may be quite
altered by such conditions as changes in acidity of the medium or
temperature of incubation. Even on a single medium remarkable
changes in morphology occur, at any rate, in some bacteria. This is
well seen in a cresol-decomposing organism under investigation at
Rothamsted. In cultures a few days old this organism develops as
bent and branching rods; these rods then break up into chains of
cocci and short rods, which separate, and in old cultures all the
organisms may be in the coccoid form (Fig. 1). It is claimed by
Löhnis[47b] that the possession of a complex life-cycle of changing
forms is a universal character in the bacteria. The instability of shape
in many bacteria makes it necessary to standardise very carefully
the cultural conditions under which they are kept when their
appearance is described.

Culture 15 hours old. Culture 3 days old.

Fig. 1.—Change in appearance, in culture, of a cresol decomposing bacterium.

The inadequacy of mere morphology as a basis for describing


bacteria led to the search for diagnostic characters, based on the
biochemical changes that they produced in their culture media, and
the appearance of their growth in the mass on various media. These
characters unfortunately have also proved to be very much
influenced by the exact composition of the medium and other
conditions of culture. Recently an attempt has been made by the
American Society of Bacteriologists to standardise the diagnostic
characters used in describing bacteria, and also the media and
cultural conditions under which they are grown for the purpose of
description. The need for such precautions, however, was not
sufficiently realised by the early workers, many of whose
descriptions cannot now be referred to any definite organism.
The large number of organisms found in the soil, and the difficulty
and labour of adequately describing them, is such that even now we
have no comprehensive description of the common soil bacteria that
appear on gelatine platings. A careful study based on modern
methods of characterisation has been made of certain selected
groups of bacteria, and it is hoped that the laborious systematic work
of describing the common forms will gradually be completed.
Several attempts have been made to classify the bacteria that
appear commonly on gelatine platings. This work was commenced
by Hiltner and Stormer in Germany, and continued by Chester,
Harding, and Conn in America. Conn[10], [14] found that the common
organisms fell into the following main groups:—
(1) Large spore-forming bacteria, related to Bacillus subtilis, which
form about 5-10 per cent. of the numbers. He adduced
evidence[12], [13] that these organisms exist in the soil mainly as
spores, so that they may not form an important part of the active soil
population.
(2) Short non-sporing organisms, related to Pseudomonas
fluorescens, that are rapid gelatine liquefiers. These form another 10
per cent. of the numbers.
(3) Short rod forms that liquefy gelatine slowly or not at all, and
develop colonies very slowly. These form 40-75 per cent. of the
numbers, and may therefore be of considerable importance in the
soil.
(4) A few micrococci also occur.
These groups comprise the larger portion of the bacterial flora of
the soil, but, in addition to these organisms, that develop on the
media commonly used for plating, there are special and important
groups that appear only on special media, either owing to their being
unable to grow on ordinary media or because they get swamped by
other forms. Examples of such groups are the ammonia and nitrite
oxidising bacteria, the nitrogen fixing groups, the cellulose
decomposing organisms, and the sulphur bacteria.
In order that we may apply the results of the study of a definite
organism to other localities, a knowledge of the geographical
distribution of the soil bacteria is clearly needed. We have,
unfortunately, very little knowledge of the distribution of soil
organisms. The common spore-forming groups appear to be
universally distributed. Thus Barthel, in a study of the bacterial flora
of soils from Greenland and the island of Disko, obtained soil
organisms belonging to the groups of Bacillus subtilis, B.
amylobacter, B. fluorescens, B. caudatus, and B. Zopfii, which are
common groups in European soil, indicating that the general
constitution of the bacterial flora of the soil in arctic regions is not
widely different from that of Western Europe. Bredemann, who made
an extensive study of the Bacillus amylobacter group, obtained soil
samples from widely scattered localities, and found these organisms
in soil from Germany, Holstein, Norway, Italy, Morocco, Teneriffe,
Russia, Japan, China, the East Indies, Samoa, Illinois, Arizona,
German East Africa, and the Cameroons. Some soil organisms, on
the other hand, are apparently absent from certain districts. This may
be due to the conditions, such as climatic environment, being
unfavourable to them. A study has recently been made at
Rothamsted of the distribution over Great Britain of a group of
bacteria that are capable of decomposing phenol and cresol. One of
these organisms, apparently related to the acid-fast B. phlœi, has an
interesting distribution. It has been found in 50 per cent. of the soils
samples examined from the drier region, where the annual rainfall is
less than 30 inches, but in only 20 per cent. of the samples in the
wetter parts of Britain. Another example of limited distribution is
found in the case of Bacillus radicicola, the organism that produces
tubercles on the roots of leguminous plants. The distribution of the
varieties of this organism follows that of the host plants with which
they are associated, so that when a new leguminous crop is
introduced into a country, nodules may not appear on the roots
unless the soil be specially inoculated with the right variety of
organism. In cases where a group of soil organisms is widely
distributed over the globe, it may yet be absent from many soils
owing to the soil conditions not suiting it. Thus, phenol decomposing
bacteria, though abundant in the neighbourhood of Rothamsted, are
yet absent from field plots that have been unmanured for a
considerable period. The occurrence of the nitrifying organisms and
the nitrogen fixing Azotobacter is also very dependent on the soil
conditions.
Owing to the method by which our knowledge of soil bacteria has
been acquired, by studying first the chemical changes in the soil and
then the bacteria that produce them, it is natural for us to divide them
into physiological groups according to the chemical changes that
they bring about. This grouping is the more reasonable since so little
is known as to the true relationships of the different groups of
bacteria that a classification based on morphology is well-nigh
impossible. In considering the activities of bacteria in the soil, it is
convenient to group the changes which they bring about into the two
divisions into which they naturally fall in the economy of the
organisms.
In the first place, there are the changes that result in a release of
energy, which the bacteria utilise for their vital processes.
In the second place, there are the processes by which the bacteria
build up the material of their bodies. These building up processes
involve an intake of energy for their accomplishment.
It will be convenient to deal first with the release of energy for their
own use by bacteria, and its consequences.
B. Activities Connected with the Acquirement of Energy.

Unlike the green plants, most bacteria are unable to obtain the
energy that is required for their metabolism from sunlight. They must,
therefore, make use of such chemical changes as will involve the
release of energy.
As an example of the acquirement of energy in this way may be
taken the oxidation of methane by B. methanicus. This organism,
described by Söhngen, obtains its energy supply by the conversion
of methane into CO2 and H2O.
CH4 + 2O2 = CO2 + 2H2O 220 Cal.
A further example is the acetic organism that obtains its energy
through the oxidation of alcohol to acetic acid.
C2H6O + O2 = C2H4O2 + H2O 115 Cal.
The decomposition processes brought about by micro-organisms
in obtaining energy are usually oxidations, but this is not necessarily
so, as can be seen in case of the fermentation of sugar into
alcohol.[E]
C6H12O6 = 2C2H6O + 2CO2 50 Cal.
[E] These examples are from Orla-Jensen (Centralblatt f. Bakt., II., Bd. 22,
p. 305).

By far the greater part of the decomposition of organic matter is


brought about by bacteria in the process of acquiring energy. In the
soil, nearly the whole of the material utilised by bacteria as a source
of energy is derived ultimately from green plants. The energy
materials left in the soil by the plant fall into two groups, the non-
nitrogenous compounds, which are mainly carbohydrates and their
derivatives, and the nitrogenous compounds, principally derived from
proteins.

(1) Decomposition of Non-nitrogenous Compounds.


The simpler carbohydrates and starches are attacked and
decomposed by a large variety of bacteria. The addition of such
substances to soil causes a rapid increase in bacterial numbers. In
nature the sugars are in all probability among the first plant
constituents to be destroyed during the decay processes.
A large proportion of plant tissues consist of cellulose and its
derivatives. These compounds are consequently of great importance
in the soil. Unfortunately our knowledge of the processes by which
cellulose is broken down in the soil is very inadequate. The early
experimental study of cellulose decomposition, such as that of
Tappeiner[60] and Hoppe-Seyler,[33] was mostly carried out under
conditions of inadequate aeration, and the products of
decomposition were found to include methane and CO2, and
sometimes fatty acids and hydrogen. The bacteriology of this
anaerobic decomposition was studied by Omelianski,[54] who
described two spore-bearing organisms, one of which attacked
cellulose with the production of hydrogen, and the other with the
production of methane. Both species also produce fatty acids and
CO2. It is probable that these organisms operate in the soil under
conditions of inadequate aeration. In swamp soils, in which rice is
grown, it has been shown that methane, hydrogen, and CO2 are
evolved in the lower layers. In these soils, however, the methane and
hydrogen are oxidised when they reach the surface layers. This
oxidation is also effected by micro-organisms. Bacteria capable of
deriving energy by the oxidation of hydrogen gas have been isolated
and studied by Kaserer,[37] and by Nabokich and Lebedeff,[52] while
Söhngen[57] has isolated an organism which he named Bacillus
methanicus, that was capable of oxidising methane.
Under normal conditions in cultivated soils, however, the
decomposition of cellulose takes place in the presence of an
adequate air supply, and so follows a different course from that
studied by Omelianski. Our knowledge of this aerobic decomposition
is very scanty. A number of bacteria, capable of decomposing
cellulose aerobically, are known. A remarkable organism was
investigated by Hutchinson and Clayton,[30] who named it
Spirochæta cytophaga. This organism, which they isolated from
Rothamsted soil, though placed among the Spirochætoidea, is of
doubtful affinities. During the active condition it exists for the most
part as thin flexible rods tapered at the extremities. This form passes
into a spherical cyst-like stage, at first thought to be a distinct
organism (Fig. 2). Spirochæta cytophaga is very aerobic, working
actively, only at the surface of the culture medium. It is very selective
in its action. It appears unable to derive energy from any
carbohydrate other than cellulose. Indeed, many of the simple
carbohydrates, especially the reducing sugars, are toxic to the
organism in pure culture. An extensive study of aerobic cellulose
decomposition by bacteria was made by McBeth and Scales,[50] who
isolated fifteen bacteria having this power. Five of these were spore-
forming organisms. Unlike Spirochæta cytophaga, they are all able
to develop on ordinary media such as beef agar or gelatine, and are
thus not nearly so selective in their food requirements.

Fig. 2.—Spirochæta cytophaga. Changes occurring in culture. (After Hutchinson


and Clayton.)

We are at present ignorant as to which organisms are most


effective in decomposing cellulose in the soil under field conditions,
or what are the conditions best suited to their activity. It is possible
that fungi also help in the decomposition of cellulose to a great
extent. This subject of the decomposition of cellulose offers one of
the most promising fields of research in soil bacteriology. The
difficulty of the subject is further increased by our present ignorance
of the chemical aspect of cellulose decomposition. It has been
supposed that the early decomposition products are simpler sugars,
but these are not found under conditions in which cellulose is being
decomposed by pure cultures of the bacteria mentioned above.
Hutchinson and Clayton found that their organism produced volatile
acids, mucilage, and a carotin-like pigment. The organisms isolated
by McBeth and Scales also produce acids, and in some cases yellow
pigments. It is known, however, that the decomposition products of
cellulose can be utilised as energy supply for other organisms, such
as nitrogen fixing bacteria.
When plant remains decompose in the soil there are ultimately
produced brown colloidal bodies collectively known as humus. The
processes by which this humus is produced are not yet properly
understood. Humus is of great importance in the soil, in rendering
the soil suitable for the growth of crops. It affects the physical
properties of the soil to a great extent. In the first place, it improves
the texture of the soil, making heavy clay soils more friable, and
loose sandy soils more coherent. Secondly, it has great water-
retaining powers, so that soils rich in organic matter suffer
comparatively little during periods of drought. And lastly, it exerts a
strong buffering effect against soil acids. Now, it is one of the
problems of present-day farming that soil is becoming depleted of its
humus. This is due to the increasing scarcity of farmyard manure in
many districts, and the consequent use of mineral fertilisers to
supply nitrogen, potash, and phosphate to the crop. A need has
therefore arisen for a substitute for farmyard manure, by means of
which the humus content of soils may be kept up in districts where
natural manure is scarce.
Fig. 3.—Cellulose decomposed by S. cytophaga in media with increasing amounts
of nitrogen. (After Hutchinson and Clayton.)

X-axis: Milligrams of nitrogen supplied as sodium-ammonium


phosphate.
Y-axis: Milligrams of cellulose decomposed in 21 days.

It is well known that if fresh unrotted manure or straw be added to


the soil, it often produces harmful effects on the succeeding crop.
The problem, therefore, was to develop a method by which fresh
straw, before application to the soil, could be made to rot down to a
mixture of humus compounds such as occur in well-rotted farmyard
manure. The solution of this problem came as a result of an
investigation by Hutchinson and Richards,[30b] at Rothamsted, into
food requirements of the cellulose decomposing bacteria. They
realised that since more than 10 per cent. of the dry weight of
bacteria consists of nitrogen, it would be necessary to supply the
cellulose decomposing bacteria with a supply of nitrogen, in order
that they should attain their greatest activity. Experiments with
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!

ebookluna.com

You might also like