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

Learn Programming with C: An Easy Step-by-Step Self-Practice Book for Learning C 1st Edition Imran download

Learn Programming with C is a comprehensive guide authored by experienced professors, aimed at novice C programmers, particularly students. The book includes detailed explanations, illustrations, and exercises to facilitate learning C programming across various platforms. It covers essential topics such as flow control, functions, file management, and graphics, making it suitable for both classroom and self-study.

Uploaded by

seymawreede
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)
7 views

Learn Programming with C: An Easy Step-by-Step Self-Practice Book for Learning C 1st Edition Imran download

Learn Programming with C is a comprehensive guide authored by experienced professors, aimed at novice C programmers, particularly students. The book includes detailed explanations, illustrations, and exercises to facilitate learning C programming across various platforms. It covers essential topics such as flow control, functions, file management, and graphics, making it suitable for both classroom and self-study.

Uploaded by

seymawreede
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/ 53

Learn Programming with C: An Easy Step-by-Step

Self-Practice Book for Learning C 1st Edition


Imran pdf download

https://ebookmass.com/product/learn-programming-with-c-an-easy-
step-by-step-self-practice-book-for-learning-c-1st-edition-imran/

Explore and download more ebooks at ebookmass.com


Here are some recommended products for you. Click the link to
download, or explore more at ebookmass.com

Microsoft Visual C# Step by Step, 9th Edition John Sharp

https://ebookmass.com/product/microsoft-visual-c-step-by-step-9th-
edition-john-sharp/

Microsoft Visual C# Step by Step 10th Edition John Sharp

https://ebookmass.com/product/microsoft-visual-c-step-by-step-10th-
edition-john-sharp/

Python Programming for Beginners: 2 Books in 1 - the


Ultimate Step-By-Step Guide to Learn Python Programming
Quickly With Practical Exercises Mark Reed
https://ebookmass.com/product/python-programming-for-
beginners-2-books-in-1-the-ultimate-step-by-step-guide-to-learn-
python-programming-quickly-with-practical-exercises-mark-reed/

Easy Algebra Step-by-Step, Third Edition Sandra Luna


Mccune

https://ebookmass.com/product/easy-algebra-step-by-step-third-edition-
sandra-luna-mccune/
McGraw-Hill's easy English step-by-step for ESL Learners.
Student Book. 2nd Edition Danielle Pelletier

https://ebookmass.com/product/mcgraw-hills-easy-english-step-by-step-
for-esl-learners-student-book-2nd-edition-danielle-pelletier/

Learn Data Mining Through Excel: A Step-by-Step Approach


for Understanding Machine Learning Methods, 2nd Edition
Hong Zhou
https://ebookmass.com/product/learn-data-mining-through-excel-a-step-
by-step-approach-for-understanding-machine-learning-methods-2nd-
edition-hong-zhou/

Python Programming: 3 Books in 1: Ultimate Beginneru2019s,


Intermediate & Advanced Guide to Learn Python Step-by-Step

https://ebookmass.com/product/python-programming-3-books-
in-1-ultimate-beginners-intermediate-advanced-guide-to-learn-python-
step-by-step/

Game Theory: An Introduction with Step-by-Step Examples


Ana Espinola-Arredondo

https://ebookmass.com/product/game-theory-an-introduction-with-step-
by-step-examples-ana-espinola-arredondo/

