You are on page 1of 61

(eTextbook PDF) for Starting out with

Visual C# 5th Edition


Visit to download the full and correct content document:
https://ebookmass.com/product/etextbook-pdf-for-starting-out-with-visual-c-5th-edition
/
Contents
1. Preface xiii
2. Attention Students xx
1. Chapter 1 Introduction to Computers and Programming 1
1. 1.1 Introduction 1
2. 1.2 Hardware and Software 2
3. 1.3 How Computers Store Data 7
4. 1.4 How a Program Works 11
5. 1.5 Graphical User Interfaces 18
6. 1.6 Objects 21
7. 1.7 The Program Development Process 23
8. 1.8 Getting Started with the Visual Studio Environment 27
9. Tutorial 1-1: Starting Visual Studio and Setting Up the Environment 28
10. Tutorial 1-2: Starting a New Visual C# Project 30
11. Tutorial 1-3: Saving and Closing a Project 32
12. Tutorial 1-4: Opening an Existing Project 40
13. Tutorial 1-5: Getting Familiar with the Visual Studio Environment 41
1. Key Terms 43
2. Review Questions 44
3. Programming Problems 49
2. Chapter 2 Introduction to Visual C# 51
1. 2.1 Getting Started with Forms and Controls 51

2. 2.2 Creating the GUI for Your First Visual C# Application: The Hello World Application 60

3. Tutorial 2-1: Creating the GUI for the Hello World Application 61
4. 2.3 Introduction to C# Code 65

5. 2.4 Writing Code for the Hello World Application 75

6. Tutorial 2-2: Writing Code for the Hello World Application 75


7. 2.5 Label Controls 78

8. Tutorial 2-3: Creating the Language Translator Application 86


9. 2.6 Making Sense of IntelliSense 89
10. 2.7 PictureBox Controls 90

11. Tutorial 2-4: Creating the Flags Application 94

12. Tutorial 2-5: Creating the Card Flip Application 98


13. 2.8 Comments, Blank Lines, and Indentation 102
14. 2.9 Writing the Code to Close an Application’s Form 104
15. 2.10 Dealing with Syntax Errors 105
1. Key Terms 107
2. Review Questions 107
3. Programming Problems 112
3. Chapter 3 Processing Data 117
1. 3.1 Reading Input with TextBox Controls 117
2. 3.2 A First Look at Variables 120

3. Tutorial 3-1: The Birth Date String Application 126


4. 3.3 Numeric Data Types and Variables 131
5. 3.4 Performing Calculations 137
6. 3.5 Inputting and Outputting Numeric Values 142
7. Tutorial 3-2: Calculating Fuel Economy 147
8. 3.6 Formatting Numbers with the ToString Method 150

9. Tutorial 3-3: Creating the Sale Price Calculator Application with Currency Formatting 153
10. 3.7 Simple Exception Handling 157

11. Tutorial 3-4: Creating the Test Average Application with Exception Handling 161
12. 3.8 Using Named Constants 165
13. 3.9 Declaring Variables as Fields 166

14. Tutorial 3-5: Creating the Change Counter Application 170


15. 3.10 Using the Math Class 174

16. 3.11 More GUI Details 176


17. 3.12 Using the Debugger to Locate Logic Errors 185
18. Tutorial 3-6: Single-stepping through an Application’s Code at Runtime 186
1. Key Terms 191
2. Review Questions 191
3. Programming Problems 196
4. Chapter 4 Making Decisions 201
1. 4.1 Decision Structures and the if Statement 201

2. Tutorial 4-1: Completing the Test Score Average Application 206


3. 4.2 The if-else Statement 210

4. Tutorial 4-2: Completing the Payroll with Overtime Application 211


5. 4.3 Nested Decision Structures 216

6. Tutorial 4-3: Completing the Loan Qualifier Application 218


7. 4.4 Logical Operators 227
8. 4.5 bool Variables and Flags 232

9. 4.6 Comparing Strings 232


10. 4.7 Preventing Data Conversion Exceptions with the TryParse Methods 236

11. Tutorial 4-4: Calculating Fuel Economy 241


12. 4.8 Input Validation 244
13. 4.9 Radio Buttons and Check Boxes 245

14. Tutorial 4-5: Creating the Color Theme Application 250


15. 4.10 The switch Statement 252
16. 4.11 Introduction to List Boxes 255

17. Tutorial 4-6: Creating the Time Zone Application 257


1. Key Terms 261
2. Review Questions 261
3. Programming Problems 265
5. Chapter 5 Loops, Files, and Random Numbers 271
1. 5.1 More about ListBoxes 271
2. 5.2 The while Loop 273

3. Tutorial 5-1: Using a Loop to Calculate an Account Balance 277

4. Tutorial 5-2: Enhancing the Ending Balance Application 280


5. 5.3 The ++ and −− operators 284

6. 5.4 The for Loop 285

7. Tutorial 5-3: Using the for Loop 290

8. 5.5 The do-while Loop 293

9. 5.6 Using Files for Data Storage 295


10. Tutorial 5-4: Writing Data to a Text File 301
11. Tutorial 5-5: Appending Data to the Friend.txt File 306
12. Tutorial 5-6: Using a Loop to Read to the End of a File 314
13. Tutorial 5-7: Calculating a Running Total 318
14. 5.7 The OpenFileDialog and SaveFileDialog Controls 321
15. 5.8 Random Numbers 326
16. Tutorial 5-8: Simulating Coin Tosses 328
17. 5.9 The Load Event 332
18. Tutorial 5-9: Creating a Load Event Handler 333
1. Key Terms 336
2. Review Questions 336
3. Programming Problems 339
6. Chapter 6 Modularizing Your Code with Methods 343
1. 6.1 Introduction to Methods 343
2. 6.2 void Methods 345

3. Tutorial 6-1: Creating and Calling Methods 349


4. 6.3 Passing Arguments to Methods 353
5. Tutorial 6-2: Passing an Argument to a Method 356
6. 6.4 Passing Arguments by Reference 364
7. Tutorial 6-3: Using an Output Parameter 367
8. 6.5 Value-Returning Methods 371
9. Tutorial 6-4: Writing a Value-Returning Method 376
10. Tutorial 6-5: Modularizing Input Validation with a Boolean Method 379
11. 6.6 Debugging Methods 384

12. Tutorial 6-6: Practicing the Step Into Command 385

13. Tutorial 6-7: Practicing the Step Over Command 386

14. Tutorial 6-8: Practicing the Step Out Command 387


1. Key Terms 389
2. Review Questions 389
3. Programming Problems 392
7. Chapter 7 Arrays and Lists 397
1. 7.1 Value Types and Reference Types 397
2. 7.2 Array Basics 400
3. Tutorial 7-1: Using an Array to Hold a List of Random Lottery Numbers 407
4. 7.3 Working with Files and Arrays 412
5. 7.4 Passing Arrays as Arguments to Methods 415
6. 7.5 Some Useful Array Algorithms 422
7. Tutorial 7-2: Processing an Array 432
8. 7.6 Advanced Algorithms for Sorting and Searching Arrays 437
9. 7.7 Two-Dimensional Arrays 444

10. Tutorial 7-3: Completing the Seating Chart Application 447


11. 7.8 Jagged Arrays 453
12. 7.9 The List Collection 454

13. Tutorial 7-4: Completing the Test Score List Application 460
14. 7.10 The ImageList Control 465
15. Tutorial 7-5: Completing the Random Card Application 467
1. Key Terms 470
2. Review Questions 470
3. Programming Problems 474
8. Chapter 8 Text Processing 479
1. 8.1 Introduction 479
2. 8.2 Working with Characters 479

3. Tutorial 8-1: Completing the Password Validation Application 485


4. 8.3 Working with Substrings 489

5. Tutorial 8-2: Completing the Telephone Format Application 498

6. Tutorial 8-3: Completing the Telephone Unformat Application 502


7. 8.4 Tokenizing Strings 506

8. Tutorial 8-4: Completing the CSV Reader Application 509


9. 8.5 The String.Format Method 514

1. Key Terms 519


2. Review Questions 519
3. Programming Problems 521
9. Chapter 9 Structures, Enumerated Types, and Dictionaries 525
1. 9.1 Introduction 525
2. 9.2 Structures 525

3. Tutorial 9-1: Completing the Phonebook Application 535


4. 9.3 The DateTime and TimeSpan Structures 541

5. 9.4 Enumerated Types 549

6. Tutorial 9-2: Completing the Color Spectrum Application 552


7. 9.5 Dictionaries 556
8. Tutorial 9-3: Storing Names and Birthdays in a Dictionary 564
9. Tutorial 9-4: Using a Dictionary to Simulate a Deck of Cards 566
1. Key Terms 572
2. Review Questions 572
3. Programming Problems 575
10. Chapter 10 Introduction to Classes 581
1. 10.1 Introduction to Classes 581
2. Tutorial 10-1: Creating and Using the Coin Class 588

3. 10.2 Properties 593


4. Tutorial 10-2: Creating and Using the CellPhone Class 598

5. 10.3 Parameterized Constructors and Overloading 602


6. Tutorial 10-3: Creating and Using the BankAccount Class 603

7. 10.4 Storing Class Type Objects in Arrays and Lists 611

8. Tutorial 10-4: Completing the Cell Phone Inventory Application 612


9. 10.5 Finding the Classes and Their Responsibilities in a Problem 616
10. 10.6 Application of Classes: Creating Multiple Forms in a Project 625
11. Tutorial 10-5: Creating an Application with Two Forms 630
12. Tutorial 10-6: Accessing a Control on a Different Form 635
13. 10.7 Static Class Members 639
14. Tutorial 10-7: Creating a Simple Logging Utility with a Static Class 643
1. Key Terms 648
2. Review Questions 648
3. Programming Problems 652
11. Chapter 11 Inheritance, Polymorphism, and Interfaces 655
1. 11.1 Inheritance 655
2. Tutorial 11-1: Creating and Testing the SavingsAccount and CDAccount Classes 664

3. 11.2 Polymorphism 672

4. Tutorial 11-2: Completing the Polymorphism Application 677


5. 11.3 Abstract Classes 682

6. Tutorial 11-3: Completing the Computer Science Student Application 684


7. 11.4 Extension Methods 688
8. Tutorial 11-4: Creating Extension Methods693
9. 11.5 Interfaces 696
10. Tutorial 11-5: Writing and Implementing an Interface 699
1. Key Terms 708
2. Review Questions 708
3. Programming Problems 712
12. Chapter 12 Databases 715
1. 12.1 Introduction to Database Management Systems 715
2. 12.2 Tables, Rows, and Columns 717
3. 12.3 Creating a Database in Visual Studio 720
4. Tutorial 12-1: Starting the Phone Book Application and Creating the Phonelist.mdf Database 721
5. 12.4 The DataGridView Control 729

6. Tutorial 12-2: Completing the Phone Book Application 729


7. 12.5 Connecting to an Existing Database and Using Details View Controls 736

8. Tutorial 12-3: Creating the Products Application and Using a Details View 738
9. 12.6 More About Data-Bound Controls 746

10. Tutorial 12-4: Creating the Product Lookup Application 749


11. Tutorial 12-5: Creating the Multiform Products Application 752
12. 12.7 Selecting Data with the SQL Select Statement 758

13. Tutorial 12-6: Creating the Product Queries Application 764

14. Tutorial 12-7: Creating the Product Queries Application 773


15. Tutorial 12-8: Creating the Product Search Application 777
1. Key Terms 783
2. Review Questions 783
3. Programming Problems 787
13. Chapter 13 Delegates, Anonymous Methods, and Lambda Expressions 789
1. 13.1 Delegates 789
2. 13.2 Anonymous Methods 795
3. 13.3 Lambda Expressions 797
4. 13.4 Built-In Delegates: Action, Func, and Predicate 803
5. Tutorial 13-1: Working with List Methods and Lambdas 811

