100% found this document useful (1 vote)
59 views49 pages

(Ebooks PDF) Download Programming For Problem Solving - GTU 2018 - Ebook PDF Full Chapters

The document provides information about various programming eBooks available for download on ebookluna.com, focusing on problem-solving using programming languages such as C, Python, and Java. It includes details about the author E Balagurusamy and the structure of the book 'Programming for Problem Solving,' which covers fundamental programming concepts and techniques. Additionally, it mentions the publisher McGraw Hill Education and the importance of the C programming language in modern software development.

Uploaded by

ignustotie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
59 views49 pages

(Ebooks PDF) Download Programming For Problem Solving - GTU 2018 - Ebook PDF Full Chapters

The document provides information about various programming eBooks available for download on ebookluna.com, focusing on problem-solving using programming languages such as C, Python, and Java. It includes details about the author E Balagurusamy and the structure of the book 'Programming for Problem Solving,' which covers fundamental programming concepts and techniques. Additionally, it mentions the publisher McGraw Hill Education and the importance of the C programming language in modern software development.

Uploaded by

ignustotie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Get the full ebook with Bonus Features for a Better Reading Experience on ebookluna.

com

Programming for Problem Solving- GTU 2018 - eBook


PDF

https://ebookluna.com/download/programming-for-problem-
solving-ebook-pdf/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookluna.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

(eBook PDF) Programming, Problem Solving and Abstraction


with C

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

ebookluna.com

Problem Solving and Python Programming 1st edition - eBook


PDF

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

ebookluna.com

Programming and Problem Solving with Python 1st Edition -


eBook PDF

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

ebookluna.com

(eBook PDF) Java: An Introduction to Problem Solving and


Programming 7th Edition

https://ebookluna.com/product/ebook-pdf-java-an-introduction-to-
problem-solving-and-programming-7th-edition/

ebookluna.com
(eBook PDF) Java: An Introduction to Problem Solving and
Programming 8th Edition

https://ebookluna.com/product/ebook-pdf-java-an-introduction-to-
problem-solving-and-programming-8th-edition/

ebookluna.com

Mathematics-1, GTU–2018 - eBook PDF

https://ebookluna.com/download/mathematics-1-gtu-2018-ebook-pdf/

ebookluna.com

(eBook PDF) Matlab: A Practical Introduction to


Programming and Problem Solving 4th Edition

https://ebookluna.com/product/ebook-pdf-matlab-a-practical-
introduction-to-programming-and-problem-solving-4th-edition/

ebookluna.com

(eBook PDF) Introduction to Programming with Java: A


Problem Solving Approach 3rd Edition

https://ebookluna.com/product/ebook-pdf-introduction-to-programming-
with-java-a-problem-solving-approach-3rd-edition/

ebookluna.com

(eBook PDF) Community Policing: Partnerships for Problem


Solving 8th Edition

https://ebookluna.com/product/ebook-pdf-community-policing-
partnerships-for-problem-solving-8th-edition/

ebookluna.com
PROGRAMMING
fOR
PRObleM SOlvING
Gujarat Technological University - 2018
About the Author

E Balagurusamy, is presently the Chairman of EBG Foundation, Coimbatore. In the past he has also held
the positions of member, Union Public Service Commission, New Delhi and Vice-Chancellor, Anna University,
Chennai. He is a teacher, trainer and consultant in the fields of Information Technology and Management.
He holds an ME (Hons) in Electrical Engineering and PhD in Systems Engineering from the Indian Institute
of Technology, Roorkee. His areas of interest include Object-Oriented Software Engineering, E-Governance:
Technology Management, Business Process Re-engineering and Total Quality Management.
A prolific writer, he has authored a large number of research papers and several books.
A recipient of numerous honors and awards, he has been listed in the Directory of Who's Who of Intellectuals
and in the Directory of Distinguished Leaders in Education.
PROGRAMMING
fOR
PRObleM SOlvING
Gujarat Technological University - 2018

E Balagurusamy
Chairman
EBG Foundation
Coimbatore

McGraw Hill Education (India) Private Limited


CHENNAI

McGraw Hill Education Offices