Microsoft Project 2019 Step by Step (Step by Step


(Microsoft)) Cindy Lewis & Carl Chatfield & Timothy
Johnson [Lewis
https://ebookmass.com/product/microsoft-project-2019-step-by-step-
step-by-step-microsoft-cindy-lewis-carl-chatfield-timothy-johnson-
lewis/
Learn Programming with C

Authored by two standout professors in the feld of Computer Science and Technology
with extensive experience in instructing, Learn Programming with C: An Easy Step-by Step
Self-Practice Book for Learning C is a comprehensive and accessible guide to programming
with one of the most popular languages.
Meticulously illustrated with fgures and examples, this book is a comprehensive
guide to writing, editing, and executing C programs on diferent operating systems and
platforms, as well as how to embed C programs into other applications and how to create
one’s own library. A variety of questions and exercises are included in each chapter to test
the readers’ knowledge.
Written for the novice C programmer, especially undergraduate and graduate students,
this book’s line-by-line explanation of code and succinct writing style makes it an excellent
companion for classroom teaching, learning, and programming labs.

Sazzad M.S. Imran, Ph.D., is Professor in the Department of Electrical and Electronic
Engineering, University of Dhaka, Bangladesh. He completed his B.Sc. and M.S. degrees in
Applied Physics, Electronics & Communication Engineering from the University of Dhaka
and received his Ph.D. degree from the Optical Communication Lab of the Kanazawa
University, Japan. Dr. Imran has vast experience in teaching C/C++, Assembly Language,
MATLAB®, PSpice, AutoCAD, etc., at the university level (more at sazzadmsi.webnode.
com).

Md Atiqur Rahman Ahad, Ph.D., SMIEEE, SMOPTICA, is Associate Professor of


Artifcial Intelligence and Machine Learning at the University of East London, UK; and
Visiting Professor at the Kyushu Institute of Technology, Japan. He worked as Professor at
the University of Dhaka and Specially Appointed Associate Professor at Osaka University.
He has authored/edited 14+ books and published 200+ peer-reviewed papers (more at
http://ahadvisionlab.com).
Learn Programming with C
An Easy Step-by-Step Self-Practice Book
for Learning C

Sazzad M.S. Imran, Ph.D.


Md Atiqur Rahman Ahad, Ph.D.
MATLAB® is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks does not warrant the
accuracy of the text or exercises in this book. This book’s use or discussion of MATLAB® software or related products
does not constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or particular
use of the MATLAB® software.
First edition published 2024
by CRC Press
2385 NW Executive Center Drive, Suite 320, Boca Raton FL 33431
and by CRC Press
4 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN
CRC Press is an imprint of Taylor & Francis Group, LLC
© 2024 Prof. Sazzad M.S. Imran, Ph.D. and Prof. Md Atiqur Rahman Ahad, Ph.D.
Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot
assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers
have attempted to trace the copyright holders of all material reproduced in this publication and apologize to
copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been
acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or
utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including
photocopying, microfilming, and recording, or in any information storage or retrieval system, without written
permission from the publishers.
For permission to photocopy or use material electronically from this work, access www.copyright.com or contact the
Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978–750–8400. For works that
are not available on CCC please contact mpkbookspermissions@tandf.co.uk
Trademark notice: Product or corporate names may be trademarks or registered trademarks and are used only for
identification and explanation without intent to infringe.
Library of Congress Cataloging-in-Publication Data
Names: Imran, Sazzad, author. | Ahad, Md. Atiqur Rahman, author.
Title: Learn programming with C / Prof. Sazzad Imran, Ph.D, and Prof. Md. Atiqur Rahman Ahad, Ph.D.
Description: First edition. | Boca Raton, FL : CRC Press, 2024. | Includes bibliographical references and index. |
Summary: “Authored by two standout professors in the fields of Computer Science and Technology with
extensive experience in instructing, Learn Programming with C is a comprehensive and accessible guide to
programming with one of the most popular languages. Meticulously illustrated with figures and examples, this
book is a comprehensive guide to writing, editing and executing C programs on different operating systems and
platforms, as well as how to embed C programs into other applications and how to create one’s own library.
A variety of questions and exercises are included in each chapter to test the readers’ knowledge Written for the
novice C programmer, especially undergraduate and graduate students, this book’s line-by-line explanation of
code and succinct writing style makes it an excellent companion for classroom teaching, learning and
programming labs”—Provided by publisher.
Identifiers: LCCN 2023033790 (print) | LCCN 2023033791 (ebook) | ISBN 9781032299082 (hbk) |
ISBN 9781032283555 (pbk) | ISBN 9781003302629 (ebk)
Subjects: LCSH: C (Computer program language). | Computer programming.
Classification: LCC QA76.73.C15 I47 2024 (print) | LCC QA76.73.C15 (ebook) | DDC 005.13/3—dc23/eng/20231026
LC record available at https://lccn.loc.gov/2023033790
LC ebook record available at https://lccn.loc.gov/2023033791
ISBN: 9781032299082 (hbk)
ISBN: 9781032283555 (pbk)
ISBN: 9781003302629 (ebk)
DOI: 10.1201/9781003302629
Typeset in Minion
by Apex CoVantage, LLC
Access the Support Material: www.routledge.com/learn-programming-with-c/ahad/p/book/9781032299082
Contents

Preface, xi

CHAPTER 1 ◾ Introduction 1
1.1 HISTORY OF PROGRAMMING LANGUAGE 1
1.2 DIFFERENT TYPES OF PROGRAMMING LANGUAGE 2
1.3 IMPORTANCE OF PROGRAMMING 3
1.4 C PROGRAM STRUCTURE 3
1.5 STEP-BY-STEP TUTORIAL TO RUN A C PROGRAM 5
1.6 KEYWORDS 7
1.7 IDENTIFIERS 7
1.8 OPERATORS 8
1.9 OPERATOR PRECEDENCE IN C 9
1.10 VARIABLES 9
1.11 CONSTANTS 10
1.12 ESCAPE SEQUENCES 10
1.13 DATA TYPES 10
1.14 TYPE CASTING 11
1.15 EXAMPLES 12
EXERCISES 26
– MCQ with Answers 26
– Questions with Short Answers 37
– Problems to Practice 44

CHAPTER 2 ◾ Flow Control 46


2.1 IF STATEMENT 46
2.2 IF..ELSE STATEMENT 47
2.3 NESTED IF..ELSE STATEMENT 47
2.4 CONDITIONAL OPERATOR 48

v
vi ◾ Contents

2.5 FOR LOOP 49


2.6 WHILE LOOP 51
2.7 DO..WHILE LOOP 52
2.8 CONTINUE STATEMENT 53
2.9 BREAK STATEMENT 53
2.10 SWITCH..CASE STATEMENT 54
2.11 GOTO STATEMENT 55
2.12 EXAMPLES 56
EXERCISES 140
– MCQ with Answers 140
– Questions with Short Answers 143
– Problems to Practice 149

CHAPTER 3 ◾ Arrays and Pointers 152


3.1 ARRAYS 152
3.2 2D ARRAYS 153
3.3 MULTIDIMENSIONAL ARRAYS 154
3.4 STRING 155
3.5 STRING FUNCTIONS 155
3.6 POINTERS 156
3.7 MEMORY ALLOCATION 156
3.8 EXAMPLES 157
EXERCISES 205
– MCQ with Answers 205
– Questions with Short Answers 211
– Problems to Practice 214

CHAPTER 4 ◾ Functions 217


4.1 FUNCTION TYPES 217
4.2 FUNCTION STRUCTURE 217
4.3 FUNCTION CALL 218
4.4 ARRAYS AND FUNCTIONS 218
4.5 POINTERS AND FUNCTIONS 218
4.6 STORAGE CLASS 219
4.7 EXAMPLES 219
Contents ◾ vii

EXERCISES 294
– MCQ with Answers 294
– Questions with Short Answers 296
– Problems to Practice 299

CHAPTER 5 ◾ Structure and Union 301


5.1 STRUCTURE 301
5.2 UNION 302
5.3 ENUM 302
5.4 DATA STRUCTURE AND ALGORITHM 303
5.5 LINKED LIST 304
5.6 TYPES OF LINKED LIST 305
5.7 EXAMPLES 306
EXERCISES 426
– MCQ with Answers 426
– Questions with Short Answers 430
– Problems to Practice 433

CHAPTER 6 ◾ File Management 437


6.1 FILE TYPES 437
6.2 FILE OPERATIONS 437
6.3 PREPROCESSORS 439
6.4 CONDITIONAL COMPILATION 439
6.5 EXAMPLES 440
EXERCISES 472
– MCQ with Answers 472
– Questions with Short Answers 474
– Problems to Practice 475

CHAPTER 7 ◾ C Graphics 477


7.1 INTRODUCTION 477
7.2 FUNCTION 477
7.3 COLOR TABLE 478
7.4 FONTS OF TEXT 479
7.5 FILL PATTERNS 479
7.6 INCLUDING GRAPHICS.H IN CODEBLOCKS 480
viii ◾ Contents

7.7 EXAMPLES 480


Problems to Practice 513

CHAPTER 8 ◾ C Cross-platform 515


8.1 CREATING OWN LIBRARY 515
8.1.1 Creating Static Library 515
8.1.2 Creating Dynamic Library 519
8.2 TURBO C 522
8.3 VISUAL STUDIO CODE 525
8.4 VISUAL STUDIO 529
8.5 COMMAND LINE 531
8.6 COMMAND LINE ARGUMENTS 534
8.7 LINUX 537
8.8 EMBEDDING C CODE INTO MATLAB 539
Using MinGW-W64 Compiler 539
Using S-Function Builder 541
Using C Function Block 545
Using C Caller Block 549
8.9 INTEGRATING C CODE INTO PYTHON 552
8.10 SWITCHING FROM ONE LANGUAGE TO ANOTHER 555
8.11 TRANSITION TO C++ OR C# FROM C 557

CHAPTER 9 ◾ C Projects 558


PROJECT-1 558
PROJECT-2 558
PROJECT-3 558
PROJECT-4 558
PROJECT-5 559
PROJECT-6 559
PROJECT-7 559
PROJECT-8 559
PROJECT-9 559
PROJECT-10 559
PROJECT-10 560
PROJECT-11 560
PROJECT-12 560
Contents ◾ ix

PROJECT-13 560
PROJECT-14 560
PROJECT-15 560
PROJECT-16 560
PROJECT-17 560
PROJECT-18 561
PROJECT-19 561
PROJECT-20 561
PROJECT-21 561
PROJECT-22 561
INDEX, 563
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Preface

C is a programming language with which every sofware developer should become


familiar. Tough numerous books are available on C programming language, most
of the example programs are written without algorithms or any fowchart in those books.
As a result, it becomes difcult for a student to comprehend the core of a programming
language through a self-learning approach. Our experience in teaching C underscores the
importance of presenting C programs by the fowchart solution frst, then the pseudocode
solution, and fnally the actual C code with the line-by-line explanation.
It is written for C programming language courses/modules at the undergraduate and
graduate levels – mostly for beginners. However, if one has prior knowledge on program-
ming, one may skip the initial couple of chapters. By going through this book, any student
or a beginner can learn and understand C programming by taking only a little or no help
from an instructor. For the instructors, this book is an easy guidance. Only going through
this book will be sufcient for them to teach C programming – as theory lectures and prac-
tical lab. We avoid a broad or overly verbose presentation or information overload, and the
book presents a concise and defnitive perspective to C.
Tis book is written as a self-practice book for learning programming by going through
all the detailed problem solutions and working through the pseudocode, fowchart, and
the actual code. In addition, readers can observe a clearer correlation between the indi-
vidual steps in the pseudocode and the fowchart itself for a better understanding of the
program fow.
One of the specialties of this book is that we introduce a new chapter that illustrates
on writing and running C codes under various operating systems and platforms. How to
embed C codes into other applications is also presented. Each chapter incorporates a num-
ber of relevant inquisitive questions and their corresponding answers. A variety of good
exercises are also available in the textbook. Another original incorporation of this book
is the last chapter, where a number of large projects are presented for students to explore
comprehensiveness in the C programming language.
Source codes for all programs in this book will be available for those who will purchase
the book. Tough we worked hard to ensure the perfection of this book, it may have issues
that require amendments. Terefore, please feel free to share at sazzadmsi@du.ac.bd and
mahad@uel.ac.uk.

xi
xii ◾ Preface

In conclusion, this book is a guided self-study for those interested in learning C by fol-
lowing a detailed, tutorial-type problem-solving book. We feel that it is a great book for
teachers to cover as a textbook for C programming language.

Prof. Sazzad M.S. Imran, Ph.D.


Prof. Md Atiqur Rahman Ahad, Ph.D.

MATLAB® is a registered trademark of Te Math Works, Inc. For product information,


please contact:
Te Math Works, Inc.
3 Apple Hill Drive
Natick, MA 01760-2098
Tel: 508-647-7000
Fax: 508-647-7001
E-mail: info@mathworks.com
Web: http://www.mathworks.com
CHAPTER 1

Introduction

C is a machine-independent, efficient, easy-to-use structured programming lan-


guage used to create various applications, operating systems, and sophisticated pro-
grams. C is widely recognized as the foundation of programming language, implying that
anyone who understands C can quickly acquire or grasp other structured programming
languages. Dennis Ritchie, a computer scientist at the Bell Laboratories in the United
States, designed the C programming language in 1972.

1.1 HISTORY OF PROGRAMMING LANGUAGE


Ada Lovelace created the first programming language in 1843 for an early computing sys-
tem. She created the first machine algorithm for the Difference Machine of Charles Babbage.
However, Konrad Zuse created the first proper programming language, Plankalkul, often
known as plan calculus, sometime between 1944 and 1945. After that, in 1947, Kathleen
Booth devised assembly language, a low-level programming language that simplified
machine coding. John McCauley proposed the first high-level language, Shortcode or
Short-order-code, in 1949. Alick Glennie created the first compiled language, Autocode,
for the Mark 1 computer in 1952.
John Backus invented FORmula TRANslation, or FORTRAN, in 1957. It was designed
for complex scientific, mathematical, and statistical calculations and is still used today.
A group of American and European computer scientists collaborated to create ALGOL,
or algorithmic language, in 1958. In the same year, John McCarthy of MIT proposed the
LISP (list processing) programming language for artificial intelligence. Dr. Grace Murray
Hopper oversaw the development of COBOL (Common Business Oriented Language) in
1959, which was created for credit card processors, ATMs, telephone and mobile phone
calls, hospital signals, traffic signal systems, and banking systems.
Beginners All-purpose Symbolic Instruction Code, or BASIC, was created in 1964 by
Dartmouth College students and later improved by Microsoft founders Bill Gates and Paul
Allen. The PASCAL was created in 1970 by Niklaus Wirth in honor of French mathemati-
cian Blaise Pascal. It was the first choice of Apple because of its simplicity of use and power.
Alan Kay, Adele Goldberg, and Dan Ingalls of the Xerox Palo Alto Research Centre created

DOI: 10.1201/9781003302629-1 1
2 ◾ Learn Programming with C

Smalltalk in 1972. Leafy, Logitech, and CrowdStrike were among the companies that used
it. In the same year, Dennis Ritchie created C for use with the Unix operating system at Bell
Telephone Laboratories. C is the basis for several modern languages, including C#, Java,
JavaScript, Perl, PHP, and Python. In 1972, IBM researchers Raymond Boyce and Donald
Chamberlain created SQL, which stood for Structured Query Language. It is a program
that lets you explore and edit data stored in databases.
Afer mathematician Ada Lovelace, Ada was created in 1980–1981 by a team directed
by Jean Ichbiah of CUU Honeywell Bull. Ada is an organized, statically typed, imperative,
wide-spectrum, and object-oriented high-level programming language used for air trafc
control systems. Bjarne Stroustrup created C++ afer modifying the C language at Bell
Labs in 1983. C++ is a high-performance programming language used in Microsof Ofce,
Adobe Photoshop, game engines, and other high-performance sofware. Brad Cox and
Tom Love created the Objective-C programming language in 1983 to construct sofware
for macOS and iOS. Larry Wall designed Perl in 1987 as a general-purpose, high-level pro-
gramming language for text editing.
Haskell, a general-purpose programming language, was created in 1990 to deal with
complex calculations, records, and number crunching. Guido Van Rossum created the
general-purpose, high-level programming language Python in 1991, and it is used by
Google, Yahoo, and Spotify. Visual Basic is a programming language created by Microsof
in 1991 that allows programmers to use a graphical user interface and is used in vari-
ous applications such as Word, Excel, and Access. Yukihiro Matsumoto designed Ruby
in 1993 as an interpreted high-level language for web application development. James
Gosling designed Java in 1995 as a general-purpose, high-level programming language
with cross-platform capabilities. Rasmus Lerdorf created the hypertext preprocessor PHP
in 1995 to create and maintain dynamic web pages and server-side applications. Brendan
Eich wrote JavaScript in 1995 for desktop widgets, dynamic web development, and PDF
documents.
Microsof created C# in 2000 by combining the computing power of C++ with the sim-
plicity of Visual Basic. Almost every Microsof product currently uses C#. In 2003, Martin
Odersky created Scala, which combines functional mathematical and object-oriented pro-
gramming. Scala is a Java-compatible programming language that is useful in Android
development. In 2003, James Strachan and Bob McWhirter created Groovy, a concise and
easy-to-learn language derived from Java. Google created Go in 2009, and it has since
gained popularity among Uber, Twitch, and Dropbox. Apple created Swif in 2014 to
replace C, C++, and Objective-C for desktop, mobile, and cloud applications.

1.2 DIFFERENT TYPES OF PROGRAMMING LANGUAGE


To communicate with computers, programmers utilize a programming language. Tere
are three broad categories of computer languages:

(a) Machine language


Referred to as machine code or object code, a set of binary digits 0 and 1. Easily
understandable by computer systems but not by users.
Introduction ◾ 3

(b) Assembly language


Considered a low-level language and used to implement the symbolic representa-
tion of machine codes.
(c) High-level language
Easy to understand and code by users. Not understandable by computer systems,
hence needs to be transformed into machine code. Diferent types of high-level
languages are as follows:
(i) Algorithmic languages – FORTRAN, ALGOL, C
(ii) Business-oriented languages – COBOL, SQL
(iii) Education-oriented languages – BASIC, Pascal, Logo, Hypertalk
(iv) Object-oriented languages – C++, C#, Ada, Java, Visual Basic, Python
(v) Declarative languages – PROLOG, LISP
(vi) Scripting languages – Perl
(vii) Document formatting languages – TeX, PostScript, SGML
(viii) World Wide Web display languages – HTML, XML
(ix) Web scripting languages – JavaScript, VB Script

1.3 IMPORTANCE OF PROGRAMMING


In recent years, programming has become the most in-demand skill. From smart TVs to
kitchen appliances, technological disruption is evident practically everywhere. As a result,
many new employments are created, and a large number of current jobs are redefned.
Programming skills provide a competitive advantage in a variety of career felds. As a
result, it is undoubtedly one of the most crucial talents to learn for both present and future
generations.
Programming helps us think more logically and analytically. Students who learn pro-
gramming languages at an early age will have many career options in the future. It is no
longer a choice to learn but rather a necessary talent to master. Apart from sofware and
application development, business analysts, graphic artists, and data scientists are among
the occupations that require programming knowledge.

1.4 C PROGRAM STRUCTURE


Te source code of any C program is written according to the syntax of the computer lan-
guage. Te source code for a C program can be written in any text editor and then saved
with the .c extension, for example, flename.c. Any alpha-numeric character, including
underscores, can be used in the fle name, except we cannot use any keyword as a fle name.
Afer then, any standard C compiler, such as Turbo C or CodeBlocks, is used to compile
and run the source code fle. Let us get started with the frst C program.
4 ◾ Learn Programming with C

Input and Output:

Explanation of the program:


Comment: Any comment in a C program begins with ‘/*’ and ends with ‘*/’. // can also
be used to make a single-line comment. Tough it is not required to write comments, it is a
good practice to do so in order to improve the readability of the program. Tere can be any
number of comments placed anywhere in the program, as the comments are not executed.
include: Many keywords and library functions, such as printf() and scanf(), may be required
in any C program. stdio.h, conio.h, and other header fles contain prototypes or declarations of
the library functions that must be included in the program. Te header fle stdio.h is included
in this program. It provides declarations for the functions printf() that displays data on the
standard output terminal and scanf() that reads data from the standard input terminal.
Display: Te built-in library function printf() displays anything written inside double
quotation marks on the output console. Te values of the variables can also be displayed
using the format specifers.
User input: Te C library function scanf() takes input from the input terminal. Following
the program’s execution, the input console awaits input, and once the age is entered, the
remaining statements are executed based on the age input.
main() function: Te main() function is used to start executing any C program source
code; hence, every C program must have one. Te main() function has the following struc-
ture. Te function name is followed by the return type, which can be either int or void.
Te return type is required for the compiler to determine if the program was successfully
compiled or not. We return 0 at the end of the main() function as 0 is the standard for
the “successful execution of the program”. Also, the ANSI standard does not allow using
void main(); therefore, it is preferred to use ‘int main()’ over ‘void main()’. If there are any
Introduction ◾ 5

arguments or parameters afer the function name, they are enclosed in parentheses; other-
wise, they are lef empty. Te body of the main() function is comprised of all the statements
between the opening and closing curly braces.

1.5 STEP-BY-STEP TUTORIAL TO RUN A C PROGRAM


We use Code::Blocks for windows OS to run all the programs available in this book. It is
a free, open-source, cross-platform C IDE built to meet the most demanding needs of its
users. How to run the programs using other compilers, platforms, or operating systems is
available in Chapter 8.
A step-by-step tutorial to run any C program using Code::Blocks is given below.

Step-1: Visit www.codeblocks.org/downloads/binaries/; download, and install code-


blocks-20.03mingw-32bit-setup.exe. We prefer 32-bit with mingw package as
that version is compatible with graphics.h header fle necessary for C graphics
programs.

Step-2: Open Code::Blocks and click on File→New→Project . . ., select ‘Empty project’


and click on Go and then Next>.

Write C-Program (or any name of your choice) on the ‘Project title:’ and choose the
folder (for example, C:\Users\SazzadImran\Desktop\) where you want to create the
project. Click Next>→Finish. A project or folder is created on the desktop.
6 ◾ Learn Programming with C

Step-3: Double click on C-Program on Workspace to select the project and click
File→New→Empty fle→Yes. Write a fle name of your choice (Example-1, for example)
and click Save.

Check Debug and Release and then press OK.

An empty fle name Example-1.c is created and saved in the C-Program folder.
Step-4: Write your C program codes on the fle Example-1.c and save the fle.
Introduction ◾ 7

Step-5: Click Build→‘Compile current fle’ to compile the program. Correct any error(s)
or warning(s) on the codes. Correcting the errors is a must though it is optional to
correct the warnings. Recompile the program until we get 0 error(s) and 0 warning(s).

Step-6: Click Build→‘Build and run’ to execute the program. Te output screen will look
as follows:

1.6 KEYWORDS
In C programming, 32 reserved words have special meaning to compilers and are utilized
as a part of the syntax. Tese terms cannot be used as names or identifers for variables. Te
list of reserved C keywords is as follows:
auto, break, case, char, const, continue, default, do, int, long, register, return, short,
signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while, double,
else, enum, extern, foat, for, goto, if.

1.7 IDENTIFIERS
Variables, functions, structures, and other objects in a program are given unique names
called identifers. For example, in the statement of the preceding demo program

int age;

int is a keyword and age is an identifer assigned to a variable by the compiler to iden-
tify the entity uniquely. When naming an identifer, the following guidelines should be
observed.

(1) A valid identifer can include uppercase and lowercase letters, numbers, and
underscores.
(2) Te frst character cannot be a digit.
(3) We cannot use any keyword as an identifer.
(4) Te length of the identifer is unlimited.

It is a good practice to give the identifer a meaningful name.


Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Exploring the Variety of Random
Documents with Different Content
Han vanished, and the outlaw sat himself down in speechless
wonderment. Presently You Han returned and announced that the
magistrate would be inexpressibly honored to receive the Personage
in the evening, and the reason for not inviting him to dine was that
he knew the guest would prefer his food prepared after his own
strange fashion by his own servant. As in a gorgeous dream the
deserter dined, with three attendants squabbling with You Han for
the honor of passing each dish. Then he brushed his dusty leggings
and blue clothes and summoned a barber.
A little later the guest was greeted as a person of rare distinction by
the dignified elderly gentleman in red-silk robes who ruled and
"squeezed" the district. The corporal rose grandly to the occasion.
The two mingled to a nicety their mutual attitudes of respect,
cordiality, protection. They talked laboriously through the doubtful
medium of the overpowered You Han, whom the intricacies of the
mandarin dialect bowled over from the one side, and on the other
such instructions as these from the corporal:
"Tell old Four-Eyes that I'm the personal ripresintative of George
Washington and Gineral Grant, an' that when I stamp me fut a
million brave soldiers trimble violently; but that because I know a
great intelleck when I see one, me heart is swelled with pride to sit
down and talk it over as man to man. Poke that into him good and
har-r-d."
The official volleyed many questions, and the deserter parried what
fragments of them You Han was able to pass along. A military escort
to the next village was offered, but the guest declined with polite
emphasis. He was not seeking ostentation in public. When he went
to his apartments after a surfeit of cakes, wine, and tobacco,
Corporal John Sweeney rubbed his close-cropped head and puzzled
over his identity. As he curled up on the warm brick kang, he was a
deserter fast becoming reconciled to his fate.
"It strains the rivets of me imagination to believe it's rale. I hope
there's more miracles in stock where this one was projuced," he
murmured sleepily.
Just at dawn he awoke. There was a clatter of voices in the
courtyard, and the sound of horses moving hurriedly. Presently the
paper of the latticed wall was ripped, and a brown finger popped
through. All the fears of the refugee came trooping back with
squadrons reinforced. He ripped the door open, rifle in hand. A
string of traders' ponies was filing out for an early start toward
Peking, and a hostler stood with his face pressed against the hole in
the wall, trying to catch a glimpse of the lordly foreigner. That was
all. But the deserter saw again the smoky room in the "Chinese City,"
and heard the Sixth Cavalry squad wheel just in rear of his frantic
flight. The "illustrious guest" was again the fugitive, escaping, he
knew not whither, from "five years—five years at least."
He kicked the sleeping You Han into action, and the cart was under
way as soon as the mule had fed.
"Only thirty miles from Peking," growled the corporal; "not half far
enough. An' cavalry is prancin' out to loot, pacify, an' scatter
Christian blessings with th' mailed fisht where they have no business
to be thinkin' of. I hike till I drop, an' that's me ultimatum."
They pressed on all day until the dun mule swayed in the shafts and
the pilgrims were ready to drop by the roadside. The night was
passed in a village tavern, for You Han was too weary to organize a
reception. The deserter slept fitfully, and awoke often talking to
himself. Nervous and foot-sore, he took the trail at dawn of the third
day, You Han watchful and worried. As the deserter turned
frequently to look behind him, the aspect of the future crushed him,
while the imminent past lashed him to persistent flight. Camp, and
the close comradeship of men in blue and khaki; the routine round
of his army years; the Chicago streets that had known his boyhood;
the father and mother who were proud of his record—these and all
other links in the chain of his thirty years were as if they had never
been forged. Names, faces and scenes of which he had been an
intimate part were in an obliterating distance, and nothing that had
gone before was given strength to follow him, except the incidents
of his escape, and these filled all the landscape with portents.
Soon they came to a schoolhouse in the middle of a tiny hamlet. You
Han knew it for such when the refugees were rods away, since from
the squat building came an incessant sound like the hum of a
gigantic top. The children were reciting their daily task from the
Confucian Analects at the limit of their lung power, when the
foreigner was spied by a truant outpost, and the teacher could not
hold the clamorous flock in leash. By scores they tumbled out to
scamper off in terror until You Han shouted his message of good will
and the corporal laughed, threw down his rifle, and became one of
them. It was not long before uproarious applause greeted his
attempts to play jackstones and strike the sharpened stick to make it
fly into the miniature mud-pie "city."
Again the feeling of homeliness tugged at his heart, and he lingered
among the children until the teacher gathered them in, with labor
like that of collecting spilled quicksilver.
You Han swaggered into the next village beyond, with a port inspired
by remembrance of the magistrate's yamen, but he came to grief at
the hands of the village bully. There was no mistaking the character
of this truculent ruffian. His garments were studiously awry, and his
queue was loosely braided and coiled around his neck to show that
he thirsted for combat. He resented the lofty bearing of the stranger,
and the two clashed with disaster to the features of You Han, who
was plucky but overmatched. He was rescued by the corporal, who
gave the bully the worst beating of his career. The feat was
applauded by a throng of villagers whose peace had been much
disturbed by this chronic nuisance, and they feasted the hero at the
house of the head man with complex and effusive hospitality. The
wayfarers were pressed to stay and make the town their home for
life.
This incident, coming in a sequence of revelations of the life of this
hitherto despised people, set the thoughts of the deserter definitely
into a new and hopeful channel.
"I begin to think," he said to You Han, "that I could stick it out in
one of these back counties, at worst until the troops are l'avin' China
in the spring. An' I could come pretty near to runnin' a town or two
meself. One more day's march an' I'll risk stakin' out a claim for a
while. An' I'll be a leadin' an' dignified citizen, an' grandfather by
brevet to all the kids in the camp."
The advance was checked by the discovery that the cart axle had
split and must be repaired to prevent a breakdown over the next bit
of rough going. The corporal was in a bluster of impatience to press
forward. Delay had not lost its power to frighten him. The next
village lay ten miles beyond, but between was a desolate stretch of
waste land in which no one lived, in which nothing grew. From the
tiled roof of the tavern the corporal could see this little desert rolling
like a lake almost from the village walls to the sky line. It caught his
fancy with a huge onset of relief. Once beyond this barrier, he would
feel secure against discovery, and he magnified it as the borderland
of safety. You Han was surrounded by a group of voluble citizens
who urged waiting two days until a new axle could be hewn from
the solid tree; but the deserter exploded the conference by
shouting:
"Dump the carrt here. Pack the mule, an' we'll send back for the
Noah's ark when we get settled over beyant. Make haste an'
upholster the mule with the baggage of light marchin' order."
When the dun mule, in tow of the boy, limped out of the gateway
across the crumbling moat, its small hoofs sank to the fetlock in
white sand, and the trail of cart-wheels winding across the plain
shimmered in an aching dazzle of sunlight. At the end of an hour the
village behind them was a brown smudge not more than two miles
distant. The deserter made peevish comments, but there was
cheerfulness in the crack of his profanity, as he plodded painfully
ahead of the boy and the mule. Whenever they paused to rest he
talked to You Han, not caring whether the boy understood one word
in five. The two seemed alone in all the world; their calamitous
fortunes were more closely knit than at any time in the flight; and
hope lay somewhere beyond this barricade provided by a fate grown
strangely kind.
"You'll have the next week to get the sand out o' thim foolish shoes
o' yourn," observed the corporal. "An' me blisters will be attinded to
by the chief surgeon of the county. Like chickens an' silk over-coats,
my son? We're goin' hell-bent for the comforts of life by the carrt-
load."
You Han talked to the mule in encouraging whistles and replied,
"Can do," to the monologue of the corporal, who rambled on:
"Say, thim kids did me more good than a barrel o' monkeys. Weren't
they corkers? By the holy poker! I'm goin' to marry you off to a little
squeeze-toed fairy in the big town over the way, an' you'll live
without worrkin' forevermore. Maybe the old man will follow suit. It's
me life ambition to be idle an' palatial. An' You Han will be the
hottest sport in fifty li. Dinghowdy? All right?"
In the third hour they were not more than halfway across, and the
short winter afternoon was reddening. The level desolation had
begun to tumble up into crowding little hills and sand barriers among
which the trail now and then entangled itself. But the air was crystal
and windless, and scrambling to the top of one of the white hills, the
corporal could see the faintest tracery of a towered temple on the
farther side of the desert as a guiding landmark. It was a forced
march, and a halt was made only for a fragment of supper and a
swig for man and mule from the water-bottle on the pack. The moon
rose in the sleeping dusk, but before it was clear of the scalloping
ridges of sand the sky became spattered with rags of flying cloud.
Presently the wind behind the angry scud began to pick up gusts of
sand and flirt them from one crest to another. The travelers rubbed
their eyes and coughed as they plowed steadily westward, steering a
course by the cart-trail, still discernible, and by the moon behind
them. "We're more 'n halfway over," shouted the corporal, "an' it's
silly to be dr'amin' of losin' ourselves in this two-by-four desert."
Then the gray sky closed down in blackness everywhere, and leaping
billows of sand seemed to meet it. The rush of the terrific wind
wiped out the trail as if it had been no more than a finger-mark.
There were no more hills nor winding passages among them, only a
fog of whirling sand. The wind had an icy edge as it brought the
killing cold of Mongolian steppes a thousand miles away. The
deserter and the boy covered their faces with their hands, their
garments; and almost instantly they were adrift, cowering, lost,
helpless. So dense was the driving smother of sand that they could
scarcely see the mule straining at the end of its halter-rope. The
hillocks were shifting with a complaining roar, and the shriek of the
wind in mid-air was pierced with a shrill rasp like the commotion of
innumerable iron filings.
The corporal and You Han groped toward the side of a hillock,
seeking a lee; but the flooding sand tumbled down its side knee-
deep, and the wind sucked round and searched them out, as if in
chase. The flinty particles pelted in sheets, and bit their faces like
incessant volleys of fine shot. There was no more time to think of
what should be done than when a swimmer is plunged over a dam.
It did not seem possible that the danger of death was menacing in
this absurdly small theater of action, yet it could not have been
many moments before the deserter began to realize where lay the
odds in another hour's exposure to such a storm. All sense of
direction had been snatched from him, and he fought only for
breath. You Han had no knowledge of desert storms in his home on
the bank of the Pei-ho. He gasped whatever prayers came to him,
but placed his active faith, still unshaken, in the ability of his master
to save him from the choking, freezing terror. The man and the boy
were not only stifled, but soon benumbed, for neither had ever felt
anything to compare with the searching cold of this blast. They
stumbled from one hill to another, sometimes keeping their feet,
falling oftener, rising more slowly, the little mule trying in vain to turn
tail to the storm.
There could be no conversation. At length the deserter muttered
drowsily to the storm such fragments as these:
"No place like home. It's the finish that's comin' to me. Cudn't take
me medicine like a man. P'rhaps this'll blow over soon. I'm blinded
entirely. Good God! forgive me poor cowardly sowl! I niver meant to
go wrong. Had to bring that poor fool You Han into this mess."
The deserter pitched forward on hands and knees, his rifle buried
somewhere in his circling wake. He caught hold of You Han's queue
lest they lose each other, and then the mule pushed impetuously
between them, ears forward, muzzle outstretched, trumpeting
joyfully.
"He b'lieve can find. He sabee plenty," feebly sputtered You Han.
The frantic mule dragged the boy by the lead-rope a few paces, the
corporal falling, sliding after, and then stopped. The linked
procession could go no farther. You Han collapsed in a little heap,
and the corporal toppled face down. The boy had tied the lead-rope
around his own wrist, and the impatient mule was jerking it so that
the forlorn figure in the sand seemed to make appealing gestures.
The corporal was without motion, and with a mighty effort You Han
pulled himself a little nearer, and the mule followed protestingly. The
swaying curtain of sand closed in around the three figures.
You Han struggled to his knees and with his teeth loosed the knotted
cinch, and the pack fell from the mule. The boy writhed over on the
corporal and tried to raise the dead weight, tried to talk to him in a
wordless and appealing whimper. The deserter strove to rise, and
failed until he dully comprehended that the boy sought to make him
mount the mule, or at least to hitch him in tow with the lead-rope.
Then the soldier awoke, and fighting off the death that had almost
mastered him, lurched to one knee and pushed You Han toward the
mule that was standing over them. His voice thick and rasping as if
his tongue were of sandpaper, the deserter succeeded in saying:
"Get aboard that mule. No Chinese village in mine. Better man than
me—you an' mule both better men. You won't? —— —— you, take
that!"
The deserter swung his fist against the jaw of the struggling boy,
and the blow went home with the last flicker of the old-time fighting
strength of Corporal Sweeney. You Han dropped limp, as if shot.
Then the fugitive from army justice braced himself, tried, and failed
to lift the light body in his arms. Three times he tried and failed, and
then, as the mule swerved, he fell against it and dropped the lad
across its back, like a bundle of quilts. The cinch, trailing in the sand,
tripped the man, and he slipped it over You Han and pulled it tight
before he fell back in the tossing sand. The mule stumbled a step or
two with its burden, found that it was free and in a moment tottered
beyond the vision of the deserter.
Not more than a hundred yards away a camel-trail lay encamped
against the storm, and to the Mongolian drivers, huddled in furs
close to their beasts, came a little dun mule half dragging an
unconscious Chinese youth, whom they took for dead as they
wonderingly cut him loose from his lashing.
Daylight and the tail of the sand-storm had come before he was able
to speak, and the camels were jostling into the line of march. The
swarthy drivers scoffed at the story told by the raving stranger, until
the bell-camel shied at something nearly buried in the sand. You Han
fought the greedy northerners off until he had disclosed a figure in
army blue and a clean-cut Irish face whose expression was vastly
peaceful.
The last silver coin was gone from the knotted sash of You Han after
he had persuaded the camel-men to carry the body to the village
where Corporal Sweeney had expected to find a refuge from fear.
THE LAST PILOT SCHOONER
Young James Arbuthnot Wilson slipped into the Standard building
with an uneasy air as if he were vaguely on the defensive. Six
months of work in the "City Department" had not rid him of the
feeling of a cat in a strange garret. The veterans of the staff were
rather pleased that this should be the attitude common among
young reporters. It showed that the office machine was geared to
high tension when every man, short of five years' service, was
thankful to find his "job" had not slid from under him between two
days.
Wilson could recall no specific warnings that his head was in peril.
His activities had been too inconspicuous to merit the dignity of
official notice of any kind. He had faithfully followed his foot-sore
round of minor police courts, hospitals, one-alarm fires, and dreary
public meetings, to have his copy jammed as scanty paragraphs
under the head of "City Jottings." A "story" filling a third of a column
had marked his one red-letter day on the Standard.
Each afternoon, at one o'clock, he hurried to his pigeon-hole in the
row of letter-boxes by the city editor's door, his heart thumping to
this sense of intangible fear, and with it pulsing the foolish hope of a
"big assignment." Some day they must give him a chance, and he
would show them whether or not he could handle something worth
while. But the flame of hope was low on this dull day of June as
Wilson unlocked his box and tore open the yellow envelope on which
his name was scrawled.
He whistled in blank amazement as he followed an unfamiliar hand
down to the managing editor's signature. The youngster's face
flushed and his fingers twittered as he turned sharply to see if the
loungers at their desks had noted his agitation. Then he stole into
the hall and re-read, with his lips moving as if he were spelling out
the words:

Dear Mr. Wilson: You have been pegging away without any
let-up for three months and your work has been excellent.
Here is an easy assignment as a reward of merit. It will
give you a pleasant outing, and us a good page story for
the Sunday sheet. The enclosed clipping from to-day's
paper will give you the idea. The art department will have a
snap-shot camera waiting for you. Our Ship-News man
made arrangements this morning for you to be met and
taken aboard. The one-forty train from Broad Street Station
will take you through to Lewes and the Breakwater. To save
time I enclose some expense money. Try to be back on
Thursday. This will give you three days at sea. We want
plenty of rattling description and human interest, with local
color ad lib. Good luck.

"Oh, there must be some mistake," gasped young Wilson. "A page
Sunday story? A whole page? My work has been excellent? The
managing editor has been following it? Why, I didn't suppose he
knew me by sight. I can't believe it."
Befogged with hopes and fears, he turned back to the door of the
city editor's room.
"He's just gone out to lunch with the managing editor," volunteered
the day assistant. "No, I don't know where they went. Said they'd be
back about two-thirty."
Wilson looked at the office clock. If he would catch the one-forty
train for Lewes there was no leeway for hesitation. He started
toward the elevator, then halted to read the clipping, which might
throw some light upon this staggering manifesto:

THE LAST PILOT SCHOONER


The new steam pilot-boat will go into commission off the
Delaware Capes early next week. This change from sail to
steam is another blow at the romance of blue water. Six of
the eight trim schooners of the Delaware fleet have already
been dismantled, not only the Albatross, Number One is
cruising on the station. She will be laid up as soon as the
steamer is ready to put the pilots aboard incoming vessels.
Every ocean voyager will regret the passing of the pilot
schooner. These stormy petrels among sailing craft have
been the first messengers from the looked-for land, as
specks in the tumbling waste of sea, or lying hove to in all
weathers....

Wilson threw his doubts overboard. All he had ever read of bellying
canvas, whipping spars, and lee rails awash leaped into the
foreground of his boyish imagination. Here was his chance for such a
"descriptive story" as he had dreamed of through weeks and
months, this last cruise of the last pilot schooner. He dashed into the
art room, snatched up the waiting camera, and bolted for the
station. After he dropped panting into a seat of the accommodation
train for Lewes, he found himself already overhauling his stock of
sea-lore and sailor adjectives.
There was time for reflection in this four-hour journey to the sea,
and ere long, sober second thought began to overtake his first wild
elation. The young reporter's doubts came trooping back. He
remembered now that he had never written a line of "ship-news" for
the Standard. He blushed to confess to himself that his life on salt
water had been bounded by the decks of river excursion steamers.
And what had he ever done worth the notice of the managing
editor? Of course, he had worked hard, and the world, at least in
fiction, occasionally rewarded honest merit in lowly places with
unexpected largess. But any "star man" of the staff would have
given a week's salary for such a note as this from the chief executive
of the Standard. And he, James Arbuthnot Wilson, was indubitably
the rawest and humblest recruit of that keen and rough-riding
squadron of talent.
An inevitable reaction swung his mood into the forebodings. The
train was loafing along the upper reaches of Delaware Bay when he
re-read the intoxicating note, and caught himself repeating "Dear Mr.
Wilson," with a sudden glimmer of association. In another miserable
moment the youth's beautiful dream was wrenched from him. What
a fool he had been! "Wilson," "Wilson," he muttered and burst out:
"Of course, there is another Wilson, the tip-top man of the staff. It's
the Wilson who's been filling in as chief of the Washington Bureau
for six months. I heard somebody say the other night that 'Doc'
Wilson was coming back, and was to go on general work again. He
must have turned up over Sunday. And that new boy put his note in
my box. Well, I am IT."
Young James Arbuthnot Wilson squeezed back a smarting tear. He
did not try to fence with this surmise. There was no room for doubt
that the kind words and the pleasant outing had been aimed at his
high-salaried elder. James Arbuthnot had never clapped eyes on the
gifted "Doc" Wilson, whose Washington dispatches had carried no
signature and whose distant personality had made no impression
upon this wretched understudy of his.
How could the pilgrim muster courage to go back and face the
issue? He would be the office butt—Well, he could resign, but most
likely, he reflected, dismissal would be the instant penalty of this
incredibly presumptuous blunder. The only thing to be done was to
drop off at the next way station and return to the scene of his
downfall. But to his stammering plea the brakeman returned:
"Next train up won't get along here till late to-night. You better go
through to Lewes instead of waiting seven hours at one of these
next-to-nothing flag stations."
The reporter slumped into his seat and looked through the open
window. The tang of brine was in the breeze that gushed up the bay
with the rising tide. Across the green fields he began to glimpse
flashing blue water and bits of the traffic of far-off seas. A deep-
laden tramp freighter was creeping toward her port, a battered bark
surged solemnly in tow of an ocean-going tug, and a four-masted
schooner was reaching up the bay with every sail pulling. Across the
aisle of the car Wilson noticed, with a melancholy pleasure, four
deep-tanned men of rugged aspect, who played cards with much
talk of ships and tides and skippers. They belonged in this picture.
Wilson thought of the stewing city far behind him, and the spirit of
some sea-faring ancestor was whispering in his ear. Yes, by Jove! he
would see the tragic venture through after all. It were better to
return with a "story," and fall with colors flying than to slink back to
empty ridicule. Let them try to overtake him if they dared. This was
"Mr. Wilson's" mission, and no one could snatch it from him.
When the train labored into Lewes, the fugitive looked across the
flats to the cuddling arm of the Breakwater and the shining sea
beyond. With the instinct of the hunted, he made ready to flee in
this direction, away from the station and the town. As he dropped
from the car, a man in the uniform of a station agent climbed aboard
and shouted:
"Telegram for Mr. Wilson. Is Mr. Wilson aboard? Urgent telegram for
Mr. J. A. Wilson."
Mr. Wilson's pulse fluttered as he dove behind the warehouse across
the tracks, while the hoarse cry of the station agent rang horribly in
his ears. The long arm of the Standard had almost clutched him by
the collar. As he hurried down the nearest street to the water, he
saw heading toward him a lusty youth of a sailorish cut, who eyed
the camera case as if hasty suspicions were confirmed.
"Is your name Wilson?" demanded the stranger. "If it be, come along
with me. I'm from the Albatross' boat-crew."
Wondering how much guilt was written in his face, Wilson fervently
shook the hand of the briny youth. They fared toward the pier, while
the convoy explained:
"You're in luck. We're ready to go to sea as soon as you get aboard.
Hit it just right, didn't you? The pilots'll be glad to see you again.
They was tickled to death over the piece you wrote for the paper
when the Eben Tunnell, Number Three, come in after fightin'
through the '88 blizzard, and specially what you wrote about ol' 'Pop'
Markle stickin' by the Morgan Castle when she ketched fire off the
Capes two year ago. And, say, they still talk about that jack-pot you
sky-hooted clean through the cabin skylight, and how th' Pilots'
Association went in mournin' for thirty days after that poker game.
Two o' them boys is aboard this cruise, with the chips all stacked an'
waitin', and their knives whetted. I'm sorry I missed the fun before."
James Arbuthnot Wilson gulped hard at these lamentable tidings. He
was vaulting from the frying-pan into the fire. These rude and
reckless men would probably heave him overboard. And, alas, the
penny-ante of his mild college dissipations had left him as deficient
in poker prowess as in sea-lore. The foremast hand from the
Albatross was somewhat crestfallen over his capture. If this slip of a
boy was the seasoned and capable "Doc" Wilson, able to hold his
own in all weather and any company, then appearances were basely
deceiving, and the escort felt a sense of personal grievance.
The boat was waiting at the pier and the four slouching seamen
rowed out to the black schooner, which lazily rolled her gleaming
sides off the end of the Breakwater. Wilson climbed awkwardly
aboard and was saved from sprawling his length on deck by a strong
hand, which yanked him in a welcoming grip. Then a stocky man
with a grizzled mustache stepped back and fairly shouted:
"Why, hell! You ain't 'Doc' Wilson. What kind of a game is this? I
popped up from below in time to see your hat coming over the side.
Kick me, please. I'm dreamin', as sure as my name's McCall."
He fished a rumpled telegram from his blue clothes, and flourished it
before the nose of his guest, as he cried formidably:
"Read that!"

"'Doc' Wilson, of the Standard, will be down on afternoon


train. Take him aboard and treat him right."

Young Wilson looked at the half mile of water between the schooner
and the beach, and thought of trying to swim for it. But the bully-
ragging tone of the pilot struck a spark of his latent pluck and he
answered with some spirit:
"I'm mighty sorry you're so disappointed. My name is Wilson, James
Arbuthnot Wilson, of the Standard. The order to join your boat was
delivered to me. If there's been a mistake, and I'm so unwelcome,
I'll have to put you to the trouble of setting me ashore again."
The innate hospitality of his kind smothered the pilot's first
emotions, and he regretted his rudeness as he smote the lad on the
back and shouted:
"All right, Jimmy Arbutus. I guess there's no great damage done. It's
now or never for your newspaper, and if we can't carry the skipper,
we'll get along with the mate of your outfit. And we'll give you a
cruise to make your lead-pencil smoke. Tumble below and shake
them natty clothes. The boat-keeper will fit you out with a pair of
boots and a jumper."
Sore and abashed, with the hateful emotions of an intruder, Wilson
crept below and faced another ordeal. In the pilots' roomy cabin,
which ran half the length of the schooner, four men were changing
their clothes and tidying up their bunks. One of them emerged from
the confusion to yell at the invader's patent leather ties:
"Hello, Doc, you old pirate. Is that you? Glad to see you aboard.
Well, I will be damned!"
His jaw dropped and he looked sheepish as a hurricane voice came
through the open skylight:
"Don't hurt the kid's feelin's. I've done plenty of that. This is Jimmy
Arbutus Wilson, apprentice to 'Doc,' and he's doin' the best he can.
'Doc' got stranded somewheres, and the lad is takin' his run. I don't
fathom it a little bit, but what's the odds?"
The passenger was introduced to all hands, who showed a
depressing lack of enthusiasm, and the pilots returned to their tasks.
Wilson retired, blushing and confused, to the edge of his bunk.
Presently the oldest man of the party sat down beside the intruder,
and shook his hand for the second time. Wilson raised his downcast
face to the white-haired veteran, who said softly:
"Now, sonny, don't let the boys rile you none. They're kinder sore on
some of the greenhorns that writes pieces all wrong for the
Philadelphy papers, and this 'Doc' Wilson knows sailor ways and
sailor lingo, and they sorter took a shine to him and his style. But
fur's I know, you can write rings around him. And Old Pop Markle, as
they calls me, will see you through, blow high, blow low. It's my last
cruise, this is. I'm past seventy year, sonny, and my oldest boy is a
pilot; he brought a tanker in yestiddy, and my grandson is servin' his
apprentice years, and he'll be gettin' his papers pretty soon. It's time
for me to quit. I was goin' to lay up ashore in the spring, but I
kinder wanted to wind up with the old Albatross. Better come on
deck, sonny; we're shortenin' cable."
Wilson smiled his gratitude at the gentle and garrulous old pilot,
whose smooth-shaven face was webbed with fine-drawn wrinkles, as
if each salty cruise had left its own recording line. The blue eyes
were faded from staring into fifty years of sun and wind, but they
held a beaming interest in the welfare of this tyro struggling in the
meshes of hostile circumstance.
The reporter followed his guardian on deck, and his spirits swiftly
rose. The Albatross was paying off under a flattened forestaysail,
while her crew tailed onto the main-sheet with a roaring chorus, for
they, too, felt a thrill of sentiment in this last cruise. The wind held
fresh from the south'ard, and under the smooth lee of Cape
Henlopen the Albatross shot seaward, as if they were skating over a
polished floor. Now the pilots came tumbling up, and shouted as
they turned to and helped set the maintopsail and staysail. The
schooner staggered down to it, until the white water hissed over her
low bulwark, and sobbed through the scuppers. "Old Pop" Markle
slapped his knee and cried huskily:
"Give her all she'll stand, boys. It's like old times when we raced that
dodgasted Number Four and hung to the weather riggin' by our
teeth, and bent a new suit of sails every other cruise."
Holding the wind abeam, the Albatross drove straight out to sea, and
then, once clear of Cape May, slid off to the north'ard. Now, the
quartering sea picked her up and she swooped down the slopes and
tried nimbly to climb the frothing hills, as the jolly wind smote her
press of canvas and jammed her smoking through them. A new
exhilaration surged in young Wilson's veins. He was drinking it all in,
the buoyant flight of the low, slim schooner, the intimate nearness of
the sea, the sweetness of the wind, and the solemnity of the
marching twilight. He would not have been elsewhere for worlds.
Then the fat and sweating face of the cook appeared from below,
and bellowed an inarticulate summons.
The pilots obeyed with ardor, and Wilson followed timidly in their
wake. Supper smoked on the cabin table, and the guest was glad to
survey the stout fare of hash, cold meat, potatoes, green peas, flaky
hot biscuits, and a mammoth pudding. "Old Pop" Markle took the
youngster under his protecting wing, and found a seat on the locker
beside his own. The reporter fell to, while the pilots chatted with
bursts of gusty laughter. He made one desperate rally to join the
talk, and in a quiet moment asked a neighbor:
"How do you know when a ship wants a pilot?"
"We generally have a trained green parrot that flies over and asks
'em," was the cruel response. "But we ran short of stores last cruise,
and had to eat him. This voyage we intend to mail 'em postal cards."
There was an appreciative roar, and Wilson winced as "Old Pop"
Markle whispered:
"Don't mind that Peter Haines. He's got a heart as soft as mush. It's
only their skylarkin', sonny. Hit 'em back. That's what they like."
But the victim had lost all self-confidence, and now he was
beginning to feel dizzy and forlorn. The smell of food, the heat, and
the jerky plunging of the cabin were overwhelming. He staggered to
his bunk and crept in. This was the last blow, that on top of his false
pretences he should be laid low before the eyes of this hostile
crowd. He knew not what happened, until hours after he awoke
from a semi-stupor to find "Old Pop" Markle sponging his face with
cold water and calling in his ear:
"There's a steamer coming up from the east'ard. Brace up and get
on deck. It's a pretty sight."
The boy clambered through the companionway as the boat-keeper
touched a match to an oil-soaked bunch of waste in a wire cage at
the end of his torch. The schooner and the near-by sea were bathed
in a yellow glare. Out in the darkness a blue Coston light glowed a
response. Some one shouted: "On deck for the skiff," and five
minutes later the boat-crew was pulling off in the night to the
waiting steamer, with a pilot in the stern-sheets.
"There goes your friend, Peter Haines," chuckled "Pop" Markle. "I
knowed you'd take it hard if I didn't give you a chance to say good-
bye to him. He won't pester you no more this cruise."
The wind blew some of the cobwebs from poor Wilson's muddled
head, and he felt refreshed. Soon the pelting spray drove him below
deck and he curled up on a locker, watching the poker game from
which youth and inexperience barred him. And what was more
cutting, he was not even asked to play.
"It would be like taking pennies from a blind child," callously
commented the strapping McCall who had welcomed him aboard.
But the white-haired patriarch of them all did not join the game, and
he said cheerily to Wilson:
"You're too young and I'm too old to be wastin' our wages in them
pursuits, ain't we, sonny? There's an old lady and a cottage at Lewes
that takes care of my rake-off. And instid of raisin' the limit, I raise
vegetubbles for my fun."
Wilson opened his bruised heart and told the old pilot the story of
his venture, and felt relieved that his masquerade had been thrown
away. "Pop" Markle's blue eyes twinkled:
"See here, Jimmy Arbutus, I'll see that you write a fust-rate piece for
your paper. Ask me anything your amazin' ignorance tells you to.
The boys wanted me to take in the fust vessel we met, and was
willin' to shove their turns aside, but I told 'em it was my last cruise,
and I was goin' to see her through to the finish. So we've lots of
time to talk pilotin' together. What was the most remarkable
experience ever I had? Pshaw, that sounds like a full-rigged reporter,
sonny, really it does.
"Well, I never got drownded boardin' a vessel, but I once fell afoul of
a skipper that was a worse blunderin' idjit than you've been. It may
sound kinder comfortin' to you. About fifty miles off the Capes, I
clumb aboard an Italian bark. Her captain said he was bound for
Wilmington, and would I take him in? He got a tow-boat at the
Breakwater, and we were goin' up the river all right, when plumb by
accident this benighted Dago imparted to me that he was bound for
Wilmington, North Caroliny. 'Great Scott! You dodgasted lunatic,'
says I, 'you're pretty nigh up to Wilmington, Delaware.' He went
crazier than ever, and put about for sea after I showed him on the
chart where he was at. He had been runnin' by dead-reckonin', and
didn't know where he was. So, when he picked up a pilot and found
he was headed all right for Wilmington, he figured his troubles were
over. So there's worse than you afloat, Jimmy Arbutus."
At his suggestion, Wilson dug up his notebook and scribbled therein
many other yarns, for the old pilot warmed to his task, and insisted
that each of the poker players should contribute a story to the fund.
When he was routed out for breakfast, the party had lost another
pilot who had found his ship at daybreak. The wind had drawn into
the northeast, and the Albatross was snuggled down under double
reefs. The barometer was falling, and the boat-keeper shook his
head when the pilots insisted upon edging further off shore.
"Drive her till she cracks," shouted McCall. "This is the trip when we
keep going till we get our ships. The Albatross goes home empty,
you bet your boots."
With much daring and difficulty one man was put aboard a liner late
in the afternoon. Three pilots were left, and they swept Wilson into
their genial comradeship, as the little party clawed its way to supper,
and hung onto the table by its eyelids. In his mind, Wilson began to
see the page story, "full of human interest and color." To-morrow he
would work at his "introduction," and the thought of really making a
start at filling those stately columns was perturbing. He felt
something like stage-fright at the notion of it.
Before midnight, James Arbuthnot Wilson had forgotten his "story,"
and was thinking only of the awful turmoil above him. The wind had
leaped to the might of a sudden summer gale. The schooner was
hove to and battened tight, and like a tightly corked bottle she
danced over the shouting seas. Made sick and giddy, Wilson sought
"Old Pop" Markle, who was peacefully snoring in the next bunk, and
shook him awake.
"Pshaw, sonny," the old man muttered, "she's safer than a big ship.
She'll rare and tear and sputter till it blows over. If it'll ease your
mind any, I'll take a peek on deck."
The pilot slipped into his oil-skins and vanished.
"It's pretty thick," he said when he came below, "but there ain't no
great sea on, not for us. Rainin' hard and blowin' some. McCall is
standin' watch with the boat-keeper. You're safer than if you was in
the Standard office. You can't lose your job out here, Jimmy."
Somewhat comforted, Wilson tried to sleep. It was a terrifying
experience for the greenhorn, with more "local color" than he had
bargained for. Some time later in the night he was half dreaming
that "Doc" Wilson was holding his head under water and drowning
him with the most enjoyable deliberation.
With a crashing sound like the explosion of a great gun in his ears,
he was flung headlong clear across the cabin, and on top of him
came "Old Pop" Markle, sputtering harmless curses. The cabin floor
sloped like the side of a house and stayed there as Wilson scrambled
to his hands and knees. Then came a more sickening lurch, and
before the hanging cabin lamp was smashed against the deck-
beams, the lad saw that the old man was dazed. He gave him a
hand, and together they climbed the slope, and grasped the legs of
the stationary table. They heard the other pilots stumble up the
companion ladder, and hammer back the hatch, with yells of terror
lest they be trapped.
Forward of the cabin bulkhead, they heard the roar of inrushing
water, and smothered outcries among the watch below. While the
old man and the boy tried to grope their way aft to the ladder, the
sea crashed through the bulkhead door from the galley beyond, and
instantly they were picked up and hurled aft, choking and fighting
for life. Wilson chanced to grasp a step of the ladder, and with his
free arm pulled "Old Pop" Markle to this refuge. The reporter did not
want to die, and he knew that death dragged him by the heels. And
it was with no heroic prompting that he pushed the old man up
ahead of him. It was done on the instant, as one friend would help
another in a pinch, without wrought-out purpose.
The water was sucking at his waist as he fought his way up, and
partly out, and managed to double himself over the hatch coaming,
with the old man's legs across his shoulders. Thus they were half
jammed in the cramped exit. Just then the flare torch was lighted by
a seaman. In the yellow glare "Old Pop" Markle saw the two pilots
and two, only two, of the crew wrestling with the one skiff left at the
davits. One of them stopped to beckon wildly to the old man and
started to go to his aid.
In this moment the schooner lurched under with a weary, lifeless
roll, and a black sea stamped across her sodden hull. It licked up the
boat and the handful of toiling men, it leaped forward and pulled
down the black figure with the torch. The two men still jammed in
the hatchway were cruelly battered, but they could not be wrenched
away. And when the towering comber had passed, there was
darkness and silence, and no more shouting voices on the
schooner's deck.
The old pilot wriggled free and got his hands on a life-buoy that
hung within his reach at the after end of the cabin hatch. Wilson
dragged himself after him, and pitched against a splintered mass of
planking upended against the wheel. They listened and heard a
steamer's imploring whistle, and one faint cry off to leeward. "Pop"
Markle groaned as he fumbled in the darkness and laboriously
passed a tangle of line around the wreck of the skylight cover to
which Wilson was clinging.
"Hang on, sonny," he gasped. "I've made the buoy fast to the loose
timber. We'll go off together with the next sea, sure. My God! here it
comes."
The dying schooner seemed to sink from beneath them, and clinging
to their frail bit of a raft, they were spun off to leeward in the arms
of the sea that swamped the rock-ballasted Albatross. Turned over
and over, the two men fought for breath until the skylight cover
righted, and they came to the surface. They slid swiftly into a murky
hollow, and were borne to the tattered crest whose froth was
strangling.
But the wind was falling fast. Such seas as those which had broken
over the helpless Albatross were running in swollen billows when
they met no barrier to check them. Therefore the castaways could
cling and breathe, and even made shift to pass the loose ends of the
line around their waists while they waited for the end. Now their
spray-blinded eyes dimly saw the lights of the steamer that had
bitten halfway through the pilot-schooner. She was blundering far to
windward, and her signal rockets cut red gashes in the night. They
could watch her swing in a useless circle as she sought to find the
craft she had struck. Drifting away to leeward, the old pilot and the
young reporter tried to shout, but their little rasping cries were
pitifully futile. They coughed the racking brine from their throats,
and saw the last rocket soar, saw the steamer's lights fade in the
rain, become twinkling points and vanish.
The last of the "Albatross."

There were no words between them until the day began to break.
Now and then one sought the other's hand and found a feebly
responsive grip. Thus they knew that death had not come to the
little raft. With the gray light, the wind veered round to the
south'ard, and except for the swinging swell, the sea was smoothed
to summer gentleness. The eternal miracle of dawn had never come
to more grateful hearts than these two. Youth had survived the
battering ordeal with mind still alert, but old age was near passing
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

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


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

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


personal growth every day!

ebookmasss.com

You might also like