1. Key Terms 815


2. Review Questions 815
3. Programming Challenges 818
14. Chapter 14 Language-Integrated Query (LINQ) 821
1. 14.1 Introduction to LINQ 821

2. Tutorial 14-1: Completing the Student Roster Application 827


3. 14.2 LINQ Method Syntax 831

4. Tutorial 14-2: Modifying the Student Roster Application 835


5. 14.3 More LINQ Extension Methods 837

6. Tutorial 14-3: Completing the Team Player Application 849


7. 14.4 Using LINQ to Query a Database 854

8. Tutorial 14-4: Completing the Phonelist Names Application 859


9. Tutorial 14-5: Completing the Product Reports Application 864

10. Tutorial 14-6: Completing the QueryDataSource Application 871


1. Key Terms 878
2. Review Questions 878
3. Programming Problems 881
1. Appendix A C# Primitive Data Types 883
2. Appendix B Additional User Interface Controls 885
3. Appendix C ASCII/Unicode Characters 905
4. Appendix D Answers to Checkpoint Questions 907
5. Appendix E Installing LINQ to SQL Classes in Visual Studio 929
6. Index 931
Preface
Welcome to Starting Out with Visual C#, Fifth Edition. This book is intended for an introductory programming course and is ideal for students with
no prior experience. Students who are new to programming will appreciate the clear, down-to-earth explanations and the detailed walk-throughs
that are provided by the hands-on tutorials. More experienced students will appreciate the depth of detail as they learn about the .NET
Framework, databases, Language-Integrated Query, and other topics.
As with all the books in the Starting Out With series, the hallmark of this text is its clear, friendly, and easy-to-understand writing. In addition, it is
rich in example programs that are concise and practical. The programs in this book include short examples that highlight specific programming
topics, as well as more involved examples that focus on problem solving. Each chapter provides numerous hands-on tutorials that guide the
student through each step of the development of an application. In addition to detailed, step-by-step instructions, the tutorials also provide the
application’s completed code and screen captures of the completed forms.

New to This Edition


The biggest changes in this edition appear in the last half of the book. Some of the chapters have been reorganized, and two new chapters have
been added. Here is a summary of the reorganization:
The ImageList control is now covered along with Arrays and Lists in Chapter 7. Since an ImageList is a collection of images, it is fitting that
this control be covered in the same chapter as Arrays and Lists.
Chapter 8 has been split into two chapters, with new material added to both of the resulting chapters. In this edition, Chapter 8 is titled Text
Processing and Chapter 9 is titled Structures, Enumerated Types, and Dictionaries.
Two new chapters have been added. In this edition, Chapter 13 is titled Delegates and Lambda Expressions and Chapter 14 is titled
Language-Integrated Query (LINQ).
An abundance of new topics and improvements has been added to this edition:
var Keyword: This edition introduces the var keyword for variable declaration.

Advanced String Formatting: Chapter 8 includes a new section on formatting strings with the String.Format method.

Working with Dates and Times: Chapter 9 includes a new section about working with dates and times. The section covers the DateTime and
TimeSpan data types, as well as the DateTimePicker control.

Dictionaries: Chapter 9 includes a new section on the Dictionary collection. The student learns to store and work with data as key–value
pairs in dictionaries.
More Use of Auto-Properties: In the previous editions, property declarations were almost always written with explicitly declared backing
fields, even when the properties were simply used to set and get a value. Where possible, those property declarations have been rewritten
as auto-properties.
Object Initializer Syntax: Object initializer syntax is introduced in Chapters 8 and 10 as an alternative way to declare and initialize structures
and class instances.
Static Members: Chapter 10 has a new section on static fields, properties, methods, and classes.
Sealed Classes and Methods: Chapter 11 has a new discussion on using the sealed keyword to prevent classes from being inherited from,
and to prevent methods from being overridden.
Extension Methods: Chapter 11 covers extension methods, which allow you to extend classes that you cannot inherit from, as well as the
primitive data types.
Interfaces: Chapter 11 now includes a section on writing and using interfaces.
Delegates: Chapter 13 introduces the student to delegates.
Anonymous Methods: Chapter 13 also introduces anonymous methods, which go hand-in-hand with delegates.
Lambda Expressions: Chapter 13 concludes by showing the student how to use a lambda expression to concisely create a delegate and
anonymous method.
Language-Integrated Query (LINQ): Chapter 14 introduces LINQ, and shows how to query simple data structures such as arrays and Lists
using LINQ to Objects, and how to query databases using LINQ to SQL.

A GUI-Based Approach
Beginning students are more motivated to learn programming when their applications have some sort of graphical element, such as a graphical
user interface (GUI). Students using this book will learn to create GUI-based, event-driven, Visual C# applications. The Visual Studio environment
is used to create forms that are rich with user interface controls and graphical images.
Learn to Use Objects Early, Learn to Write Classes Later
This book explains what an object is very early and shows the student how to create objects from classes that are provided by the .NET
Framework. It then introduces the student to the fundamentals of input and output, control structures, methods, arrays and lists, and file operations.
Then, the student learns to write his or her own classes and explores the topics of inheritance and polymorphism.

Brief Overview of Each Chapter


Chapter 1: Introduction to Computers and Programming
This chapter begins by giving a very concrete and easy-to-understand explanation of how computers work, how data is stored and manipulated,
and why we write programs in high-level languages. In this chapter, the student learns what an object is and sees several examples by studying
the objects that make up a program’s GUI. The chapter discusses steps in the programming development cycle. It also gives an introduction to
the Visual Studio environment.

Chapter 2: Introduction to Visual C#


In this chapter, the student learns to create forms with labels, buttons, and picture boxes and learns to modify control properties. The student is
introduced to C# code and learns the organizational structure of namespaces, classes, and methods. The student learns to write simple event-
driven applications that respond to button clicks or provide interaction through clickable images. The importance of commenting code is also
discussed.

Chapter 3: Processing Data


This chapter introduces variables and data types. It discusses the use of local variables and variables declared as fields within a form class. The
student learns to create applications that read input from TextBox controls, perform mathematical operations, and produce formatted output. The
student learns about the exceptions that can occur when the user enters invalid data into a TextBox and learns to write simple exception-handling
code to deal with those problems. Named constants are introduced as a way of representing unchanging values and creating self-documenting,
maintainable code. The student also learns more intricacies of creating graphical user interfaces. The chapter concludes with a discussion and
tutorial on using the Visual Studio debugger to locate logic errors by single-stepping through an application’s code.

Chapter 4: Making Decisions


In this chapter, the student learns about relational operators and Boolean expressions and is shown how to control the flow of a program with
decision structures. The if, if-else, and if-else-if statements are covered. Nested decision structures, logical operators, and the switch
statement are also discussed. The student learns to use the TryParse family of methods to validate input and prevent exceptions. Radio buttons,
check boxes, and list boxes are introduced as ways to let the user select items in a GUI.

Chapter 5: Loops, Files, and Random Numbers


This chapter shows the student how to use loops to create repetition structures. The while loop, the for loop, and the do-while loop are
presented. Counters, accumulators, and running totals are also discussed. This chapter also introduces sequential file input and output and using
text files. The student learns various programming techniques for writing data to text files and reading the contents of test files. The chapter
concludes with a discussion of pseudorandom numbers, their applications, and how to generate them.

Chapter 6: Modularizing Your Code with Methods


In this chapter, the student first learns how to write and call void methods as well as value-returning methods. The chapter shows the benefits of
using methods to modularize programs and discusses the top-down design approach. Then, the student learns to pass arguments to methods.
Passing by value, by reference, and output parameters are discussed. The chapter concludes with a discussion and tutorial on debugging
methods with the Visual Studio step-into, step-over, and step-out, commands.

Chapter 7: Arrays and Lists


Arrays and lists are reference-type objects in C# so this chapter begins by discussing the difference between value type and reference type
objects in the C# language. Then, the student learns to create and work with single-dimensional and two-dimensional arrays. The student learns to
pass arrays as arguments to methods, transfer data between arrays and files, work with partially filled arrays, and create jagged arrays. Many
examples of array processing are provided, including examples of finding the sum, average, highest, and lowest values in an array. Finally, the
student learns to create List objects and store data in them, and use the ImageList control, a data structure for storing and retrieving images.

Chapter 8: Text Processing


This chapter discusses various techniques for working with text. The topics include working with characters, working with substrings, tokenizing
strings, and formatting strings.

Chapter 9: Structures, Enumerated Types, and Dictionaries.


In this chapter, the student learns to use structures to encapsulate several variables into a single item. The student next learns to create and use
enumerated types. Last, the student learns to use the Dictionary collection from the .NET Framework to store and work with data as key–value
pairs.

Chapter 10: Introduction to Classes.


Up to this point, the student has extensively used objects that are instances of .NET Framework classes. In this chapter, the student learns to write
classes to create his or her own objects with fields, methods, and constructors. The student learns how to implement various types of properties
within a class, including auto-properties and read-only auto-properties. Creating arrays of objects and storing objects in a List are also
discussed. A primer on finding the classes in a problem as well as their responsibilities is provided. The chapter shows the student how to create
multiple form classes in a project, instantiate those classes, and display them. A tutorial is given where the student creates a multiform application
in which the code in one form accesses controls on another form. The chapter concludes by discussing static members and static classes.

Chapter 11: Inheritance, Polymorphism, and Interfaces


The study of classes continues in this chapter with the subjects of inheritance and polymorphism. The topics covered include base classes,
derived classes, how constructors functions work in inheritance, method overriding, and polymorphism. Abstract classes and abstract methods
are also discussed. The chapter discusses extension methods, and concludes with a section on interfaces.

Chapter 12: Databases


This chapter introduces the student to basic database concepts. The student first learns about tables, rows, and columns and how to create an
SQL Server database in Visual Studio. The student then learns how to connect a database to a Visual C# application and display a table in a
DataGridView control, a Details view, and other data-bound controls. Finally, the student learns how to write SQL Select statements to retrieve
data from a table.

Chapter 13: Delegates and Lambda Expressions.


Lambda expressions have become commonplace in C# programming. Before the student can really understand lambda expressions, he or she
must first understand delegates and anonymous methods. The goal of this chapter is to build a foundation of knowledge about how delegates and
anonymous methods work, and then build an understanding of lambda expressions.

Chapter 14: Language-Integrated Query (LINQ).


This chapter begins by introducing the student to LINQ as a tool for querying the data in common data structures such as arrays and Lists, using
LINQ to Objects. It discusses both query syntax and method syntax. Several useful LINQ extension methods are also discussed. The chapter
concludes with a section on LINQ to SQL and discusses how to use LINQ to query a database.

Appendix A: C# Primitive Data Types


This appendix gives an overview of the primitive data types available in C#.

Appendix B: Additional User Interface Controls


This appendix shows how to create a variety of controls such as ToolTips, combo boxes, scroll bars, TabControls, WebBrowser controls,
ErrorProvider components, and menu systems.

Appendix C: ASCII/Unicode Characters


This appendix lists the ASCII (American Standard Code for Information Interchange) character set, which is also the Latin Subset of Unicode.

Appendix D: Answers to Checkpoint Questions


This appendix provides the answers to the Checkpoint questions that appear throughout each chapter in the book.

Appendix E: Installing LINQ to SQL.