Chennai New York St Louis San Francisco Auckland Bogotá Caracas
Kuala Lumpur Lisbon London Madrid Mexico City Milan Montreal
San Juan Santiago Singapore Sydney Tokyo Toronto
McGraw Hill Education (India) Private Limited
Published by McGraw Hill Education (India) Private Limited
444/1, Sri Ekambara Naickr Industrial Estate, Alapakkam, Porur, Chennai-600 116

Programming for Problem Solving


Copyright © 2019 by McGraw Hill Education (India) Private Limited.
No part of this publication may be reproduced or distributed in any form or by any means, electronic, mechanical,
photocopying, recording, or otherwise or stored in a database or retrieval system without the prior written permission of
the publishers. The program listings (if any) may be entered, stored and executed in a computer system, but they may not
be reproduced for publication.
This edition can be exported from India only by the publishers,
McGraw Hill Education (India) Private Limited.
Print Edition
ISBN (13 digit): 978-93-5316-278-8
ISBN (10 digit): 93-5316-278-5
E-book Edition
ISBN (13 digit): 978-93-5316-279-5
ISBN (10 digit): 93-5316-279-3
1 23456789 D101417 22 21 20 19 18
Printed and bound in India.
Director—Science & Engineering Portfolio: Vibha Mahajan
Senior Portfolio Manager—Science & Engineering: Hemant K Jha
Associate Portfolio Manager —Science & Engineering: Tushar Mishra
Production Head: Satinder S Baveja
Copy Editor: Taranpreet Kaur
Assistant Manager—Production: Suhaib Ali
General Manager—Production: Rajender P Ghansela
Manager—Production: Reji Kumar

Information contained in this work has been obtained by McGraw Hill Education (India), from sources believed to be
reliable. However, neither McGraw Hill Education (India) nor its authors guarantee the accuracy or completeness of any
information published herein, and neither McGraw Hill Education (India) nor its authors shall be responsible for any errors,
omissions, or damages arising out of use of this information. This work is published with the understanding that McGraw
Hill Education (India) and its authors are supplying information but are not attempting to render engineering or other
professional services. If such services are required, the assistance of an appropriate professional should be sought.

Typeset at The Composers, 260, C.A. Apartment, Paschim Vihar, New Delhi 110 063 and printed at

Cover Printer:
Cover Designer: APS Compugraphics
Cover Image Source: Shutterstock
Visit us at: www.mheducation.co.in
Write to us at: [email protected]
CIN: U22200TN1970PTC111531
Toll Free Number: 1800 103 5875
Preface

P
rogramming for Problem Solving requires a deep understanding of C. C is a powerful, flexible, portable
and elegantly structured programming language. Since C combines the features of high-level language
with the elements of the assembler, it is suitable for both systems and applications programming. It
is undoubtedly the most widely used general-purpose language today in operating systems, and embedded
system development. Its influence is evident in almost all modern programming languages. Since its
standardization in 1989, C has undergone a series of changes and improvements in order to enhance the
usefulness of the language.

Organization of the Book


Programming for Problem Solving starts with an Introduction to Computer Programming, Chapter 2 discusses
fundamentals of C. Control Structures in C is presented in Chapter 3. Chapter 4 deals with Arrays and
Strings. Chapter 5 discusses Functions. In Chapter 6 students can study Pointers. While Chapter 7 details
Structure. Dynamic Memory Allocation is discussed in Chapter 8. Chapter 9 details on File Management.

Salient Features of the Book


∑ Learning Objectives
∑ Key Concepts
∑ Content Tagged with LO
∑ Worked Out Problems
∑ Tips
∑ Closing Vignette
∑ Review Exercises – True False, Fill in the blanks, Questions, Programming Exercises – categorized into
LO and Difficulty level (E for Easy, M for Medium and H for High)

Acknowledgements
I owe special thanks to the entire team of McGraw Hill Education India.
A note of acknowledgement is due to the following reviewers for their valuable feedback.

Ms. Kalpana Mudaliar Gandhinagar Institute of Technology, Gandhinagar, Gujarat