This appendix shows how to use the Visual Studio Installer to download and install LINQ to SQL.
Organization of the Text
The text teaches Visual C# step by step. Each chapter covers a major set of programming topics, introduces controls and GUI elements, and
builds knowledge as the student progresses through the book. Although the chapters can be easily taught in their existing sequence, there is
some flexibility. Figure P-1 shows the chapter dependencies. As shown in the figure, Chapters 1–7 present the fundamentals of Visual C#
programming and should be covered in sequence. Then, you can move directly to Chapter 8, 9, 10, or 12. Chapter 11 should be covered after
Chapter 10. Then Chapter 13 and 14 can be covered in order.

Figure P-1 Chapter dependencies

Figure P-1 Full Alternative Text

Features of the Text


Concept Statements
Each major section of the text starts with a concept statement. This statement concisely summarizes the main point of the section.

Tutorials
Each chapter has several hands-on tutorials that guide the student through the development of an application. Each tutorial provides detailed,
step-by-step instructions, as well as the application’s completed code and screen captures of the completed forms.

Example Programs
Each chapter has an abundant number of code examples designed to highlight the current topic.

Notes
Notes appear at several places throughout the text. They are short explanations of interesting or often misunderstood points relevant to the topic
at hand.

Tips
Tips advise the student on the best techniques for approaching different programming or animation problems.

Warnings
Warnings caution students about programming techniques or practices that can lead to malfunctioning programs or lost data.

Checkpoints
Checkpoints are questions placed at intervals throughout each chapter. They are designed to query the student’s knowledge quickly after learning
a new topic. The answers to the Checkpoint questions can be found in Appendix D.

Review Questions
Each chapter presents a thorough and diverse set of Review Questions. They include Multiple Choice, True/False, Algorithm Workbench, and
Short Answer.

Programming Problems
Each chapter offers a pool of Programming Problems designed to solidify the student’s knowledge of the topics currently being studied.

VideoNotes
Each tutorial in the book has an accompanying online VideoNote that can be accessed on the book’s companion Web site
www.pearson.com/gaddis. Students can follow along with the author as he or she works through each tutorial in the videos. Also, one
programming problem at the end of each chapter has an accompanying VideoNote that shows the student how to create the solution.

Supplements
Student
The following supplementary material is available with the book:
Source code and files required for the chapter tutorials are available at www.pearson.com/cs-resources
A complete set of online VideoNotes that take the student through each tutorial in the book. Also, one programming problem from each
chapter has an accompanying VideoNote that helps the student create a solution. You may access the VideoNotes by going to
www.pearson.com/cs-resources.

Instructor
The following supplements are available to qualified instructors:
Answers to all Review Questions in the text
Solutions for all Programming Problems in the text
Completed versions of all tutorials
PowerPoint presentation slides for every chapter
Test bank
For information on how to access these supplements, visit the Pearson Education Instructor Resource Center at www.pearsonhighered.com/irc.

Acknowledgments
There were many helping hands in the development and publication of this text. I would like to thank the following faculty reviewers for their helpful
suggestions and expertise:

Matthew Alimagham Spartanburg Community College


Carolyn Borne Louisiana State University

Arthur E. Carter Radford University


Sallie B. Dodson Radford University

Elizabeth Freije Indiana University—Purdue University, Indianapolis


Bettye J. Parham Daytona State College

Wendy L. Payne Gulf Coast State College


Jason Sharp Tarleton State University

John Van Assen York Technical College


Reginald White Black Hawk College

Dawn R. Wick Southwestern Community College


I also want to thank everyone at Pearson for making the Starting Out With ... series so successful. I have worked so closely with the team at
Pearson that I consider them among my closest friends. I am extremely fortunate to have Matt Goldstein as my editor, and Meghan Jacoby as
Editorial Assistant. They have guided me through the process of revising this book, as well as many others. I am also fortunate to have Demetrius
Hall and Yvonne Vannatta as my marketing team. Their hard work is truly inspiring, and they do a great job of getting this book out to the
academic community. The production team, led by Carole Snyder, worked tirelessly to make this book a reality. Thanks to you all!

About the Author


Tony Gaddis is the principal author of the Starting Out With series of textbooks. Tony has nearly 20 years experience teaching computer
science courses at Haywood Community College in North Carolina. He is a highly acclaimed instructor who was previously selected as the North
Carolina Community College Teacher of the Year and has received the Teaching Excellence Award from the National Institute for Staff and
Organizational Development.

The Starting Out With series includes introductory books using the C++ programming language, the Java™ programming language, Microsoft®
Visual Basic®, Microsoft® C#®, Python, Programming Logic and Design, MIT App Inventor, and Alice, all published by Pearson Education.
Attention Students
Installing Visual Studio
To complete the tutorials and programming problems in this book, you need to install Visual Studio 2017, or a later version, on your computer. We
recommend that you download Visual Studio Community 2017 from the following website, and install it on your system:
www.visualstudio.com
Visual Studio Community 2017 is a free, full-featured development environment, and is a perfect companion for this textbook.

Note
If you are working in your school’s computer lab, there is a good chance that Microsoft Visual Studio has already been installed. If this is the
case, your instructor will show you how to start Visual Studio.

Installing the Student Sample Program Files


The Student Sample Program files that accompany this book are available for download from the book’s companion Web site at:
www.pearson.com/cs-resources
These files are required for many of the book’s tutorials. Simply download the Student Sample Program files to a location on your hard drive
where you can easily access them.
Chapter 1 Introduction to Computers and Programming
Topics
1. 1.1 Introduction
2. 1.2 Hardware and Software
3. 1.3 How Computers Store Data
4. 1.4 How a Program Works
5. 1.5 Graphical User Interfaces
6. 1.6 Objects
7. 1.7 The Program Development Process
8. 1.8 Getting Started with the Visual Studio Environment
1.1 Introduction
Think about some of the different ways that people use computers. In school, students use computers for tasks such as writing papers, searching
for articles, sending e-mail, and participating in online classes. At work, people use computers to analyze data, make presentations, conduct
business transactions, communicate with customers and coworkers, control machines in manufacturing facilities, and do many other things. At
home, people use computers for tasks such as paying bills, shopping online, staying connected with friends and family, and playing computer
games. And don’t forget that smart phones, tablets, car navigation systems, and many other devices are computers as well. The uses of
computers are almost limitless in our everyday lives.
Computers can do such a wide variety of things because they can be programmed, which means that computers are designed not to do just one
job, but to do any job that their programs tell them to do. A program is a set of instructions that a computer follows to perform a task. For example,
Figure 1-1 shows screens from two commonly used Microsoft programs: Word and PowerPoint. Word is a word processing program that allows
you to create, edit, and print documents. PowerPoint allows you to create graphical slides and use them as part of a presentation.

Figure 1-1 A word processing program and a presentation


program

Figure 1-1 Full Alternative Text


Programs are commonly referred to as software. Software is essential to a computer because without software, a computer can do nothing. All
the software that makes our computers useful is created by individuals known as programmers, or software developers. A programmer, or
software developer, is a person with the training and skills necessary to design, create, and test computer programs. Computer programming is
an exciting and rewarding career. Today, programmers work in business, medicine, government, law enforcement, agriculture, academics,
entertainment, and almost every other field.
This book introduces you to the fundamental concepts of computer programming using the C# programming language. Before we begin exploring
those concepts, you need to understand a few basic things about computers and how they work. This chapter provides a solid foundation of
knowledge that you will continually rely on as you study computer science. First, we discuss the physical components that computers are
commonly made of. Then, we look at how computers store data and execute programs. Next, we introduce you to two fundamental elements of
modern software design: graphical user interfaces and objects. Finally, we give a quick introduction to the software used to write C# programs.
1.2 Hardware and Software
Concept
The physical devices that a computer is made of are referred to as the computer’s hardware. The programs that run on a computer are referred to
as software.

Hardware
Hardware refers to all the physical devices, or components, of which a computer is made. A computer is not one single device but is a system of
devices that all work together. Like the different instruments in a symphony orchestra, each device in a computer plays its own part.
If you have ever shopped for a computer, you have probably seen sales literature listing components such as microprocessors, memory, disk
drives, video displays, graphics cards, and so forth. Unless you already know a lot about computers or at least have a friend who does,
understanding what these different components do can be confusing. As shown in Figure 1-2, a typical computer system consists of the following
major components:
The central processing unit (CPU)
Main memory
Secondary storage devices
Input devices
Output devices

Figure 1-2 Typical components of a computer system

Figure 1-2 Full Alternative Text


Let’s take a closer look at each of these components.

The CPU
When a computer is performing the tasks that a program tells it to do, we say that the computer is running or executing the program. The central
processing unit, or CPU, is the part of a computer that actually runs programs. The CPU is the most important component in a computer because
without it, the computer could not run software.
In the earliest computers, CPUs were huge devices made of electrical and mechanical components such as vacuum tubes and switches. Figure
1-3 shows such a device. The two women in the photo are working with the historic ENIAC computer. The ENIAC, considered by many to be the
world’s first programmable electronic computer, was built in 1945 to calculate artillery ballistic tables for the U.S. Army. This machine, which was
primarily one big CPU, was 8 feet tall and 100 feet long and weighed 30 tons.

Figure 1-3 The ENIAC computer

Today, CPUs are small chips known as microprocessors. Figure 1-4 shows a photo of a lab technician holding a modern-day microprocessor. In
addition to being much smaller than the old electromechanical CPUs in early computers, microprocessors are also much more powerful.

Figure 1-4 A lab technician holds a modern microprocessor


Main Memory
You can think of main memory as the computer’s work area. This is where the computer stores a program while the program is running, as well as
the data that the program is working with. For example, suppose you are using a word processing program to write an essay for one of your
classes. While you do this, both the word processing program and the essay are stored in main memory.
Main memory is commonly known as random access memory, or RAM. It is called this because the CPU is able to quickly access data stored at
any random location in RAM. RAM is usually a volatile type of memory that is used only for temporary storage while a program is running. When
the computer is turned off, the contents of RAM are erased. Inside your computer, RAM is stored in chips, similar to the ones shown in Figure 1-5.

Figure 1-5 Memory chips


Secondary Storage Devices
Secondary storage is a type of memory that can hold data for long periods of time, even when there is no power to the computer. Programs are
normally stored in secondary memory and loaded into main memory as needed. Important data, such as word processing documents, payroll
data, and inventory records, is saved to secondary storage as well.
The most common type of secondary storage device is the disk drive. A traditional disk drive stores data by magnetically encoding it onto a
spinning circular disk. Solid-state drives, which store data in solid-state memory, are increasingly becoming popular. A solid-state drive has no
moving parts and operates faster than a traditional disk drive.
Most computers have some sort of secondary storage device, either a traditional disk drive or a solid-state drive, mounted inside their case.
External storage devices are also available, which connect to one of the computer’s communication ports, or plug into a memory slot. External
storage devices can be used to create backup copies of important data or to move data to another computer. For example, USB (Universal
Serial Bus) drives and SD (Secure Digital) memory cards are small devices that appear in the system as disk drives. They are inexpensive,
reliable, and small enough to be carried in your pocket.
Optical devices such as the compact disc (CD) and the digital versatile disc (DVD) are also popular for data storage. Data is not recorded
magnetically on an optical disc but is encoded as a series of pits on the disc surface. CD and DVD drives use a laser to detect the pits and thus
read the encoded data. Optical discs hold large amounts of data, and because recordable CD and DVD drives are now commonplace, they are
good mediums for creating backup copies of data.

Input Devices
Input is any data the computer collects from people and from other devices. The component that collects the data and sends it to the computer is
called an input device. Common input devices are the keyboard, mouse, touchscreen, scanner, microphone, and digital camera. Disk drives and
optical drives can also be considered input devices because programs and data are retrieved from them and loaded into the computer’s
memory.

Output Devices
Output is any data the computer produces for people or for other devices. It might be a sales report, a list of names, or a graphic image. The data
is sent to an output device, which formats and presents it. Common output devices are screens and printers. Storage devices can also be
considered output devices because the system sends data to them in order to be saved.

Software
If a computer is to function, software is not optional. Everything that a computer does, from the time you turn the power switch on until you shut the
system down, is under the control of software. There are two general categories of software: system software and application software. Most
computer programs clearly fit into one of these two categories. Let’s take a closer look at each.

System Software
The programs that control and manage the basic operations of a computer are generally referred to as system software. System software
typically includes the following types of programs:

Operating Systems
An operating system is the most fundamental set of programs on a computer. The operating system controls the internal operations of the
computer’s hardware, manages all the devices connected to the computer, allows data to be saved to and retrieved from storage devices,
and allows other programs to run on the computer.

Utility Programs
A utility program performs a specialized task that enhances the computer’s operation or safeguards data. Examples of utility programs are
virus scanners, file-compression programs, and data-backup programs.

Software Development Tools


The software tools that programmers use to create, modify, and test software are referred to as software development tools. Assemblers,
compilers, and interpreters, which are discussed later in this chapter, are examples of programs that fall into this category.

Application Software
Programs that make a computer useful for everyday tasks are known as application software. These are the programs that people normally
spend most of their time running on their computers. Figure 1-1, at the beginning of this chapter, shows screens from two commonly used
applications—Microsoft Word, a word processing program, and Microsoft Powerpoint, a presentation program. Some other examples of
application software are spreadsheet programs, e-mail programs, Web browsers, and game programs.

Checkpoint
1. 1.1 What is a program?
2. 1.2 What is hardware?
3. 1.3 List the five major components of a computer system.
4. 1.4 What part of the computer actually runs programs?
5. 1.5 What part of the computer serves as a work area to store a program and its data while the program is running?
6. 1.6 What part of the computer holds data for long periods of time, even when there is no power to the computer?
7. 1.7 What part of the computer collects data from people and from other devices?
8. 1.8 What part of the computer formats and presents data for people or other devices?
9. 1.9 What fundamental set of programs control the internal operations of the computer’s hardware?
10. 1.10 What do you call a program that performs a specialized task, such as a virus scanner, a file-compression program, or a data-backup
program?
11. 1.11 Word processing programs, spreadsheet programs, e-mail programs, Web browsers, and game programs belong to what category of
software?
1.3 How Computers Store Data
Concept
All data stored in a computer is converted to sequences of 0s and 1s.
A computer’s memory is divided into tiny storage locations known as bytes. One byte is enough memory to store only a letter of the alphabet or a
small number. In order to do anything meaningful, a computer has to have lots of bytes. Most computers today have millions, or even billions, of
bytes of memory.
Each byte is divided into eight smaller storage locations known as bits. The term bit stands for binary digit. Computer scientists usually think of
bits as tiny switches that can be either on or off. Bits aren’t actual “switches,” however, at least not in the conventional sense. In most computer
systems, bits are tiny electrical components that can hold either a positive or a negative charge. Computer scientists think of a positive charge as
a switch in the on position and a negative charge as a switch in the off position. Figure 1-6 shows the way that a computer scientist might think of
a byte of memory: as a collection of switches that are each flipped to either the on or the off position.

Figure 1-6 A byte thought of as eight switches

When a piece of data is stored in a byte, the computer sets the eight bits to an on/off pattern that represents the data. For example, the pattern
shown on the left in Figure 1-7 shows how the number 77 would be stored in a byte, and the pattern on the right shows how the letter A would be
stored in a byte. In a moment, you will see how these patterns are determined.

Figure 1-7 Bit patterns for the number 77 and the letter A

Figure 1-7 Full Alternative Text

Storing Numbers
A bit can be used in a very limited way to represent numbers. Depending on whether the bit is turned on or off, it can represent one of two different
values. In computer systems, a bit that is turned off represents the number 0 and a bit that is turned on represents the number 1. This corresponds
perfectly to the binary numbering system. In the binary numbering system (or binary, as it is usually called), all numeric values are written as
sequences of 0s and 1s. Here is an example of a number that is written in binary:
10011101

The position of each digit in a binary number has a value assigned to it. Starting with the rightmost digit and moving left, the position values are
20,21,22,23, and so forth, as shown in Figure 1-8. Figure 1-9 shows the same diagram with the position values calculated. Starting with the
rightmost digit and moving left, the position values are 1, 2, 4, 8, and so forth.

Figure 1-8 The values of binary digits as powers of 2


Figure 1-8 Full Alternative Text

Figure 1-9 The values of binary digits

Figure 1-9 Full Alternative Text


To determine the value of a binary number, you simply add up the position values of all the 1s. For example, in the binary number 10011101, the
position values of the 1s are 1, 4, 8, 16, and 128. This is shown in Figure 1-10. The sum of all these position values is 157. So, the value of the
binary number 10011101 is 157.

Figure 1-10 Determining the value of 10011101

Figure 1-10 Full Alternative Text


Figure 1-11 shows how you can picture the number 157 stored in a byte of memory. Each 1 is represented by a bit in the on position, and each 0
is represented by a bit in the off position.
Figure 1-11 The bit pattern for 157

Figure 1-11 Full Alternative Text


When all the bits in a byte are set to 0 (turned off), then the value of the byte is 0. When all the bits in a byte are set to 1 (turned on), then the byte
holds the largest value that can be stored in it. The largest value that can be stored in a byte is 1+2+4+8+16+32+64+128=255. This limit exists
because there are only eight bits in a byte.
What if you need to store a number larger than 255? The answer is simple: use more than 1 byte. For example, suppose we put 2 bytes together.
That gives us 16 bits. The position values of those 16 bits would be 20,21,22,23, and so forth, up through 215. As shown in Figure 1-12, the
maximum value that can be stored in 2 bytes is 65,535. If you need to store a number larger than this, then more bytes are necessary.

Figure 1-12 Two bytes used for a large number

Figure 1-12 Full Alternative Text

Tip
In case you’re feeling overwhelmed by all this, relax! You will not have to actually convert numbers to binary while programming. Knowing that this
process is taking place inside the computer will help you as you learn, and in the long term this knowledge will make you a better programmer.

Storing Characters
Any piece of data that is stored in a computer’s memory must be stored as a binary number. That includes characters such as letters and
punctuation marks. When a character is stored in memory, it is first converted to a numeric code. The numeric code is then stored in memory as a
binary number.
Over the years, different coding schemes have been developed to represent characters in computer memory. Historically, the most important of
these coding schemes is ASCII, which stands for the American Standard Code for Information Interchange. ASCII is a set of 128 numeric codes
that represent the English letters, various punctuation marks, and other characters. For example, the ASCII code for the uppercase letter A is 65.
When you type an uppercase A on your computer keyboard, the number 65 is stored in memory (as a binary number, of course). This is shown in
Figure 1-13.

Figure 1-13 The letter A stored in memory as the number 65

Figure 1-13 Full Alternative Text

Tip
The acronym ASCII is pronounced “askee.”
In case you are curious, the ASCII code for uppercase B is 66, for uppercase C is 67, and so forth. Appendix C shows all the ASCII codes and
the characters they represent.
The ASCII character set was developed in the early 1960s and was eventually adopted by almost all computer manufacturers. ASCII is limited,
however, because it defines codes for only 128 characters. To remedy this, the Unicode character set was developed in the early 1990s. Unicode
is an extensive encoding scheme that is compatible with ASCII and can also represent the characters of many of the world’s languages. Today,
Unicode is quickly becoming the standard character set used in the computer industry.

Advanced Number Storage


Earlier you saw how numbers are stored in memory. Perhaps it occurred to you then that the binary numbering system can be used to represent
only integer numbers, beginning with 0. Negative numbers and real numbers (such as 3.14159) cannot be represented using the simple binary
numbering technique we discussed.
Computers are able to store negative numbers and real numbers in memory, but to do so they use encoding schemes along with the binary
numbering system. Negative numbers are encoded using a technique known as two’s complement, and real numbers are encoded in floating-
point notation. You don’t need to know how these encoding schemes work, only that they are used to convert negative numbers and real numbers
to binary format.

Other Types of Data


Computers are often referred to as digital devices. The term digital can be used to describe anything that uses binary numbers. Digital data is
data that is stored in binary, and a digital device is any device that works with binary data. In this section, we have discussed how numbers and
characters are stored in binary, but computers also work with many other types of digital data.
For example, consider the pictures that you take with your digital camera. These images are composed of tiny dots of color known as pixels. (The
term pixel stands for picture element.) As shown in Figure 1-14, each pixel in an image is converted to a numeric code that represents the pixel’s
color. The numeric code is stored in memory as a binary number.

Figure 1-14 A digital image stored in binary format

The music that you play on your CD player, iPod, or MP3 player is also digital. A digital song is broken into small pieces known as samples. Each
sample is converted to a binary number, which can be stored in memory. The more samples that a song is divided into, the more it sounds like
the original music when it is played back. A CD-quality song is divided into more than 44,000 samples per second!

Checkpoint
1. 1.12 What amount of memory is enough to store a letter of the alphabet or a small number?
2. 1.13 What do you call a tiny “switch” that can be set to either on or off?
3. 1.14 In what numbering system are all numeric values written as sequences of 0s and 1s?
4. 1.15 What is the purpose of ASCII?
5. 1.16 What encoding scheme is extensive enough to represent all the characters of many of the languages in the world?
6. 1.17 What do the terms digital data and digital device mean?
1.4 How a Program Works
Concept
A computer’s CPU can understand only instructions written in machine language. Because people find it very difficult to write entire programs in
machine language, other programming languages have been invented.
Earlier, we stated that the CPU is the most important component in a computer because it is the part of the computer that runs programs.
Sometimes the CPU is called the “computer’s brain” and is described as being “smart.” Although these are common metaphors, you should
understand that the CPU is not a brain, and it is not smart. The CPU is an electronic device that is designed to do specific things. In particular, the
CPU is designed to perform operations such as the following:
Reading a piece of data from main memory
Adding two numbers
Subtracting one number from another number
Multiplying two numbers
Dividing one number by another number
Moving a piece of data from one memory location to another
Determining whether one value is equal to another value
As you can see from this list, the CPU performs simple operations on pieces of data. The CPU does nothing on its own, however. It has to be told
what to do, which is the purpose of a program. A program is nothing more than a list of instructions that cause the CPU to perform operations.
Each instruction in a program is a command that tells the CPU to perform a specific operation. Here’s an example of an instruction that might
appear in a program:
10110000

To you and me, this is only a series of 0s and 1s. To a CPU, however, this is an instruction to perform an operation.1 It is written in 0s and 1s
because CPUs understand only instructions that are written in machine language, and machine language instructions are always written in binary.
1The example shown is an actual instruction for an Intel microprocessor. It tells the microprocessor to move a value into the CPU.
A machine language instruction exists for each operation that a CPU is capable of performing. For example, there is an instruction for adding
numbers; there is an instruction for subtracting one number from another; and so forth. The entire set of instructions that a CPU can execute is
known as the CPU’s instruction set.