H K Patnaik Kalinga Institute of Industrial Technology, KIIT University, Bhubaneswar
T V Gopal College of Engineering, Anna University, Chennai, Tamil Nadu
Unnati Nitin Chaudhari Tolani Maritime Institute, Pune, Maharashtra
Tanveer Ahmed Jamia Millia Islamia, Delhi
Ravindra Divekar KJ Somaiya College of Engineering, Mumbai, Maharashtra
SC Dutta Birsa Institute of Technology, Sindri, Dhanbad, Jharkhand
D Lakshmi Adithya Institute of Technology, Coimbatore, Tamil Nadu
vi Preface

This book is my sincere attempt to make a footprint on the immensely vast and infinite sands of knowledge.
I would request the readers to utilize this book to the maximum extent.
E Balagurusamy

Publisher’s Note
McGraw Hill Education (India) invites suggestions and comments from you, all of which can be sent to info.
[email protected] (kindly mention the title and author name in the subject line).
Piracy-related issues may also be reported.
Contents

About the Author ii


Preface v

1. Introduction to Computer and Programming 1


Learning Objectives 1
Introduction 1
Generations of Computers 2
Classification of Computers 5
Basic Anatomy of a Computer System 7
Input Devices 8
Processor 9
Output Devices 10
Memory Management 12
Types of Computer Software 13
Overview of Operating System 14
MS Word 19
MS Excel System 21
MS Powerpoint System 22
Networking Concepts 23
Network Topologies 25
Network Protocols and Software 29
Decimal System 31
Binary System 32
Hexadecimal System 33
Octal System 34
Conversion of Numbers 35
Binary Arithmetic Operations 44
Logic Gates 52
Programming Languages 55
viii Contents

Translator Programs 58
Problem-Solving Techniques 59
Using the Computer 70
Learning Outcomes 70
Key Concepts 71
Review Questions 73
Discussion Questions 84

2. Fundamentals of C 87
Learning Objectives 87
History of C 87
Importance of C 89
Sample Program 1: Printing a Message 89
Sample Program 2: Adding Two Numbers 92
Sample Program 3: Interest Calculation 93
Sample Program 4: Use of Subroutines 95
Sample Program 5: Use of Math Functions 96
Basic Structure of C Programs 97
Programming Style 98
Executing a ‘C’ Program 99
UNIX System 99
MS-DOS System 102
Key Concepts 102
Always Remember 103
Review Questions 103
Debugging Exercises 105
Programming Exercises 105

3. Control Structure in C 107


Learning Objectives 107
Introduction 107
Decision Making with if Statement 108
Simple If Statement 108
The If.....Else Statement 111
Nesting of If....Else Statements 114
The Else If Ladder 117
The Switch Statement 121
The ? : Operator 125
The goto Statement 129
Key Concepts 132
Contents ix

Always Remember 132


Brief Cases 132
Review Questions 137
Debugging Exercises 141
Programming Exercises 141

4. Array & String 145


Learning Objectives 145
Introduction 145
One-Dimensional Arrays 147
Declaration of One-dimensional Arrays 148
Initialization of One-dimensional Arrays 151
Two-Dimensional Arrays 156
Initializing Two-dimensional Arrays 161
Multi-dimensional Arrays 168
Dynamic Arrays 169
More About Arrays 170
Declaring and Initializing String Variables 170
Reading Strings from Terminal 171
Writing Strings to Screen 177
Arithmetic Operations on Characters 181
Putting Strings Together 183
Comparison of Two Strings 184
String-Handling Functions 184
Table of Strings 190
Other Features of Strings 192
Key Concepts 192
Always Remember 193
Brief Cases 194
Review Questions 210
Debugging Exercises 214
Programming Exercises 215

5. Functions 220
Learning Objectives 220
Introduction 220
Need for User-Defined Functions 221
A Multi-Function Program 221
Elements of User-Defined Functions 224
x Contents

Definition of Functions 224


Return Values and Their Types 227
Function Calls 228
Function Declaration 229
Category of Functions 231
No Arguments and No Return Values 231
Arguments but No Return Values 233
Arguments with Return Values 236
No Arguments but Returns a Value 241
Functions that Return Multiple Values 242
Nesting of Functions 243
Recursion 244
Passing Arrays to Functions 245
Passing Strings to Functions 250
The Scope, Visibility and Lifetime of Variables 251
Multifile Programs 260
Key Concepts 262
Always Remember 262
Brief Cases 263
Review Questions 266
Debugging Exercises 270
Programming Exercises 270