Note
There are several microprocessor companies today that manufacture CPUs. Some of the more well-known microprocessor companies are Intel,
AMD, and Motorola. If you look carefully at your computer, you might find a tag showing a logo for its microprocessor.
Each brand of microprocessor has its own unique instruction set, which is typically understood only by microprocessors of the same brand. For
example, Intel microprocessors understand the same instructions, but they do not understand instructions for Motorola microprocessors.
The machine language instruction that was previously shown is an example of only one instruction. It takes a lot more than one instruction,
however, for the computer to do anything meaningful. Because the operations that a CPU knows how to perform are so basic in nature, a
meaningful task can be accomplished only if the CPU performs many operations. For example, if you want your computer to calculate the amount
of interest that you will earn from your savings account this year, the CPU will have to perform a large number of instructions, carried out in the
proper sequence. It is not unusual for a program to contain thousands or even a million or more machine language instructions.
Programs are usually stored on a secondary storage device such as a disk drive. When you install a program on your computer, the program is
typically copied to your computer’s disk drive from a CD-ROM or perhaps downloaded from a Web site.
Although a program can be stored on a secondary storage device such as a disk drive, it has to be copied into main memory, or RAM, each time
the CPU executes it. For example, suppose you have a word processing program on your computer’s disk. To execute the program, you use the
mouse to double-click the program’s icon. This causes the program to be copied from the disk into main memory. Then, the computer’s CPU
executes the copy of the program that is in main memory. This process is illustrated in Figure 1-15.

Figure 1-15 A program being copied into main memory and then
executed
Figure 1-15 Full Alternative Text
When a CPU executes the instructions in a program, it is engaged in a process that is known as the fetch-decode-execute cycle. This cycle,
which consists of three steps, is repeated for each instruction in the program. The steps are as follows:
1. Fetch. A program is a long sequence of machine language instructions. The first step of the cycle is to fetch, or read, the next instruction
from memory into the CPU.
2. Decode. A machine language instruction is a binary number that represents a command that tells the CPU to perform an operation. In this
step the CPU decodes the instruction that was just fetched from memory, to determine which operation it should perform.
3. Execute. The last step in the cycle is to execute, or perform, the operation.
Figure 1-16 illustrates these steps.

Figure 1-16 The fetch-decode-execute cycle

Figure 1-16 Full Alternative Text

From Machine Language to Assembly Language


Computers can execute only programs that are written in machine language. As previously mentioned, a program can have thousands or even a
million or more binary instructions, and writing such a program would be very tedious and time consuming. Programming in machine language
would also be very difficult because putting a 0 or a 1 in the wrong place would cause an error.
Although a computer’s CPU understands only machine language, it is impractical for people to write programs in machine language. For this
reason, assembly language was created in the early days of computing2 as an alternative to machine language. Instead of using binary numbers
for instructions, assembly language uses short words that are known as mnemonics. For example, in assembly language, the mnemonic add
typically means to add numbers, mul typically means to multiply numbers, and mov typically means to move a value to a location in memory. When
a programmer uses assembly language to write a program, he or she can write short mnemonics instead of binary numbers.
2The first assembly language was most likely developed in the 1940s at Cambridge University for use with a historical computer known as the
EDSAC.

Note
There are many different versions of assembly language. It was mentioned earlier that each brand of CPU has its own machine language
instruction set. Each brand of CPU typically has its own assembly language as well.
Assembly language programs cannot be executed by the CPU, however. The CPU understands only machine language, so a special program
known as an assembler is used to translate an assembly language program to a machine language program. This process is shown in Figure 1-
17. The CPU can then execute the machine language program that the assembler creates.

Figure 1-17 An assembler translating an assembly language


program to a machine language program

Figure 1-17 Full Alternative Text

High-Level Languages
Although assembly language makes it unnecessary to write binary machine language instructions, it is not without difficulties. Assembly language
is primarily a direct substitute for machine language, and like machine language, it requires that you know a lot about the CPU. Assembly
language also requires that you write a large number of instructions for even the simplest program. Because assembly language is so close in
nature to machine language, it is referred to as a low-level language.
In the 1950s, a new generation of programming languages known as high-level languages began to appear. A high-level language allows you to
create powerful and complex programs without knowing how the CPU works and without writing large numbers of low-level instructions. In
addition, most high-level languages use words that are easy to understand. For example, if a programmer were using COBOL (which was one of
the early high-level languages created in the 1950s), he or she would write the following instruction to display the message Hello world on the
computer screen:
DISPLAY "Hello world"

Doing the same thing in assembly language would require several instructions and an intimate knowledge of how the CPU interacts with the
computer’s video circuitry. As you can see from this example, high-level languages allow programmers to concentrate on the tasks they want to
perform with their programs rather than the details of how the CPU will execute those programs.
Since the 1950s, thousands of high-level languages have been created. Table 1-1 lists several of the more well-known languages.

Table 1-1 Programming languages


Language Description
Ada was created in the 1970s, primarily for applications used by the U.S. Department of Defense. The language is named in honor
Ada
of Countess Ada Lovelace, an influential and historical figure in the field of computing.
Beginners All-purpose Symbolic Instruction Code is a general-purpose language that was originally designed in the early 1960s to
BASIC
be simple enough for beginners to learn. Today, there are many different versions of BASIC.
FORmula TRANslator was the first high-level programming language. It was designed in the 1950s for performing complex
FORTRAN
mathematical calculations.
COBOL Common Business-Oriented Language was created in the 1950s and was designed for business applications.
Pascal was created in 1970 and was originally designed for teaching programming. The language was named in honor of the
Pascal
mathematician, physicist, and philosopher Blaise Pascal.
C and C++ (pronounced “c plus plus”) are powerful, general-purpose languages developed at Bell Laboratories. The C language
C and C++
was created in 1972, and the C++ language was created in 1983.
Pronounced “c sharp,” this language was created by Microsoft around the year 2000 for developing applications based on the
C#
Microsoft .NET platform.
Java was created by Sun Microsystems in the early 1990s. It can be used to develop programs that run on a single computer or over
Java
the Internet from a Web server.
Another random document with
no related content on Scribd:
DANCE ON STILTS AT THE GIRLS’ UNYAGO, NIUCHI

Newala, too, suffers from the distance of its water-supply—at least


the Newala of to-day does; there was once another Newala in a lovely
valley at the foot of the plateau. I visited it and found scarcely a trace
of houses, only a Christian cemetery, with the graves of several
missionaries and their converts, remaining as a monument of its
former glories. But the surroundings are wonderfully beautiful. A
thick grove of splendid mango-trees closes in the weather-worn
crosses and headstones; behind them, combining the useful and the
agreeable, is a whole plantation of lemon-trees covered with ripe
fruit; not the small African kind, but a much larger and also juicier
imported variety, which drops into the hands of the passing traveller,
without calling for any exertion on his part. Old Newala is now under
the jurisdiction of the native pastor, Daudi, at Chingulungulu, who,
as I am on very friendly terms with him, allows me, as a matter of
course, the use of this lemon-grove during my stay at Newala.
FEET MUTILATED BY THE RAVAGES OF THE “JIGGER”
(Sarcopsylla penetrans)

The water-supply of New Newala is in the bottom of the valley,