6. Pointers 273
Learning Objectives 273
Introduction 273
Understanding Pointers 274
Accessing the Address of a Variable 276
Declaring Pointer Variables 277
Initialization of Pointer Variables 278
Accessing a Variable Through its Pointer 279
Chain of Pointers 281
Pointer Expressions 282
Pointer Increments and Scale Factor 284
Pointers and Arrays 284
Pointers and Character Strings 288
Array of Pointers 290
Pointers as Function Arguments 291
Functions Returning Pointers 294
Contents xi

Pointers to Functions 295


Pointers and Structures 297
Troubles with Pointers 299
Key Concepts 300
Always Remember 300
Brief Cases 301
Review Questions 306
Debugging Exercises 309
Programming Exercises 309

7. Structure 311
Learning Objectives 311
Introduction 311
Defining a Structure 312
Declaring Structure Variables 313
Accessing Structure Members 315
Structure Initialization 316
Copying and Comparing Structure Variables 318
Operations on Individual Members 320
Arrays of Structures 320
Arrays within Structures 323
Structures within Structures 324
Structures and Functions 326
Unions 329
Size of Structures 330
Bit Fields 330
Key Concepts 333
Always Remember 333
Brief Cases 334
Review Questions 338
Debugging Exercises 341
Programming Exercises 341

8. Dynamic Memory Allocation 344


Learning Objectives 344
Introduction 344
Dynamic Memory Allocation 344
Allocating a Block of Memory: malloc 345
Allocating Multiple Blocks of Memory: calloc 347
xii Contents

Releasing the Used Space: free 348


Altering the Size of a Block: realloc 348
Concepts of Linked Lists 350
Advantages of Linked Lists 353
Types of Linked Lists 354
Pointers Revisited 354
Creating a Linked List 356
Inserting an Item 360
Deleting an Item 363
Application of Linked Lists 365
Key Concepts 365
Always Remember 366
Brief Cases 366
Review Questions 372
Debugging Exercises 374
Programming Exercises 374

9. File Management 376


Learning Objectives 376
Introduction 376
Defining and Opening a File 377
Closing a File 378
Input/Output Operations on Files 379
Error Handling During I/O Operations 385
Random Access to Files 387
Command Line Arguments 394
Key Concepts 396
Always Remember 396
Review Questions 397
Debugging Exercises 398
Programming Exercises 398
Roadmap to the Syllabus
Programming For Problem Solving
Code: 3110003

Introduction to computer and programming: Introduction, Basic block diagram and functions of various
components of computer, Concepts of Hardware and software, Types of software, Compiler and interpreter,
Concepts of Machine level, Assembly level and high level programming, Flowcharts and Algorithms

GO TO Chapter 1 Introduction to Computer and Programming

Fundamentals of C: Features of C language, structure of C Program, comments, header files, data types,
constants and variables, operators, expressions, evaluation of expressions, type conversion, precedence
and associativity, I/O functions

GO TO Chapter 2 Fundamentals of C

Control structure in C: Simple statements, Decision making statements, Looping statements, Nesting of
control structures, break and continue, goto statement

GO TO Chapter 3 Control Structure in C

Array & String: Concepts of array, one and two dimensional arrays, declaration and initialization of arrays,
string, string storage, Built-in-string functions
Recursion: Recursion, as a different way of solving problems. Example programs, such as Finding
Factorial, Fibonacci series, Ackerman function etc. Quick sort or Merge sort.

GO TO Chapter 4 Array & String


xiv Roadmap to the Syllabus

Functions: Concepts of user defined functions, prototypes, definition of function, parameters, parameter
passing, calling a function, recursive function, Macros, Pre-processing

GO TO Chapter 5 Functions

Pointers: Basics of pointers, pointer to pointer, pointer and array, pointer to array, array to pointer, function
returning pointer

GO TO Chapter 6 Pointers

Structure: Basics of structure, structure members, accessing structure members, nested structures, array
of structures, structure and functions, structures and pointers

GO TO Chapter 7 Structure

Dynamic memory allocation: Introduction to Dynamic memory allocation, malloc, calloc

GO TO Chapter 8 Dynamic Memory Allocation

File management: Introduction to file management and its functions

GO TO Chapter 9 File Management


Introduction to
Chapter
Computer and
Programming 1
LEARNING OBJECTIVES
LO 1.1 Identify the various generations of computers
LO 1.2 Classify computers on the basis of different criteria
LO 1.3 Describe the computer system
LO 1.4 Classify various computer software
LO 1.5 Discuss various operating systems
LO 1.6 Discuss Microsoft software
LO 1.7 Know various networking concepts and protocols
LO 1.8 Identify the various positional number systems
LO 1.9 Carry out number conversions from one number system to another
LO 1.10 Explain how binary arithmetic operations are performed
LO 1.11 Describe primary logic gates
LO 1.12 Discuss various levels of programming languages
LO 1.13 Know various problem solving techniques and computer applications

introduction
A computer is an electronic machine that takes input from the user, processes the given input and generates
output in the form of useful information. A computer accepts input in different forms such as data, programs
and user reply. Data refer to the raw details that need to be processed to generate some useful information.
Programs refer to the set of instructions that can be executed by the computer in sequential or non-
sequential manner. User reply is the input provided by the user in response to a question asked by the
computer.
A computer includes various devices that function as an integrated system to perform several tasks
described above (Fig. 1.1). These devices are:
Central Processing Unit (CPU)
It is the processor of the computer that is responsible for controlling and executing instructions in the computer.
It is considered as the most significant component of the computer.
Other documents randomly have
different content
So Rago shouted very loudly. He shouted again and again.
The leader of the men heard the call.
“I hear someone calling,” he said. “Let us go into the forest and see
who it is.”
So all of the men went into the forest and soon came upon Rago
and Goni, who were sitting on the ground, with their mother and
baby sister.
“Did you call?” asked the leader.
“Yes,” answered their mother. “Will you take us with you?
“We should like to join your clan.”
“Yes,” said the leader, “we shall be glad to have you.”
“Shall we have someone to play with?” asked Rago.
“Yes, there are many boys and girls in our clan,” answered the
leader.
“You are very brave,” said Rago. “I watched you drive the huge
rhinoceros to the edge of the cliff.”
“I should like to be as brave as you are when I am a man.”
“We will teach you how to be brave,” said the leader.
“Come, let us start as it is getting late.”
So they all started off together.
Rago and Goni weren’t a bit afraid because they were with these
brave men.
“What is that?” asked Rago, pointing to the firebrand.
“This is a fire-torch,” said the leader; “when we carry these we need
not be afraid.
“Fire protects us from the wild beast.”
“And where do you get fire?” asked Rago.
“Not so very long ago we had a terrible storm in our forest. It
thundered and lightened.
“The lightning set fire to the trees in the forest.
“At first we Tree-dwellers thought that the fire was a terrible
monster. We were frightened and ran away from it.
“Then we learned that the fire would not harm us and that if we fed
it wood, it would burn on forever.
“When we have fire there is no need for swinging from tree to tree,
for we are safe on the ground.”
“Do the wild beasts fear the firebrands?” asked Rago.
“Yes,” answered the leader.
“May I use a firebrand?” asked Rago.
“Yes,” answered the leader. “You may light your own firebrand, and
you may help us feed the fire also.”
“I am glad we are going to live with you,” said Rago.
“We shall be glad to have you,” said the leader.
CHAPTER VII
THE FIRE

“I am tired and hungry,” said Goni.