some 1,600 feet lower down. The way is not only long and fatiguing,
but the water, when we get it, is thoroughly bad. We are suffering not
only from this, but from the fact that the arrangements at Newala are
nothing short of luxurious. We have a separate kitchen—a hut built
against the boma palisade on the right of the baraza, the interior of
which is not visible from our usual position. Our two cooks were not
long in finding this out, and they consequently do—or rather neglect
to do—what they please. In any case they do not seem to be very
particular about the boiling of our drinking-water—at least I can
attribute to no other cause certain attacks of a dysenteric nature,
from which both Knudsen and I have suffered for some time. If a
man like Omari has to be left unwatched for a moment, he is capable
of anything. Besides this complaint, we are inconvenienced by the
state of our nails, which have become as hard as glass, and crack on
the slightest provocation, and I have the additional infliction of
pimples all over me. As if all this were not enough, we have also, for
the last week been waging war against the jigger, who has found his
Eldorado in the hot sand of the Makonde plateau. Our men are seen
all day long—whenever their chronic colds and the dysentery likewise
raging among them permit—occupied in removing this scourge of
Africa from their feet and trying to prevent the disastrous
consequences of its presence. It is quite common to see natives of
this place with one or two toes missing; many have lost all their toes,
or even the whole front part of the foot, so that a well-formed leg
ends in a shapeless stump. These ravages are caused by the female of
Sarcopsylla penetrans, which bores its way under the skin and there
develops an egg-sac the size of a pea. In all books on the subject, it is
stated that one’s attention is called to the presence of this parasite by
an intolerable itching. This agrees very well with my experience, so
far as the softer parts of the sole, the spaces between and under the
toes, and the side of the foot are concerned, but if the creature
penetrates through the harder parts of the heel or ball of the foot, it
may escape even the most careful search till it has reached maturity.
Then there is no time to be lost, if the horrible ulceration, of which
we see cases by the dozen every day, is to be prevented. It is much
easier, by the way, to discover the insect on the white skin of a
European than on that of a native, on which the dark speck scarcely
shows. The four or five jiggers which, in spite of the fact that I
constantly wore high laced boots, chose my feet to settle in, were
taken out for me by the all-accomplished Knudsen, after which I
thought it advisable to wash out the cavities with corrosive
sublimate. The natives have a different sort of disinfectant—they fill
the hole with scraped roots. In a tiny Makua village on the slope of
the plateau south of Newala, we saw an old woman who had filled all
the spaces under her toe-nails with powdered roots by way of
prophylactic treatment. What will be the result, if any, who can say?
The rest of the many trifling ills which trouble our existence are
really more comic than serious. In the absence of anything else to
smoke, Knudsen and I at last opened a box of cigars procured from
the Indian store-keeper at Lindi, and tried them, with the most
distressing results. Whether they contain opium or some other
narcotic, neither of us can say, but after the tenth puff we were both
“off,” three-quarters stupefied and unspeakably wretched. Slowly we
recovered—and what happened next? Half-an-hour later we were
once more smoking these poisonous concoctions—so insatiable is the
craving for tobacco in the tropics.
Even my present attacks of fever scarcely deserve to be taken
seriously. I have had no less than three here at Newala, all of which
have run their course in an incredibly short time. In the early
afternoon, I am busy with my old natives, asking questions and
making notes. The strong midday coffee has stimulated my spirits to
an extraordinary degree, the brain is active and vigorous, and work
progresses rapidly, while a pleasant warmth pervades the whole
body. Suddenly this gives place to a violent chill, forcing me to put on
my overcoat, though it is only half-past three and the afternoon sun
is at its hottest. Now the brain no longer works with such acuteness
and logical precision; more especially does it fail me in trying to
establish the syntax of the difficult Makua language on which I have
ventured, as if I had not enough to do without it. Under the
circumstances it seems advisable to take my temperature, and I do
so, to save trouble, without leaving my seat, and while going on with
my work. On examination, I find it to be 101·48°. My tutors are
abruptly dismissed and my bed set up in the baraza; a few minutes
later I am in it and treating myself internally with hot water and
lemon-juice.
Three hours later, the thermometer marks nearly 104°, and I make
them carry me back into the tent, bed and all, as I am now perspiring
heavily, and exposure to the cold wind just beginning to blow might
mean a fatal chill. I lie still for a little while, and then find, to my
great relief, that the temperature is not rising, but rather falling. This
is about 7.30 p.m. At 8 p.m. I find, to my unbounded astonishment,
that it has fallen below 98·6°, and I feel perfectly well. I read for an
hour or two, and could very well enjoy a smoke, if I had the
wherewithal—Indian cigars being out of the question.
Having no medical training, I am at a loss to account for this state
of things. It is impossible that these transitory attacks of high fever
should be malarial; it seems more probable that they are due to a
kind of sunstroke. On consulting my note-book, I become more and
more inclined to think this is the case, for these attacks regularly
follow extreme fatigue and long exposure to strong sunshine. They at
least have the advantage of being only short interruptions to my
work, as on the following morning I am always quite fresh and fit.
My treasure of a cook is suffering from an enormous hydrocele which
makes it difficult for him to get up, and Moritz is obliged to keep in
the dark on account of his inflamed eyes. Knudsen’s cook, a raw boy
from somewhere in the bush, knows still less of cooking than Omari;
consequently Nils Knudsen himself has been promoted to the vacant
post. Finding that we had come to the end of our supplies, he began
by sending to Chingulungulu for the four sucking-pigs which we had
bought from Matola and temporarily left in his charge; and when
they came up, neatly packed in a large crate, he callously slaughtered
the biggest of them. The first joint we were thoughtless enough to
entrust for roasting to Knudsen’s mshenzi cook, and it was
consequently uneatable; but we made the rest of the animal into a
jelly which we ate with great relish after weeks of underfeeding,
consuming incredible helpings of it at both midday and evening
meals. The only drawback is a certain want of variety in the tinned
vegetables. Dr. Jäger, to whom the Geographical Commission
entrusted the provisioning of the expeditions—mine as well as his
own—because he had more time on his hands than the rest of us,
seems to have laid in a huge stock of Teltow turnips,[46] an article of
food which is all very well for occasional use, but which quickly palls
when set before one every day; and we seem to have no other tins
left. There is no help for it—we must put up with the turnips; but I
am certain that, once I am home again, I shall not touch them for ten
years to come.
Amid all these minor evils, which, after all, go to make up the
genuine flavour of Africa, there is at least one cheering touch:
Knudsen has, with the dexterity of a skilled mechanic, repaired my 9
× 12 cm. camera, at least so far that I can use it with a little care.
How, in the absence of finger-nails, he was able to accomplish such a
ticklish piece of work, having no tool but a clumsy screw-driver for
taking to pieces and putting together again the complicated
mechanism of the instantaneous shutter, is still a mystery to me; but
he did it successfully. The loss of his finger-nails shows him in a light
contrasting curiously enough with the intelligence evinced by the
above operation; though, after all, it is scarcely surprising after his
ten years’ residence in the bush. One day, at Lindi, he had occasion
to wash a dog, which must have been in need of very thorough
cleansing, for the bottle handed to our friend for the purpose had an
extremely strong smell. Having performed his task in the most
conscientious manner, he perceived with some surprise that the dog
did not appear much the better for it, and was further surprised by
finding his own nails ulcerating away in the course of the next few
days. “How was I to know that carbolic acid has to be diluted?” he
mutters indignantly, from time to time, with a troubled gaze at his
mutilated finger-tips.
Since we came to Newala we have been making excursions in all
directions through the surrounding country, in accordance with old
habit, and also because the akida Sefu did not get together the tribal
elders from whom I wanted information so speedily as he had
promised. There is, however, no harm done, as, even if seen only
from the outside, the country and people are interesting enough.
The Makonde plateau is like a large rectangular table rounded off
at the corners. Measured from the Indian Ocean to Newala, it is
about seventy-five miles long, and between the Rovuma and the
Lukuledi it averages fifty miles in breadth, so that its superficial area
is about two-thirds of that of the kingdom of Saxony. The surface,
however, is not level, but uniformly inclined from its south-western
edge to the ocean. From the upper edge, on which Newala lies, the
eye ranges for many miles east and north-east, without encountering
any obstacle, over the Makonde bush. It is a green sea, from which
here and there thick clouds of smoke rise, to show that it, too, is
inhabited by men who carry on their tillage like so many other
primitive peoples, by cutting down and burning the bush, and
manuring with the ashes. Even in the radiant light of a tropical day
such a fire is a grand sight.
Much less effective is the impression produced just now by the
great western plain as seen from the edge of the plateau. As often as
time permits, I stroll along this edge, sometimes in one direction,
sometimes in another, in the hope of finding the air clear enough to
let me enjoy the view; but I have always been disappointed.
Wherever one looks, clouds of smoke rise from the burning bush,
and the air is full of smoke and vapour. It is a pity, for under more
favourable circumstances the panorama of the whole country up to
the distant Majeje hills must be truly magnificent. It is of little use
taking photographs now, and an outline sketch gives a very poor idea
of the scenery. In one of these excursions I went out of my way to
make a personal attempt on the Makonde bush. The present edge of
the plateau is the result of a far-reaching process of destruction
through erosion and denudation. The Makonde strata are
everywhere cut into by ravines, which, though short, are hundreds of
yards in depth. In consequence of the loose stratification of these
beds, not only are the walls of these ravines nearly vertical, but their
upper end is closed by an equally steep escarpment, so that the
western edge of the Makonde plateau is hemmed in by a series of
deep, basin-like valleys. In order to get from one side of such a ravine
to the other, I cut my way through the bush with a dozen of my men.
It was a very open part, with more grass than scrub, but even so the
short stretch of less than two hundred yards was very hard work; at
the end of it the men’s calicoes were in rags and they themselves
bleeding from hundreds of scratches, while even our strong khaki
suits had not escaped scatheless.

NATIVE PATH THROUGH THE MAKONDE BUSH, NEAR


MAHUTA

I see increasing reason to believe that the view formed some time
back as to the origin of the Makonde bush is the correct one. I have
no doubt that it is not a natural product, but the result of human
occupation. Those parts of the high country where man—as a very
slight amount of practice enables the eye to perceive at once—has not
yet penetrated with axe and hoe, are still occupied by a splendid
timber forest quite able to sustain a comparison with our mixed
forests in Germany. But wherever man has once built his hut or tilled
his field, this horrible bush springs up. Every phase of this process
may be seen in the course of a couple of hours’ walk along the main
road. From the bush to right or left, one hears the sound of the axe—
not from one spot only, but from several directions at once. A few
steps further on, we can see what is taking place. The brush has been
cut down and piled up in heaps to the height of a yard or more,
between which the trunks of the large trees stand up like the last
pillars of a magnificent ruined building. These, too, present a
melancholy spectacle: the destructive Makonde have ringed them—
cut a broad strip of bark all round to ensure their dying off—and also
piled up pyramids of brush round them. Father and son, mother and
son-in-law, are chopping away perseveringly in the background—too
busy, almost, to look round at the white stranger, who usually excites
so much interest. If you pass by the same place a week later, the piles
of brushwood have disappeared and a thick layer of ashes has taken
the place of the green forest. The large trees stretch their
smouldering trunks and branches in dumb accusation to heaven—if
they have not already fallen and been more or less reduced to ashes,
perhaps only showing as a white stripe on the dark ground.
This work of destruction is carried out by the Makonde alike on the
virgin forest and on the bush which has sprung up on sites already
cultivated and deserted. In the second case they are saved the trouble
of burning the large trees, these being entirely absent in the
secondary bush.
After burning this piece of forest ground and loosening it with the
hoe, the native sows his corn and plants his vegetables. All over the
country, he goes in for bed-culture, which requires, and, in fact,
receives, the most careful attention. Weeds are nowhere tolerated in
the south of German East Africa. The crops may fail on the plains,
where droughts are frequent, but never on the plateau with its
abundant rains and heavy dews. Its fortunate inhabitants even have
the satisfaction of seeing the proud Wayao and Wamakua working
for them as labourers, driven by hunger to serve where they were
accustomed to rule.
But the light, sandy soil is soon exhausted, and would yield no
harvest the second year if cultivated twice running. This fact has
been familiar to the native for ages; consequently he provides in
time, and, while his crop is growing, prepares the next plot with axe
and firebrand. Next year he plants this with his various crops and
lets the first piece lie fallow. For a short time it remains waste and
desolate; then nature steps in to repair the destruction wrought by
man; a thousand new growths spring out of the exhausted soil, and
even the old stumps put forth fresh shoots. Next year the new growth
is up to one’s knees, and in a few years more it is that terrible,
impenetrable bush, which maintains its position till the black
occupier of the land has made the round of all the available sites and
come back to his starting point.
The Makonde are, body and soul, so to speak, one with this bush.
According to my Yao informants, indeed, their name means nothing
else but “bush people.” Their own tradition says that they have been
settled up here for a very long time, but to my surprise they laid great
stress on an original immigration. Their old homes were in the
south-east, near Mikindani and the mouth of the Rovuma, whence
their peaceful forefathers were driven by the continual raids of the
Sakalavas from Madagascar and the warlike Shirazis[47] of the coast,
to take refuge on the almost inaccessible plateau. I have studied
African ethnology for twenty years, but the fact that changes of
population in this apparently quiet and peaceable corner of the earth
could have been occasioned by outside enterprises taking place on
the high seas, was completely new to me. It is, no doubt, however,
correct.
The charming tribal legend of the Makonde—besides informing us
of other interesting matters—explains why they have to live in the
thickest of the bush and a long way from the edge of the plateau,
instead of making their permanent homes beside the purling brooks
and springs of the low country.
“The place where the tribe originated is Mahuta, on the southern
side of the plateau towards the Rovuma, where of old time there was
nothing but thick bush. Out of this bush came a man who never
washed himself or shaved his head, and who ate and drank but little.
He went out and made a human figure from the wood of a tree
growing in the open country, which he took home to his abode in the
bush and there set it upright. In the night this image came to life and
was a woman. The man and woman went down together to the
Rovuma to wash themselves. Here the woman gave birth to a still-
born child. They left that place and passed over the high land into the
valley of the Mbemkuru, where the woman had another child, which
was also born dead. Then they returned to the high bush country of
Mahuta, where the third child was born, which lived and grew up. In
course of time, the couple had many more children, and called
themselves Wamatanda. These were the ancestral stock of the
Makonde, also called Wamakonde,[48] i.e., aborigines. Their
forefather, the man from the bush, gave his children the command to
bury their dead upright, in memory of the mother of their race who
was cut out of wood and awoke to life when standing upright. He also
warned them against settling in the valleys and near large streams,
for sickness and death dwelt there. They were to make it a rule to
have their huts at least an hour’s walk from the nearest watering-
place; then their children would thrive and escape illness.”
The explanation of the name Makonde given by my informants is
somewhat different from that contained in the above legend, which I
extract from a little book (small, but packed with information), by
Pater Adams, entitled Lindi und sein Hinterland. Otherwise, my
results agree exactly with the statements of the legend. Washing?
Hapana—there is no such thing. Why should they do so? As it is, the
supply of water scarcely suffices for cooking and drinking; other
people do not wash, so why should the Makonde distinguish himself
by such needless eccentricity? As for shaving the head, the short,
woolly crop scarcely needs it,[49] so the second ancestral precept is
likewise easy enough to follow. Beyond this, however, there is
nothing ridiculous in the ancestor’s advice. I have obtained from
various local artists a fairly large number of figures carved in wood,
ranging from fifteen to twenty-three inches in height, and
representing women belonging to the great group of the Mavia,
Makonde, and Matambwe tribes. The carving is remarkably well
done and renders the female type with great accuracy, especially the
keloid ornamentation, to be described later on. As to the object and
meaning of their works the sculptors either could or (more probably)
would tell me nothing, and I was forced to content myself with the
scanty information vouchsafed by one man, who said that the figures
were merely intended to represent the nembo—the artificial
deformations of pelele, ear-discs, and keloids. The legend recorded
by Pater Adams places these figures in a new light. They must surely
be more than mere dolls; and we may even venture to assume that
they are—though the majority of present-day Makonde are probably
unaware of the fact—representations of the tribal ancestress.
The references in the legend to the descent from Mahuta to the
Rovuma, and to a journey across the highlands into the Mbekuru
valley, undoubtedly indicate the previous history of the tribe, the
travels of the ancestral pair typifying the migrations of their
descendants. The descent to the neighbouring Rovuma valley, with
its extraordinary fertility and great abundance of game, is intelligible
at a glance—but the crossing of the Lukuledi depression, the ascent
to the Rondo Plateau and the descent to the Mbemkuru, also lie
within the bounds of probability, for all these districts have exactly
the same character as the extreme south. Now, however, comes a
point of especial interest for our bacteriological age. The primitive
Makonde did not enjoy their lives in the marshy river-valleys.
Disease raged among them, and many died. It was only after they
had returned to their original home near Mahuta, that the health
conditions of these people improved. We are very apt to think of the
African as a stupid person whose ignorance of nature is only equalled
by his fear of it, and who looks on all mishaps as caused by evil
spirits and malignant natural powers. It is much more correct to
assume in this case that the people very early learnt to distinguish
districts infested with malaria from those where it is absent.
This knowledge is crystallized in the
ancestral warning against settling in the
valleys and near the great waters, the
dwelling-places of disease and death. At the
same time, for security against the hostile
Mavia south of the Rovuma, it was enacted
that every settlement must be not less than a
certain distance from the southern edge of the
plateau. Such in fact is their mode of life at the
present day. It is not such a bad one, and
certainly they are both safer and more
comfortable than the Makua, the recent
intruders from the south, who have made USUAL METHOD OF
good their footing on the western edge of the CLOSING HUT-DOOR
plateau, extending over a fairly wide belt of
country. Neither Makua nor Makonde show in their dwellings
anything of the size and comeliness of the Yao houses in the plain,
especially at Masasi, Chingulungulu and Zuza’s. Jumbe Chauro, a
Makonde hamlet not far from Newala, on the road to Mahuta, is the
most important settlement of the tribe I have yet seen, and has fairly
spacious huts. But how slovenly is their construction compared with
the palatial residences of the elephant-hunters living in the plain.
The roofs are still more untidy than in the general run of huts during
the dry season, the walls show here and there the scanty beginnings
or the lamentable remains of the mud plastering, and the interior is a
veritable dog-kennel; dirt, dust and disorder everywhere. A few huts
only show any attempt at division into rooms, and this consists
merely of very roughly-made bamboo partitions. In one point alone
have I noticed any indication of progress—in the method of fastening
the door. Houses all over the south are secured in a simple but
ingenious manner. The door consists of a set of stout pieces of wood
or bamboo, tied with bark-string to two cross-pieces, and moving in
two grooves round one of the door-posts, so as to open inwards. If
the owner wishes to leave home, he takes two logs as thick as a man’s
upper arm and about a yard long. One of these is placed obliquely
against the middle of the door from the inside, so as to form an angle
of from 60° to 75° with the ground. He then places the second piece
horizontally across the first, pressing it downward with all his might.
It is kept in place by two strong posts planted in the ground a few
inches inside the door. This fastening is absolutely safe, but of course
cannot be applied to both doors at once, otherwise how could the
owner leave or enter his house? I have not yet succeeded in finding
out how the back door is fastened.