“All right,” said the leader, “let us look for food.
“There are plenty of roots and nuts around here.”
“Here are some acorns, Goni; eat them.”
Rago found his own food as did all of the men.
After they had eaten all they wished they started off again.
“The trees might be safer,” said the leader, “for our torches have
gone out and it is getting late.”
“I can already hear the growls of the cave bear.”
“They have been asleep all day and are looking for a feast.”
“All for the trees!” shouted the leader.
So they all climbed the trees and nimbly swung from branch to
branch.
“That largest horse is leading the herd up the trail.”
“I wonder if there are any wild beasts lying in wait for them!”
“Where do the horses go at night?” asked Goni.
“To the grassy plain outside the forest,” answered the leader.
“They have to eat the green grass which they find there.”
“Here we are,” said the leader, as all of the men suddenly jumped to
the ground.
There were many Tree-dwellers squatting around the fire.
One strong Tree-dweller woman was
feeding the fire with huge cedar logs.
Some of the young boys were playing that
a cave bear had come suddenly upon them.
They had make-believe torches with which
they were pretending to frighten the fierce
bear.
They all stopped and looked at Rago and
Goni and their mother, who had baby sister
in her arms.
Baby sister began to cry when she saw so
many people.
Goni clutched Rago’s arm.
“I am afraid, Rago,” said Goni.
Rago was frightened also. He didn’t go very near the fire.
“You need not be afraid,” said the leader. “The fire is our friend. It
will not hurt you.”
The children ran toward Rago and Goni and pushed them toward the
fire.
“It will not hurt you,” they cried.
“It will keep you warm, and protect you from the wild beasts.
“See, here is some roasted squirrel’s meat which you may have.
“Taste it and see how good it is.”
Rago had never eaten roasted meat before.
“It is good,” said Rago. “I have never eaten roasted meat before.

“How did you learn that meat could be roasted?”


“One day, Strong-arm, the leader of our clan, threw down a squirrel
near the fire. It was so near that the fire scorched it.
“When Strong-arm ate the squirrel’s meat it tasted so good that he
told the other people in the clan about it.
“Since then we often roast our meat because we like it better than
raw meat.”
“Do you like roasted meat, mother?” asked Rago.
“Here is a piece of meat for you, baby sister,” said Goni.
“Come, sit down with us,” said the children.
“Strong-arm has something to show us.”
Strong-arm was sitting near the fire with the other Tree-dwellers
about him.
He was telling them all about the hunt that day.
He told them how the huge rhinoceros had fallen over the cliff.
He showed them the tusks, and teeth and claws.
The Tree-dwellers were all very much pleased, and they praised the
men for their bravery.
When he had finished talking, Strong-arm jumped up.
“Let us all play the hunt of today,” he said.
“You be the leader, Strong-arm,” they shouted.
“All right,” said Strong-arm; “let us pretend that the huge rhinoceros
is here and we will show you just what we did.”
So the men played the hunt.
They acted just as if it were real.
“This is our hunting dance,” said one of the children to Rago.
“We have a hunting dance every night after the men return from the
hunt.
“These make us brave and teach us how to hunt together.
“They teach all of the people how to do their part.
“Some day we shall be brave enough to take part in a real hunt.”
“I hope to be brave enough to be a leader,” said Rago.
“Yes,” said the other child, “I do too.”
CHAPTER VIII
THE SHELTER

It was growing late and the Tree-dwellers were tired.


So they stretched themselves about the fire to sleep.
“I shall watch the fire tonight,” said one of the women.
“Why must someone watch the fire?” asked Rago.
“We must not let it go out,” answered Strong-arm, “for if we did we
would have no fire.”
“I do not wish to sleep on the ground,” said Goni. “I am afraid.”
“You may sleep in the trees if you wish,” said Strong-arm.
“Where will you sleep, Rago?” asked Strong-arm.
“I shall sleep on the ground,” answered Rago. “I am not afraid.”
So their mother found a bed in the evergreen trees for Goni and
baby sister.
She, too, stretched herself on a limb and tied herself tightly to it so
she would not fall.
There she could watch baby sister and Goni.
She could look down on the Tree-dwellers as they slept on the
ground.
The trees sheltered them from the wind and rain.
So they slept through the long night.
All night long the woman Tree-dweller fed the fire. She did not sleep
for fear the fire would go out.
In the early morning the Tree-dwellers awoke.
Each one left the fireplace to go in search of food.
The mothers carried their babies with them, and did not go far away
from the fire.
The men went into the forest.
They left a woman in charge of the fire.
When Goni and baby sister awoke, Rago had already eaten his
breakfast of berries and roots, which he found near by.
He stood watching some women who were working among the
evergreen trees.
He wondered what they were doing, as he watched them break off
the evergreen branches.
“Shall I help you carry them?” asked Rago.
“Thank you,” said the woman. “You may carry the branches to those
young trees near the fire. We shall follow you.”
Rago wondered what the women would do with the branches.
They soon came carrying armfuls of them.
Rago watched them bend down the tops of the young trees and tie
them together.
They wove the evergreens among them and piled larger branches
against the young trees to strengthen them.
“What are you making?” asked Rago.
“A shelter for our children, which will protect them from the cold and
rain.
“Now that it is cold and the trees have lost their leaves we need
shelter for our children.”
“Do not these evergreen trees protect you from the rain and snow?”
asked Rago.
“Not always,” answered the woman.
“We have carried our fire to the evergreen trees, because they are
the only trees which will protect us in the winter.
“But the needles of the evergreen trees do not protect us so well as
the leaves of the birch and oak trees.”
“I have never seen a shelter before,” said Rago.
“No,” said the woman, “this is the first house which the Tree-
dwellers have made.”
Rago went to the fire. The Tree-dweller woman was piling cedar logs
upon it.
“Where are all of the men?” asked Rago.
“They have gone into the forest to hunt,” answered the woman.
“Come, Rago,” called one of the boys, “let us go into the forest too.”
“What is your name?” asked Rago of the boy.
“My name is Long-head,” said the boy.

“How old are you, Long-head?” asked Rago.


“I am fourteen years old,” answered Long-head.
“I am twelve,” said Rago.
“Come along,” said Long-head, “here is a firebrand for you.”
Rago felt very big with the firebrand in his hand.
He wasn’t afraid to carry it.
Now he would not have to swing from branch to branch, but could
walk upon the ground. He would be safe while he carried the torch.
The two boys wandered into the forest.
At first they followed the trail, then they left the trail and went into
the denser part of the forest.
Long-head walked faster than Rago and soon got ahead.
Rago did not hurry, for he had many strange things to look at.
He was used to traveling in the trees, for he had never before had a
torch to protect him.
He felt very brave and safe as he walked along.
CHAPTER IX
THE ATTACK

Suddenly he stopped, for he heard a loud call.


“Help! help!” came from the distance.
“I’m coming,” shouted Rago, “I’m coming,” and he ran in the
direction of the call.
“Help! help!” came the call again, and this time Rago knew that it
was Long-head calling.
“I’m coming, I’m coming,” shouted Rago as he ran on as fast as he
could.
It was not very easy running, for the trees were very thick in this
part of the forest.
As he neared the spot from which the sound had come, he heard a
fierce growl.
Growl after growl he heard. “’Tis a wolf, ’tis a wolf,” he thought.
“Where is your torch, Long-head?” panted Rago, as he came up out
of breath.
He saw Long-head standing against the tree, and the wolf ready to
spring upon him.
Long-head was terribly frightened, for he could not defend himself
against the wolf.
His torch was out, and he had lost his club. He didn’t dare attempt
to climb the tree for fear the wolf would seize him.
Rago came up cautiously from behind. With one bound he waved his
torch before the eyes of the wolf.
The fire terrified the wolf and he made one leap for the thicket.
Then Long-head sank to the ground. He was weak with fright.
“He almost had me, that time,” said Long-head.
“He was upon me before I knew it. My torch had gone out and I was
waiting for you, when the wolf sprang toward me.

“He must have come from the thicket, because I didn’t see him until
he was upon me.”
“That certainly was a narrow escape,” said Rago.
“I am glad I heard you call.
“We must stay together now; my torch will protect both of us.”
“Let us find something to eat,” said Long-head.
So they walked on through the forest. They found nuts and roots
and fruits.
“Look out,” said Long-head, pointing to an opening in the hillside.
“That is the home of the cave bear. Don’t go too near.”
“The cave bears are asleep, aren’t they?” asked Rago.
“Yes, but they may wake up,” answered Long-head.

“I shouldn’t care to be attacked by a cave bear,” said Long-head.


“They certainly are fierce creatures.”
“What a fine patch of blueberries!” said Rago.
“Goni and baby sister would like some of these berries, I know. I
wish I might carry some to them.”
“I will show you how to make a basket,” said Long-head.
“Let us find some rushes.”
“There is a marshy place,” said Long-head, pointing to the river. “We
can find some rushes there.”
So the boys gathered the rushes and sat down upon the ground to
make the basket.
Long-head wove the rushes together for the bottom of the basket.
When he had tied the ends together at the top, he wove around the
sides, until the basket was deep enough. Then he fastened the
rushes tightly, so that the basket would be strong enough to hold
the berries.