MAKONDE LOCK AND KEY AT JUMBE CHAURO


This is the general way of closing a house. The Makonde at Jumbe
Chauro, however, have a much more complicated, solid and original
one. Here, too, the door is as already described, except that there is
only one post on the inside, standing by itself about six inches from
one side of the doorway. Opposite this post is a hole in the wall just
large enough to admit a man’s arm. The door is closed inside by a
large wooden bolt passing through a hole in this post and pressing
with its free end against the door. The other end has three holes into
which fit three pegs running in vertical grooves inside the post. The
door is opened with a wooden key about a foot long, somewhat
curved and sloped off at the butt; the other end has three pegs
corresponding to the holes, in the bolt, so that, when it is thrust
through the hole in the wall and inserted into the rectangular
opening in the post, the pegs can be lifted and the bolt drawn out.[50]

MODE OF INSERTING THE KEY

With no small pride first one householder and then a second


showed me on the spot the action of this greatest invention of the
Makonde Highlands. To both with an admiring exclamation of
“Vizuri sana!” (“Very fine!”). I expressed the wish to take back these
marvels with me to Ulaya, to show the Wazungu what clever fellows
the Makonde are. Scarcely five minutes after my return to camp at
Newala, the two men came up sweating under the weight of two
heavy logs which they laid down at my feet, handing over at the same
time the keys of the fallen fortress. Arguing, logically enough, that if
the key was wanted, the lock would be wanted with it, they had taken
their axes and chopped down the posts—as it never occurred to them
to dig them out of the ground and so bring them intact. Thus I have
two badly damaged specimens, and the owners, instead of praise,
come in for a blowing-up.
The Makua huts in the environs of Newala are especially
miserable; their more than slovenly construction reminds one of the
temporary erections of the Makua at Hatia’s, though the people here
have not been concerned in a war. It must therefore be due to
congenital idleness, or else to the absence of a powerful chief. Even
the baraza at Mlipa’s, a short hour’s walk south-east of Newala,
shares in this general neglect. While public buildings in this country
are usually looked after more or less carefully, this is in evident
danger of being blown over by the first strong easterly gale. The only
attractive object in this whole district is the grave of the late chief
Mlipa. I visited it in the morning, while the sun was still trying with
partial success to break through the rolling mists, and the circular
grove of tall euphorbias, which, with a broken pot, is all that marks
the old king’s resting-place, impressed one with a touch of pathos.
Even my very materially-minded carriers seemed to feel something
of the sort, for instead of their usual ribald songs, they chanted
solemnly, as we marched on through the dense green of the Makonde
bush:—
“We shall arrive with the great master; we stand in a row and have
no fear about getting our food and our money from the Serkali (the
Government). We are not afraid; we are going along with the great
master, the lion; we are going down to the coast and back.”
With regard to the characteristic features of the various tribes here
on the western edge of the plateau, I can arrive at no other
conclusion than the one already come to in the plain, viz., that it is
impossible for anyone but a trained anthropologist to assign any
given individual at once to his proper tribe. In fact, I think that even
an anthropological specialist, after the most careful examination,
might find it a difficult task to decide. The whole congeries of peoples
collected in the region bounded on the west by the great Central
African rift, Tanganyika and Nyasa, and on the east by the Indian
Ocean, are closely related to each other—some of their languages are
only distinguished from one another as dialects of the same speech,
and no doubt all the tribes present the same shape of skull and
structure of skeleton. Thus, surely, there can be no very striking
differences in outward appearance.
Even did such exist, I should have no time
to concern myself with them, for day after day,
I have to see or hear, as the case may be—in
any case to grasp and record—an
extraordinary number of ethnographic
phenomena. I am almost disposed to think it
fortunate that some departments of inquiry, at
least, are barred by external circumstances.
Chief among these is the subject of iron-
working. We are apt to think of Africa as a
country where iron ore is everywhere, so to
speak, to be picked up by the roadside, and
where it would be quite surprising if the
inhabitants had not learnt to smelt the
material ready to their hand. In fact, the
knowledge of this art ranges all over the
continent, from the Kabyles in the north to the
Kafirs in the south. Here between the Rovuma
and the Lukuledi the conditions are not so
favourable. According to the statements of the
Makonde, neither ironstone nor any other
form of iron ore is known to them. They have
not therefore advanced to the art of smelting
the metal, but have hitherto bought all their
THE ANCESTRESS OF
THE MAKONDE
iron implements from neighbouring tribes.
Even in the plain the inhabitants are not much
better off. Only one man now living is said to
understand the art of smelting iron. This old fundi lives close to
Huwe, that isolated, steep-sided block of granite which rises out of
the green solitude between Masasi and Chingulungulu, and whose
jagged and splintered top meets the traveller’s eye everywhere. While
still at Masasi I wished to see this man at work, but was told that,
frightened by the rising, he had retired across the Rovuma, though
he would soon return. All subsequent inquiries as to whether the
fundi had come back met with the genuine African answer, “Bado”
(“Not yet”).
BRAZIER

Some consolation was afforded me by a brassfounder, whom I


came across in the bush near Akundonde’s. This man is the favourite
of women, and therefore no doubt of the gods; he welds the glittering
brass rods purchased at the coast into those massive, heavy rings
which, on the wrists and ankles of the local fair ones, continually give
me fresh food for admiration. Like every decent master-craftsman he
had all his tools with him, consisting of a pair of bellows, three
crucibles and a hammer—nothing more, apparently. He was quite
willing to show his skill, and in a twinkling had fixed his bellows on
the ground. They are simply two goat-skins, taken off whole, the four
legs being closed by knots, while the upper opening, intended to
admit the air, is kept stretched by two pieces of wood. At the lower
end of the skin a smaller opening is left into which a wooden tube is
stuck. The fundi has quickly borrowed a heap of wood-embers from
the nearest hut; he then fixes the free ends of the two tubes into an
earthen pipe, and clamps them to the ground by means of a bent
piece of wood. Now he fills one of his small clay crucibles, the dross
on which shows that they have been long in use, with the yellow
material, places it in the midst of the embers, which, at present are
only faintly glimmering, and begins his work. In quick alternation
the smith’s two hands move up and down with the open ends of the
bellows; as he raises his hand he holds the slit wide open, so as to let
the air enter the skin bag unhindered. In pressing it down he closes
the bag, and the air puffs through the bamboo tube and clay pipe into
the fire, which quickly burns up. The smith, however, does not keep
on with this work, but beckons to another man, who relieves him at
the bellows, while he takes some more tools out of a large skin pouch
carried on his back. I look on in wonder as, with a smooth round
stick about the thickness of a finger, he bores a few vertical holes into
the clean sand of the soil. This should not be difficult, yet the man
seems to be taking great pains over it. Then he fastens down to the
ground, with a couple of wooden clamps, a neat little trough made by
splitting a joint of bamboo in half, so that the ends are closed by the
two knots. At last the yellow metal has attained the right consistency,
and the fundi lifts the crucible from the fire by means of two sticks
split at the end to serve as tongs. A short swift turn to the left—a
tilting of the crucible—and the molten brass, hissing and giving forth
clouds of smoke, flows first into the bamboo mould and then into the
holes in the ground.
The technique of this backwoods craftsman may not be very far
advanced, but it cannot be denied that he knows how to obtain an
adequate result by the simplest means. The ladies of highest rank in
this country—that is to say, those who can afford it, wear two kinds
of these massive brass rings, one cylindrical, the other semicircular
in section. The latter are cast in the most ingenious way in the
bamboo mould, the former in the circular hole in the sand. It is quite
a simple matter for the fundi to fit these bars to the limbs of his fair
customers; with a few light strokes of his hammer he bends the
pliable brass round arm or ankle without further inconvenience to
the wearer.
SHAPING THE POT

SMOOTHING WITH MAIZE-COB

CUTTING THE EDGE


FINISHING THE BOTTOM

LAST SMOOTHING BEFORE


BURNING

FIRING THE BRUSH-PILE


LIGHTING THE FARTHER SIDE OF
THE PILE

TURNING THE RED-HOT VESSEL

NYASA WOMAN MAKING POTS AT MASASI


Pottery is an art which must always and everywhere excite the
interest of the student, just because it is so intimately connected with
the development of human culture, and because its relics are one of
the principal factors in the reconstruction of our own condition in
prehistoric times. I shall always remember with pleasure the two or
three afternoons at Masasi when Salim Matola’s mother, a slightly-
built, graceful, pleasant-looking woman, explained to me with
touching patience, by means of concrete illustrations, the ceramic art
of her people. The only implements for this primitive process were a
lump of clay in her left hand, and in the right a calabash containing
the following valuables: the fragment of a maize-cob stripped of all
its grains, a smooth, oval pebble, about the size of a pigeon’s egg, a
few chips of gourd-shell, a bamboo splinter about the length of one’s
hand, a small shell, and a bunch of some herb resembling spinach.
Nothing more. The woman scraped with the
shell a round, shallow hole in the soft, fine
sand of the soil, and, when an active young
girl had filled the calabash with water for her,
she began to knead the clay. As if by magic it
gradually assumed the shape of a rough but
already well-shaped vessel, which only wanted
a little touching up with the instruments
before mentioned. I looked out with the
MAKUA WOMAN closest attention for any indication of the use
MAKING A POT. of the potter’s wheel, in however rudimentary
SHOWS THE a form, but no—hapana (there is none). The
BEGINNINGS OF THE embryo pot stood firmly in its little
POTTER’S WHEEL
depression, and the woman walked round it in
a stooping posture, whether she was removing
small stones or similar foreign bodies with the maize-cob, smoothing
the inner or outer surface with the splinter of bamboo, or later, after
letting it dry for a day, pricking in the ornamentation with a pointed
bit of gourd-shell, or working out the bottom, or cutting the edge
with a sharp bamboo knife, or giving the last touches to the finished
vessel. This occupation of the women is infinitely toilsome, but it is
without doubt an accurate reproduction of the process in use among
our ancestors of the Neolithic and Bronze ages.
There is no doubt that the invention of pottery, an item in human
progress whose importance cannot be over-estimated, is due to
women. Rough, coarse and unfeeling, the men of the horde range
over the countryside. When the united cunning of the hunters has
succeeded in killing the game; not one of them thinks of carrying
home the spoil. A bright fire, kindled by a vigorous wielding of the
drill, is crackling beside them; the animal has been cleaned and cut
up secundum artem, and, after a slight singeing, will soon disappear
under their sharp teeth; no one all this time giving a single thought
to wife or child.
To what shifts, on the other hand, the primitive wife, and still more
the primitive mother, was put! Not even prehistoric stomachs could
endure an unvarying diet of raw food. Something or other suggested
the beneficial effect of hot water on the majority of approved but
indigestible dishes. Perhaps a neighbour had tried holding the hard
roots or tubers over the fire in a calabash filled with water—or maybe
an ostrich-egg-shell, or a hastily improvised vessel of bark. They
became much softer and more palatable than they had previously
been; but, unfortunately, the vessel could not stand the fire and got
charred on the outside. That can be remedied, thought our
ancestress, and plastered a layer of wet clay round a similar vessel.
This is an improvement; the cooking utensil remains uninjured, but
the heat of the fire has shrunk it, so that it is loose in its shell. The
next step is to detach it, so, with a firm grip and a jerk, shell and
kernel are separated, and pottery is invented. Perhaps, however, the
discovery which led to an intelligent use of the burnt-clay shell, was
made in a slightly different way. Ostrich-eggs and calabashes are not
to be found in every part of the world, but everywhere mankind has
arrived at the art of making baskets out of pliant materials, such as
bark, bast, strips of palm-leaf, supple twigs, etc. Our inventor has no
water-tight vessel provided by nature. “Never mind, let us line the
basket with clay.” This answers the purpose, but alas! the basket gets
burnt over the blazing fire, the woman watches the process of
cooking with increasing uneasiness, fearing a leak, but no leak
appears. The food, done to a turn, is eaten with peculiar relish; and
the cooking-vessel is examined, half in curiosity, half in satisfaction
at the result. The plastic clay is now hard as stone, and at the same
time looks exceedingly well, for the neat plaiting of the burnt basket
is traced all over it in a pretty pattern. Thus, simultaneously with
pottery, its ornamentation was invented.
Primitive woman has another claim to respect. It was the man,
roving abroad, who invented the art of producing fire at will, but the
woman, unable to imitate him in this, has been a Vestal from the
earliest times. Nothing gives so much trouble as the keeping alight of
the smouldering brand, and, above all, when all the men are absent
from the camp. Heavy rain-clouds gather, already the first large
drops are falling, the first gusts of the storm rage over the plain. The
little flame, a greater anxiety to the woman than her own children,
flickers unsteadily in the blast. What is to be done? A sudden thought
occurs to her, and in an instant she has constructed a primitive hut
out of strips of bark, to protect the flame against rain and wind.
This, or something very like it, was the way in which the principle
of the house was discovered; and even the most hardened misogynist
cannot fairly refuse a woman the credit of it. The protection of the
hearth-fire from the weather is the germ from which the human
dwelling was evolved. Men had little, if any share, in this forward
step, and that only at a late stage. Even at the present day, the
plastering of the housewall with clay and the manufacture of pottery
are exclusively the women’s business. These are two very significant
survivals. Our European kitchen-garden, too, is originally a woman’s
invention, and the hoe, the primitive instrument of agriculture, is,
characteristically enough, still used in this department. But the
noblest achievement which we owe to the other sex is unquestionably
the art of cookery. Roasting alone—the oldest process—is one for
which men took the hint (a very obvious one) from nature. It must
have been suggested by the scorched carcase of some animal
overtaken by the destructive forest-fires. But boiling—the process of
improving organic substances by the help of water heated to boiling-
point—is a much later discovery. It is so recent that it has not even
yet penetrated to all parts of the world. The Polynesians understand
how to steam food, that is, to cook it, neatly wrapped in leaves, in a
hole in the earth between hot stones, the air being excluded, and
(sometimes) a few drops of water sprinkled on the stones; but they
do not understand boiling.
To come back from this digression, we find that the slender Nyasa
woman has, after once more carefully examining the finished pot,
put it aside in the shade to dry. On the following day she sends me
word by her son, Salim Matola, who is always on hand, that she is
going to do the burning, and, on coming out of my house, I find her
already hard at work. She has spread on the ground a layer of very
dry sticks, about as thick as one’s thumb, has laid the pot (now of a
yellowish-grey colour) on them, and is piling brushwood round it.
My faithful Pesa mbili, the mnyampara, who has been standing by,
most obligingly, with a lighted stick, now hands it to her. Both of
them, blowing steadily, light the pile on the lee side, and, when the
flame begins to catch, on the weather side also. Soon the whole is in a
blaze, but the dry fuel is quickly consumed and the fire dies down, so
that we see the red-hot vessel rising from the ashes. The woman
turns it continually with a long stick, sometimes one way and
sometimes another, so that it may be evenly heated all over. In
twenty minutes she rolls it out of the ash-heap, takes up the bundle
of spinach, which has been lying for two days in a jar of water, and
sprinkles the red-hot clay with it. The places where the drops fall are
marked by black spots on the uniform reddish-brown surface. With a
sigh of relief, and with visible satisfaction, the woman rises to an
erect position; she is standing just in a line between me and the fire,
from which a cloud of smoke is just rising: I press the ball of my
camera, the shutter clicks—the apotheosis is achieved! Like a
priestess, representative of her inventive sex, the graceful woman
stands: at her feet the hearth-fire she has given us beside her the
invention she has devised for us, in the background the home she has
built for us.
At Newala, also, I have had the manufacture of pottery carried on
in my presence. Technically the process is better than that already
described, for here we find the beginnings of the potter’s wheel,
which does not seem to exist in the plains; at least I have seen
nothing of the sort. The artist, a frightfully stupid Makua woman, did
not make a depression in the ground to receive the pot she was about
to shape, but used instead a large potsherd. Otherwise, she went to
work in much the same way as Salim’s mother, except that she saved
herself the trouble of walking round and round her work by squatting
at her ease and letting the pot and potsherd rotate round her; this is
surely the first step towards a machine. But it does not follow that
the pot was improved by the process. It is true that it was beautifully
rounded and presented a very creditable appearance when finished,
but the numerous large and small vessels which I have seen, and, in
part, collected, in the “less advanced” districts, are no less so. We
moderns imagine that instruments of precision are necessary to
produce excellent results. Go to the prehistoric collections of our
museums and look at the pots, urns and bowls of our ancestors in the
dim ages of the past, and you will at once perceive your error.
MAKING LONGITUDINAL CUT IN
BARK

DRAWING THE BARK OFF THE LOG

REMOVING THE OUTER BARK


BEATING THE BARK

WORKING THE BARK-CLOTH AFTER BEATING, TO MAKE IT


SOFT

MANUFACTURE OF BARK-CLOTH AT NEWALA


To-day, nearly the whole population of German East Africa is
clothed in imported calico. This was not always the case; even now in
some parts of the north dressed skins are still the prevailing wear,
and in the north-western districts—east and north of Lake
Tanganyika—lies a zone where bark-cloth has not yet been
superseded. Probably not many generations have passed since such
bark fabrics and kilts of skins were the only clothing even in the
south. Even to-day, large quantities of this bright-red or drab
material are still to be found; but if we wish to see it, we must look in
the granaries and on the drying stages inside the native huts, where
it serves less ambitious uses as wrappings for those seeds and fruits
which require to be packed with special care. The salt produced at
Masasi, too, is packed for transport to a distance in large sheets of
bark-cloth. Wherever I found it in any degree possible, I studied the
process of making this cloth. The native requisitioned for the
purpose arrived, carrying a log between two and three yards long and
as thick as his thigh, and nothing else except a curiously-shaped
mallet and the usual long, sharp and pointed knife which all men and
boys wear in a belt at their backs without a sheath—horribile dictu!
[51]
Silently he squats down before me, and with two rapid cuts has
drawn a couple of circles round the log some two yards apart, and
slits the bark lengthwise between them with the point of his knife.
With evident care, he then scrapes off the outer rind all round the
log, so that in a quarter of an hour the inner red layer of the bark
shows up brightly-coloured between the two untouched ends. With
some trouble and much caution, he now loosens the bark at one end,
and opens the cylinder. He then stands up, takes hold of the free
edge with both hands, and turning it inside out, slowly but steadily
pulls it off in one piece. Now comes the troublesome work of
scraping all superfluous particles of outer bark from the outside of
the long, narrow piece of material, while the inner side is carefully
scrutinised for defective spots. At last it is ready for beating. Having
signalled to a friend, who immediately places a bowl of water beside
him, the artificer damps his sheet of bark all over, seizes his mallet,
lays one end of the stuff on the smoothest spot of the log, and
hammers away slowly but continuously. “Very simple!” I think to
myself. “Why, I could do that, too!”—but I am forced to change my
opinions a little later on; for the beating is quite an art, if the fabric is
not to be beaten to pieces. To prevent the breaking of the fibres, the
stuff is several times folded across, so as to interpose several
thicknesses between the mallet and the block. At last the required
state is reached, and the fundi seizes the sheet, still folded, by both
ends, and wrings it out, or calls an assistant to take one end while he
holds the other. The cloth produced in this way is not nearly so fine
and uniform in texture as the famous Uganda bark-cloth, but it is
quite soft, and, above all, cheap.
Now, too, I examine the mallet. My craftsman has been using the
simpler but better form of this implement, a conical block of some
hard wood, its base—the striking surface—being scored across and
across with more or less deeply-cut grooves, and the handle stuck
into a hole in the middle. The other and earlier form of mallet is
shaped in the same way, but the head is fastened by an ingenious
network of bark strips into the split bamboo serving as a handle. The
observation so often made, that ancient customs persist longest in
connection with religious ceremonies and in the life of children, here
finds confirmation. As we shall soon see, bark-cloth is still worn
during the unyago,[52] having been prepared with special solemn
ceremonies; and many a mother, if she has no other garment handy,
will still put her little one into a kilt of bark-cloth, which, after all,
looks better, besides being more in keeping with its African
surroundings, than the ridiculous bit of print from Ulaya.
MAKUA WOMEN

You might also like