“What a fine basket,” said Rago. “I have never seen a rush basket
before.
“Now let me try to make one.” Then Rago wove a basket like the
one which Long-head had made.
“Mother will be pleased to see my basket,” said Rago.
“Now for the blueberry patch. We can fill our baskets.”
The two boys picked enough berries to fill their baskets.
“These baskets are very strong,” said Rago.
“Yes,” said Long-head. “Oak leaves make strong baskets, also.”
After they had filled their baskets the boys wandered about for a
while.
They watched the cattle going toward the stream for their evening’s
drink.
“Let us follow them,” said Long-head.
They enjoyed seeing the cattle wade knee-deep into the stream and
drink of the clear, cool water.
Both Rago and Long-head dipped their hands into the water. They
filled them and drank.
They were thirsty, for they had had no water all day.
“’Tis growing late,” said Long-head. “See, the sun is setting.
“The men will be coming back to the fire. Let us go back also.
“We shall have to tell them about the fierce wolf.”
“Will they play it?” asked Rago.
“Yes, indeed,” answered Long-head.
CHAPTER X
THE RETURN

When Rago and Long-head reached the fire, the men had already
returned.
They were sitting on the ground about the fire.
Rago ran up to Goni, saying, “Here are some fine blueberries, Goni. I
thought you would like them.”
“Where did you get the basket, Rago?” asked Goni.
“I made it from rushes,” said Rago. “Long-head showed me how to
make it.
“Some day I will show you how to make a basket just like this one.
“Where is baby sister?” asked Rago.
“She is in there,” said Goni, pointing to the shelter.
“The wind is so cold that the children are in there.”
Rago walked over toward Long-head. He was talking to the men in a
very excited way.
Rago knew he was telling them of his narrow escape from the wolf.
The men were listening and asking questions.
“You must be more careful in the future, Long-head,” they said.
“You are a brave boy, Rago,” said Strong-arm. “We are glad you have
come to live with us.”
This pleased Rago very much.
“Let us play it,” said the men.
So they pretended that one man was the fierce wolf, and another
played that he was Rago.
Then the man who played that he was Rago rushed upon the wolf,
waving his torch in his eyes.
The Tree-dwellers were very much interested.
“Now let us play it,” said one of the older boys.
So the boys had their hunting dance. They were glad to play what
the men had played.
After the hunting dance the men told about the animals which they
had seen that day.
They pretended that they were animals and showed just how the
animals acted.
Strong-arm held up the skin of a gopher which he had killed.
He told how the gophers lived among the tall grass, and how quick
one had to be to catch them.
Strong-arm showed the other Tree-dwellers how he had caught this
gopher.
Another man told how he had chased a cave bear back to its den
with his torch. He showed just how he had done this.
“Indeed, the fire is our friend,” he said, “for I could not have
frightened the cave bear without a torch.”
Rago listened while the man talked. He was anxious to learn, so he
could be brave.
One by one the men became drowsy and stretched themselves on
the ground near the fire.
“Where will you and Goni sleep tonight?” asked Rago of his mother.
“You need not be afraid to sleep on the ground. The fire will protect
you.”
“We shall sleep on the ground,” answered his mother. “Goni is not
afraid now.”
“Yes,” said Goni. “I shall sleep on the ground.”
One of the women took her place by the fire. She would watch all
night while the others slept.
Soon all was very quiet. The Tree-dwellers were fast asleep.
Only the sounds of the wild beasts could be heard as they hunted
their prey.
The Tree-dwellers were safe, because the fire would protect them.

TRANSCRIBER’S NOTE:
Obvious typographical errors have been corrected.
*** END OF THE PROJECT GUTENBERG EBOOK RAGO AND GONI,
THE TREE-DWELLER CHILDREN ***

Updated editions will replace the previous one—the old editions will
be renamed.

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


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

START: FULL LICENSE


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

To protect the Project Gutenberg™ mission of promoting the free


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

Section 1. General Terms of Use and


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

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


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information

You might also like