100% found this document useful (2 votes)
31 views

Get Programming with C Zambak 1st Edition Osman Ay PDF ebook with Full Chapters Now

The document provides information on downloading various ebooks, including 'Programming with C' by Osman Ay. It includes links to additional titles and details about the 'Programming with C' ebook, such as authors, ISBN, file format, and year of publication. The document also outlines the contents of the book, covering topics from basic programming concepts to advanced object-oriented programming.

Uploaded by

yhonelyefi
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 (2 votes)
31 views

Get Programming with C Zambak 1st Edition Osman Ay PDF ebook with Full Chapters Now

The document provides information on downloading various ebooks, including 'Programming with C' by Osman Ay. It includes links to additional titles and details about the 'Programming with C' ebook, such as authors, ISBN, file format, and year of publication. The document also outlines the contents of the book, covering topics from basic programming concepts to advanced object-oriented programming.

Uploaded by

yhonelyefi
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/ 85

Visit https://ebookultra.

com to download the full version and


explore more ebooks

Programming with C Zambak 1st Edition Osman Ay

_____ Click the link below to download _____


https://ebookultra.com/download/programming-with-c-
zambak-1st-edition-osman-ay/

Explore and download more ebooks at ebookultra.com


Here are some suggested products you might be interested in.
Click the link to download

Ecology Zambak 1st Edition Osman Arpaci

https://ebookultra.com/download/ecology-zambak-1st-edition-osman-
arpaci/

Programming with Visual C Concepts and Projects 1st


Edition James Allert

https://ebookultra.com/download/programming-with-visual-c-concepts-
and-projects-1st-edition-james-allert/

Public Figures 1st Edition Osman

https://ebookultra.com/download/public-figures-1st-edition-osman/

Programming and Problem Solving with C Comprehensive


Comprehensive Edition Nell B. Dale

https://ebookultra.com/download/programming-and-problem-solving-with-
c-comprehensive-comprehensive-edition-nell-b-dale/
Professional Windows 8 Programming Application Development
with C and XAML 1st Edition Nick Lecrenski

https://ebookultra.com/download/professional-windows-8-programming-
application-development-with-c-and-xaml-1st-edition-nick-lecrenski/

Real World Functional Programming With Examples in F and C


1st Edition Tomas Petricek

https://ebookultra.com/download/real-world-functional-programming-
with-examples-in-f-and-c-1st-edition-tomas-petricek/

Programming C 1st Edition Jesse Liberty

https://ebookultra.com/download/programming-c-1st-edition-jesse-
liberty/

Earth Inferno Austin Osman Spare

https://ebookultra.com/download/earth-inferno-austin-osman-spare/

Functions Zambak 1st Edition Cem Giray

https://ebookultra.com/download/functions-zambak-1st-edition-cem-
giray/
Programming with C Zambak 1st Edition Osman Ay
Digital Instant Download
Author(s): Osman AY, Muhammed Akif HORASANLI
ISBN(s): 9789752662452, 9752662455
Edition: 1
File Details: PDF, 3.64 MB
Year: 2006
Language: english
M O D U L A R S Y S T E M

PROGRAMMING WITH
C++

Osman AY
Muhammed Akif HORASANLI

http://book.zambak.com
Copyright © 2006 Zambak Basým
Yayýn Eðitim ve Turizm Ýþletmeleri
Sanayi Ticaret A.Þ.
All rights reserved.
No part of this book may be
reproduced, stored in a retrieval
system, or transmitted in any form of
recording without the prior written
permission of the publisher.
Digital Assembly
Zambak Typesetting & Design
Page Design
Osman AY
Proofreader
Andy MARTIN
Publisher
Zambak Basým Yayýn Eðitim ve Turizm
Ýþletmeleri Sanayi Ticaret A.Þ.
Printed in
Ýstanbul - TURKEY
ISBN
978-975-266-245-2
DISTRIBUTION
ZAMBAK YAYINLARI
Bulgurlu Mah. Libadiye Cad. Haminne
Çeþmesi Sok. No. 20 34696
Üsküdar / ÝSTANBUL
_______________________
Tel : +90-216 522 09 00 (pbx)
Fax : +90-216 443 98 39
http://book.zambak.com
1. Introduction To Programming 3. Repetition Structures
Understanding the Programming . . . . . . . . . . . . . 6 Repetition Structures (Loops) . . . . . . . . . . . . . . . 38
The First C++ Program . . . . . . . . . . . . . . . . . . . . 6 The "while" Loop . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Breaking a Text into Multiple Lines . . . . . . . . . . . . 7 Increment and Decrement Operators . . . . . . . . . 40
Basic Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Counter-Controlled and Sentinel-Controlled
Getting Data from the User (Input) . . . . . . . . . . . . 8 Repetitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . 9 The "do/while" Loop . . . . . . . . . . . . . . . . . . . . . . . 45
Precedence of Arithmetic Operators The "for" Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Fundamental C++ Variables . . . . . . . . . . . . . . . . 11 Syntax of “for” statement . . . . . . . . . . . . . . . . 47
ASCII Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 The "break" and "continue" Statements . . . . . . . . 53
Reading and Printing Strings . . . . . . . . . . . . . . . . 15 Which loop should I use?. . . . . . . . . . . . . . . . . . . 54
Initialization of Variables . . . . . . . . . . . . . . . . . . . . 16 Nested Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Using Text Files as Input and Output. . . . . . . . . . 16 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . 57
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . 19 Programming Problems . . . . . . . . . . . . . . . . . . . . 58
Programming Problems . . . . . . . . . . . . . . . . . . . . 20 Flowchart Programming . . . . . . . . . . . . . . . . . . . . 61
Flowchart Programming . . . . . . . . . . . . . . . . . . . . 20 Making Loops . . . . . . . . . . . . . . . . . . . . . . . . . 61
Understanding Flowchart Programming . . . . 21 Pre-conditional Loops. . . . . . . . . . . . . . . . . . . 61
Flowchart Symbols . . . . . . . . . . . . . . . . . . . . . 22 Post-conditional Loops . . . . . . . . . . . . . . . . . . 62

2. Decision Structures 4. Functions


Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
The if structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 The Program Flow . . . . . . . . . . . . . . . . . . . . . . . . 64
The if/else structure . . . . . . . . . . . . . . . . . . . . . . . 25 Some Pre-defined Functions . . . . . . . . . . . . . . . . 65
Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . 27 The Structure of a Function . . . . . . . . . . . . . . . . . 67
The Conditional Operator (?) . . . . . . . . . . . . . . . . 28 Using Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 68
The Switch Structure . . . . . . . . . . . . . . . . . . . . . . 29 The Return Statement. . . . . . . . . . . . . . . . . . . . . . 69
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Passing Arguments to the Functions . . . . . . . . . . 70
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . 32 Pass by Value . . . . . . . . . . . . . . . . . . . . . . . . . 71
Programming Problems . . . . . . . . . . . . . . . . . . . . 34 Pass by Reference . . . . . . . . . . . . . . . . . . . . . 72
Flowchart Programming . . . . . . . . . . . . . . . . . . . . 35 Scope and Lifetime . . . . . . . . . . . . . . . . . . . . . . . 74
Making a Decision . . . . . . . . . . . . . . . . . . . . . 35 Local Variables . . . . . . . . . . . . . . . . . . . . . . . . 74
Global Variables . . . . . . . . . . . . . . . . . . . . . . . 74
Static Local Variables . . . . . . . . . . . . . . . . . . . 76 7. Object-Oriented Programming
Overloading Functions . . . . . . . . . . . . . . . . . . . . 77 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Understanding Classes and Objects . . . . . . . . . 130
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . . 79 Member Accessibility. . . . . . . . . . . . . . . . . . . . . . 130
Programming Problems . . . . . . . . . . . . . . . . . . . . 83 Class Definition . . . . . . . . . . . . . . . . . . . . . . . . . . 131

5. Arrays and Strings Reading and Printing a Class . . . . . . . . . . . . . . . 132


The Class Constructor and
Arrays and Vector Class . . . . . . . . . . . . . . . . . . . . 86
Initializing Class Members . . . . . . . . . . . . . . . 135
Array Declaration and
Object-Oriented Techniques . . . . . . . . . . . . . . . . 136
Accessing Array Elements . . . . . . . . . . . . . . . 86
a. Encapsulation and Data Hiding . . . . . . . . 136
Vector Manipulation . . . . . . . . . . . . . . . . . . . . . . . 88
b. Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . 136
Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . 90
c. Polymorphism . . . . . . . . . . . . . . . . . . . . . . 136
Passing Arrays to Functions. . . . . . . . . . . . . . . . . 93
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Searching Arrays . . . . . . . . . . . . . . . . . . . . . . . . . 95
Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Sequential (Linear) Searching . . . . . . . . . . . . 95
Operator Overloading . . . . . . . . . . . . . . . . . . . . . 141
Binary Searching. . . . . . . . . . . . . . . . . . . . . . . 96
Overloading Equal, Assignment, and
Sorting Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Smaller Than Operators. . . . . . . . . . . . . . . . . 141
String Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Reading and Printing Strings. . . . . . . . . . . . . 100
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . 145
String Manipulation . . . . . . . . . . . . . . . . . . . . . . . 101
Programming Problems . . . . . . . . . . . . . . . . . . . 148
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . 105 Answer Key
Programming Problems . . . . . . . . . . . . . . . . . . . 107
Flowchart Programming . . . . . . . . . . . . . . . . . . . 110
Index
Arrays and Strings . . . . . . . . . . . . . . . . . . . . . 110

6. Structs
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Declaring Structs and Accessing Members . . . 112
Reading and Printing Structures . . . . . . . . . . 112
Hierarchical Structures . . . . . . . . . . . . . . . . . . . . 114
Array of Structs . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Review Questions . . . . . . . . . . . . . . . . . . . . . . . . 123
Programming Problems . . . . . . . . . . . . . . . . . . . 124
Flowchart Programming . . . . . . . . . . . . . . . . . . . 126
Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Understanding the Programming
Ibn Musa al-Khwarizmi Programming is instructing a computer to perform a task for you with the help of a
(Algorizm) (770 - 840 AD) was programming language. The instructing part requires a step by step solution to the
born in Uzbekistan. His task. This step by step solution is called an algorithm after the name of AlKharizmi.
parents migrated to Baghdad
when he was a child. He is People who make computer programs are called programmers. There are usually
best known for introducing the two difficulties for computer programmers; Finding a feasible algorithm (algorithm
mathematical concept design) and writing the program (implementation). People who use the programs are
Algorithm, which is so named
called end-users.
after his last name.
Al-Khwarizmi was one of the A computer program (software) contains a sequence of instructions for a computer.
greatest mathematicians who One program is usually composed of three parts:
ever lived. He was the founder
of several branches and basic  Input part gets the data from an input device. Our programs, in the book, will get
concepts of mathematics. He the data from keyboard or from a text file.
is also famous as an
astronomer and geographer.  Process part is the hardest working part of the program. It carries out the
He is recognized as the algorithm and finds out the desired result.
founder of Algebra, as he not
only initiated the subject in a
 Output part gives the result of the program. Our programs will display the result
systematic form but also on the screen or print it into a text file.
developed it to the extent of
giving analytical solutions of
linear and quadratic The First C++ Program
equations. The name Algebra
is derived from his famous It is time to type our first C++ program. This program is going to prompt a line of
book Al-Jabr wa-al- text that says "Hello World!". This program has no input and no process but only
Muqabilah. He developed in output which says "Hello world!".
detail trigonometric tables
containing the sine functions. /*
Al-Khwarizmi also developed PROG: C1_01hello.cpp
the calculus of two errors, Understanding structure of a C++ program.
which led him to the concept Printing a line of text.
of differentiation. He also Using comments.
refined the geometric */
representation of conic
sections. #include <iostream>
//includes the declarations of the basic standard input-output
//library in C++, and its functionality is going to be used later
//in the program.

using namespace std;


//Namespaces are containers that contain the declarations of all
All the programs in this book //the elements of the standard C++ library
have been compiled with
Microsoft Visual Studio 2005.
int main() //the only function in this program.
You can also compile them
{
with GNU C++ (g++) in
Linux environment, or use free cout <<"Hello world!"; //print "Hello world!". cout is
Windows IDEs like Dev-C++ //declared in the iostream standard
(http://www.bloodshed.net/de //file within the std namespace
vcpp.html) and CodeBlocks
(http://www.codeblocks.org). system("pause"); //Wait until user hits a key and

6 Programming with C++


//displays a message
return 0; //the main function ends properly
}

Hello world!Press any key to continue . . .

C++ programs consist of one or more modules. Each module performs a specific
task. These modules are called functions. The "Hello World!" program has only one
module that is the main function. Any C++ program is been started to execute from
the main function so each program must have this function.
Before the functions, the program has an "include" and "using namespace" part.
This part declares the libraries where the C++ commands we are going to use in
the program are defined. Flowchart of the Program
“01hello”.
Like each sentence ends with a period ('.'), each C++ statement ends with a
semicolon character (';').
A flowchart is a visual
Besides the program codes, the program has some comments. C++ has two ways representation of the
to insert comments into source code: Single line comment and multiple line algorithms. Is is made up of a
few symbols: terminal, input,
comment. Single line comments are written behind the double slash characters
process, decision, output, and
("//") and multiple line comments are enclosed between slash and asterisk ("/*") connector.
and asterisk and slash ("*/") characters. Comments are ignored by the compiler.

Include precise comments in


Breaking a Text into Multiple Lines your program to make it self-
documentary and easy to
Use end of line "endl" or new line 'n/' characters with in a cout statement to make read. Usually the reading time
a new line. 'n/' characters are inherited from C programming. We prefer to use "endl" for programs is much more
notation. than the writing time.

/*
PROG: C1_02hello.cpp
Using endl.
*/
#include <iostream>
using namespace std;

int main()
{
cout <<"Hello world!"<<endl; //move the cursor to the cout<<“Hello ”<<endl;
//beginning of the next line. and
cout <<"This is my C++ program."<<endl<<endl; cout<<“Hello \n”;
system("pause"); statemens print the same
return 0; output.
}

Hello world!
This is my C++ program.

Press any key to continue . . .

Introduction to Programming 7
Basic Arithmetic
Any statement enclosed with double quotes (" ") in a cout statement is displayed
directly and any arithmetical or logical expression is evaluated and then the result
is displayed. The program below shows the result of the expression 3 + 5.
/*
PROG: C1_03sum.cpp
*/
#include <iostream>
using namespace std;

int main()
{
cout <<"5 + 3 = "<<5+3<<endl; //calculate and print the sum
system("pause");
return 0;
}

5+3=8
Flowchart of the Program Press any key to continue . . .
“03sum”
Getting Data from the User (Input)
Programs usually read the input data from the standard input (keyboard) or from
an input file. "cin" command is used to read data from the standard input. The
following program reads two integers, calculates their sum and then outputs the
result.
int num1, num2, sum; declares three variables. The names of the variables are
num1, num2 and sum. A variable is a named storage location that can contain
data that can be modified during program execution. This declaration specifies
that those variables can contain integer values (-45, 0, 11, 37, etc.). "num1" and
"num2" will be used to store the input data, and "sum" will be used to keep the
sum of input values in the program.
/*
PROG: C1_04sum.cpp
Getting data from keyboard, making sum of two integers,
understanding variables, and using assignment operator.
*/
#include <iostream>
using namespace std;

int main()
{
int num1, num2, sum; //num1, num2 and sum are three
//variables type of integer.
cout<<"Enter two integers:"<<endl;
cin >> num1 >> num2; //cin reads two values for
Flowchart of the Program //num1 and num2.
“04sum” sum = num1 + num2; //sum gets the value of num1+num2.

8 Programming with C++


cout <<"Sum is "<<sum<<endl;
system("PAUSE");
return 0;
}

Enter two integers:


57
Sum is 12
Press any key to continue . . . C++ provides assigment
operator and compount
assignment operators(+=,
sum = num1 + num2; first computes the sum of the values of num1 and num2 then -=, *=, /=, %=, >>=,
assigns the result to the variable sum. We have used an arithmetic operator (+) and <<=, &=, ^=, |=). For
assignment operator (=) in this statement. example sum=sum+5 can be
written as sum+=5. The
assigment operator can be
used for chain assignment
Arithmetic Operators processes. For example a=3;
and b=3; can be written as
Operation Operator Example a=b=3;

Addition + 5+4=9
Subtraction - 5 - 4 = 1 and 4 - 5 = -1 Beside the assignment and
the arithmetic operators C++
Multiplication * 5*4=9 has many others. The most
common C++ operators are:
Division (integer) / 15 / 3 = 5 and 12 / 5 = 2
 assignment
Modulus % 12 % 5 = 2, 15 % 3 = 0, and 3 % 5 = 3  arithmetic
 increment and decrement
/*

PROG: C1_05calculator.cpp string concatenation
Demonstrating arithmetic operators. Calculating sum, difference,  relational
product, quotient, and remainder. Using (float) casting to get  logical
floating-point quotient.  conditional
*/  bitwise
#include <iostream>
using namespace std;

int main() The bitwise shift operators


{ shift their first operand left
int num1, num2; (<<) or right (>>) by the
number of positions the
cout <<"Enter two integers:"; second operand specifies.
Shifting one position left is
cin >> num1 >> num2;
equivalent to multiply the
number by 2, and shifting one
cout <<num1 <<"+"<<num2<<"="<<num1+num2<<endl; position right is equivalent to
cout <<num2 <<"+"<<num1<<"="<<num2+num1<<endl<<endl; divide the number by 2.

cout <<num1 <<"-"<<num2<<"="<<num1-num2<<endl; (4<<3) yields 32 and


(12>>2) yields 3.
cout <<num2 <<"-"<<num1<<"="<<num2-num1<<endl<<endl;

Introduction to Programming 9
cout <<num1 <<"*"<<num2<<"="<<num1*num2<<endl;
cout <<num2 <<"*"<<num1<<"="<<num2*num1<<endl<<endl;

cout <<num1 <<"/"<<num2<<"="<<num1/num2<<endl;


cout <<num1 <<"/"<<num2<<"="<<(float)num1/num2<<endl;
cout <<num2 <<"/"<<num1<<"="<<num2/num1<<endl;
cout <<num2 <<"/"<<num1<<"="<<(float)num2/num1<<endl<<endl;

cout <<num1 <<"%"<<num2<<"="<<num1%num2<<endl;


cout <<num2 <<"%"<<num1<<"="<<num2%num1<<endl<<endl;

system("PAUSE"); return 0;
}

Enter two integers:7 3


7+3=10
3+7=10

7-3=4
3-7=-4

7*3=21
3*7=21

7/3=2
7/3=2.33333
3/7=0
3/7=0.428571

7%3=1
3%7=3

Press any key to continue . . .

Precedence of Arithmetic Operators


 Parentheses ("( )") are evaluated first. The expression in the innermost
parentheses is evaluated first if the parentheses are nested.
Flowchart of the Program
 After parentheses multiplication (*), division (/), and modulus (%) operators are
“05calculator”
evaluated.
 Addition (+) and subtraction (-) are evaluated last.
 The operators with the same precedence are evaluated left to right.
3 * 5 + 2 = 17
3 * (5 + 2) = 21
5 + 3*4 - 2 = 15
6*8/4 = 12
6*(8/4) = 12

10 Programming with C++


Exercise: Rectangle

Make a program to calculate area and perimeter of a rectangle.

Input: length of side1 and length of side2.


Process: area = side1*side2 side2
Perimeter = 2*(side1+side2)
Output: area and perimeter side1

Fundamental C++ Variables


A variable is a memory place in which you can store a value and from which you can
later retrieve that value. Notice that this temporary storage is used only during the
execution of the program.
The following table summarizes the fundamental C++ variables.

Size in
Type Values
Bytes
unsigned short int 2 0 to 65,535
short int 2 -32,768 to 32,767 Always name your variables
with a great care, and explain
unsigned int 4 0 to 4,294,967,295 them thoroughly.
int 4 -2,147,483,648 to 2,147,483,647
integer variables
unsigned long int 4 0 to 4,294,967,295
long int 4 -2,147,483,648 to 2,147,483,647
9.223.372.036.854 to
long long int 8
9.223.372.036.853

floating-point float 4 1.2e-38 to 3.4e38


variables double 8 2.2e-308 to 1.8e308
logical variable bool 1 true or false
character variable char 1 256 character values

 Integer variables store whole numbers (-4, 3, 51, etc). Unsigned integer type
variables cannot have negative values, whereas other integer type variables (signed
integers) may have negative and positive values.
 Floating-point variables store decimal numbers (3.5, -5,123, 4.0, etc).

Introduction to Programming 11
 Logical variables store the result of logical expressions and get only the values
true and false. False is represented with 0 and true is represented with a positive
value (usually 1) in C++. Logical expressions are usually used in decision and
repetition structures to control the flow of the program.
 Character variables are used to store characters (letters, numbers, punctuation
characters, etc). Characters are enclosed with a pair of single quotes in C++, like
'a', 'B', '7', '+', etc.

The sizes of variables might be different from those shown in the table, depending
on the compiler and the computer you are using. Use sizeof() operator to measure
the sizes of variable types in your system. The sizeof() operator returns the number
of bytes in variable or type.
/*
PROG: C1_06sizeof.cpp
C++ variable types and their sizes in bytes
*/
#include <iostream>
using namespace std;
int main()
{
cout <<"int = "<<sizeof(int)<<endl;
cout <<"short int = "<<sizeof(short int)<<endl;
cout <<"long int = " <<sizeof(long int)<<endl;
cout << "long long int =" <<sizeof(long long int)<<endl;

cout <<"float = "<<sizeof(float)<<endl;


cout <<"double ="<<sizeof(double)<<endl;
cout <<"long double ="<<sizeof(double)<<endl;

cout <<"bool ="<<sizeof(bool)<<endl;

cout <<"char ="<<sizeof(char)<<endl;

system("pause"); return 0;
}

int = 4
short int = 2
long int = 4
long long int =8
float = 4
double =8
long double =8
bool =1
char =1
Press any key to continue . . .

12 Programming with C++


Exercise: Circle
Like variables, constants are
Make a program to calculate area and circumference of a circle. data storage locations. Unlike
Input: radius of circle. variables, constants don't
change. You must initialize a
Process: area = PI*radius*radius ius constant when you create it,
rad and you cannot assign a new
circumference = 2*PI*radius value later.

Output: area and circumference Most of the common


constants have already been
defined in C++. For the user
defined constants, there are
PI is an arithmetical constant whose approximated value is 3.14159. It is defined two main techniques used to
in C++ as a constant as PI. Add the following lines at the beginning of your create constant values:
program to use this constant in your program: a. using the define keyword
#include <iostream>
#define _USE_MATH_DEFINES
#define PI 3.14
#include <cmath> .
.
b. using the const keyword
.

Exercise: 1 or 0
.
int main()
const float PI = 3.14;
.
Make a program that gets two numbers (let's say A and B) and then displays .
1 if the first number is bigger then second one, otherwise displays 0.
Input: Two numbers A and B.
Process: Comparing A and B. Use bigger than operator in the comparison
(A>B).
Output: 1 if the first number is bigger, 0 if the first number is not bigger. Visit the site
http://www.asciitable.com to
see the ASCII table.

EBCDIC (Extended Binary


ASCII Codes Coded Decimal Interchange
There are only 1s and 0s in a computer system. Computers work with binary Code) is an 8-bit character
encoding (code page) used
numbers. We can convert binary numbers into their equivalent decimal numbers that on IBM mainframe operating
are the numbers we use in our daily life. But what about other characters, letters, systems as well as IBM
punctuation marks, and special characters. How can we present them to the minicomputer operating
computers? systems. It is also employed
on various non-IBM platforms
Character encoding (character set) tables are used to represent the characters with such as Fujitsu-Siemens and
numbers. ASCII (1963) and EBCDIC (1964) are two international standard character Unisys MCP. Although it is
widely used on large IBM
sets.
computers, most other
ASCII (Pronounced ask-ee) is an acronym for American Standard Code for computers, including PCs and
Macintoshes, use ASCII
Information Interchange. In ASCII, every letter, number, and punctuation symbol has codes.

Introduction to Programming 13
a corresponding number, or ASCII code. For example, the character for the number
1 has the code 49, capital letter A has the code 65, and a blank space has the code
32. This encoding system not only lets a computer store a document as a series of
numbers, but also makes it possible to transfer data from one computer to another.
In an ASCII file, each alphabetic, numeric, or special character is represented with a
7-bit binary number (a string of seven 0s or 1s). 128 possible characters are defined.
There are also ASCII extensions in use which utilize 8 bit codes to represent
international characters in addition to the standard ASCII scheme.
cout prints the ASCII character of an ASCII code with “char” casting. The following
program reads an ASCII code (an integer) and prints its character.
/*
PROG: C1_07ascii.cpp
Displaying the ASCII character of an ASCII code.
*/
#include <iostream>
using namespace std;

int main()
{
int code;
cout <<"Enter the ASCII code [between 0 and 127] ";
cin >> code;

cout <<"The ASCII character of "<<code<<" is "


<<(char)code<<endl; //print the character not number

system("pause");
return 0;
}

Enter the ASCII code [between 0 and 127] 75


The ASCII character of 75 is K
Press any key to continue . . .

Exercise: ASCII Character

Make a program to print code of an ASCII character.


Input: an ASCII character.
Output: ASCII code of the input character.
Sample Output:
Enter an ASCII character A
The ASCII code of A is 65
Devam etmek için bir tusa basin . . .

14 Programming with C++


Reading and Printing Strings
In programming, a string is an ordered series of characters. You can consider them
words and sentences. They are represented with enclosed double quotes in a C++
program code, like "Hello!" or "I am learning C++".
C++ provides string class for string operations. S string class is defined in the Class and object are two main
terms of Object Oriented
<string> standard library. The instances of variable types are called variables,
Programming. Objects are the
whereas the instances of classes are called objects. We are going to study classes real elements in the program
and objects in the later chapters of this book. and classes are like a
blueprint of the objects.
cin reads only the first word of a string, and cout prints all characters of a string. The Whenever we need an object
string class has its own methods (functions) for string manipulation. We are going to we can create it from its class.
study string class later in this book.
The '+' is called string concatenation operator with strings and is used to
concatenate two string objects. Do not confuse the string concatenation and
arithmetic addition operator. Examine the following two operations.
57 + 33 is 90 Here '+' is addition operator.
"57" + "33" is "5733" Here '+' is string concatenation operator.
The following example reads name and surname of the user, and then prints a hello
message.
/*
PROG: c1_08string.cpp
Reading a word. Using the string data type and the string
concatenation operator (+).
*/
#include <iostream>
#include <string> //string library
using namespace std;
int main()
{
string firstname, surname; //two objects of string class

cout << "Enter your firstname."<<endl;


cin >> firstname;
cout << "Enter your surname."<<endl;
cin >> surname;
//string concatenation
cout <<"Hello "<<firstname + " " + surname<<endl;
system("pause"); return 0;
}

Enter your firstname.


Alan
Enter your surname.
Flowchart of the Program
Smith
“08string”
Hello Alan Smith
Press any key to continue . . .

Introduction to Programming 15
Initialization of Variables
You can give the initial values to the variables during the declaration in C++. The
following program demonstrates how to declare different type of variables. Notice
that string objects can be initialized in two ways. You may use either of them in your
programs.
/*
PROG: c1_09init.cpp
Initializtion of variables.
*/
#include <iostream>
#include <string>
using namespace std;
int main()
{
string st1("I am learning "); //st1 is been initialized to
//"I am learging "
string st2 = "C++"; //st2 is been initialized to "C++"
int int1 = 8, int2 = 5; //int1 is been initialized to 8, and
//int2 to 5
float flt1 = 7.5, flt2 = 3.9; //flt1 is been initialized to
//7.5, and flt2 to 3.9
char ch1 = 'A'; //ch1 is been initialized to 'A'
bool bl1 = true, bl2 = false; //bl1 is been initialized to
//true, and bl2 to false

cout<<"st1 + st2 is "<<st1 + st2<<endl;


cout<<"int1 + int2 is "<<int1 + int2<<endl;
cout<<"flt1 + flt2 is "<<flt1 + flt2<<endl;
cout<<"ch1 is "<<ch1<<endl;
cout<<"bl1 is "<<bl1<<endl;
cout<<"bl2 is "<<bl2<<endl;
system("pause"); return 0;
}

st1 + st2 is I am learning C++


int1 + int2 is 13
flt1 + flt2 is 11.4
ch1 is A
bl1 is 1
bl2 is 0
Press any key to continue . . .

Using Text Files as Input and Output


C++ provides two functions to read from a text file and to write into a text file. Those
functions are ifstream() and ofstream(). Both functions are declared in the
<fstream> header. ifstream opens an existing input file whereas, ofstream creates
or recreates and opens the output file.

16 Programming with C++


Data input and output operations on text files are performed in the same way we
operated with “cin” and “cout”. ifstream() function defines an identifier to read from
a file, and the name and location (path) of that file. In the same way, ofstream()
function defines an identifier to write into a file, and the name and location (path) of
the file. I prefer to use "fin" and "fout" identifiers in my programs fin takes the role of
cin and fout takes the role of cout. After you have finished with the input and output
files you should close them so that their resources become available again for the
system. close() function is used to close the open files.
The following program read two integers (num1 and num2) from the file numbers.in.
Computes sum, difference, product and quotient of those two numbers and then
writes the result into the file numbers.out.

/*
PROG: c1_10file.cpp
Using input and output files.
*/
#include <fstream>
using namespace std;

int main()
{
ifstream fin("numbers.in"); //open input file
ofstream fout("numbers.out");//create and open output file

int num1, num2;


fin >>num1 >>num2; //read two integers from the input file

//Make arithmetical calculations and write the result into


//the output file
fout <<"sum is "<<num1+num2<<endl;
fout <<"difference is "<<num1-num2<<endl;
fout <<"product is "<<num1*num2<<endl;
fout <<"integer quotient is "<<num1/num2<<endl;
fout <<"floating-point quotient is "<<(float)num1/num2<<endl;

fin.close(); //close the input file


fout.close(); //close the output file

system("PAUSE"); Flowchart of the Program


return 0; “10file”
}
numbers.in numbers.out

53 sum is 8
difference is 2
product is 15
integer quotient is 1
floating-point quotient is 1.66667

Introduction to Programming 17
SUMMARY

An algorithm is a set of ordered steps for solving a particular problem. A computer program is series of
instructions or statements, in a form acceptable to a computer, to cary out an algorithm. A programming
language is a human-created language that translates instructions from programmers to computers.
C++ is an object-oriented programming (OOP) language and the primary programming languages for
computers of today. Any C++ program consists of modules that are called functions. The primary function of
a C++ program is “main”. C++ uses cout and cin for printing and getting the data.
Operators are symbols (such as +, *, /) used to perform arithmetic, relational, logical, assignment, string,
bitwise etc. operations.
A variable is a named item used to represent data that can be changed while the program is running. Like a
variable, a constant is a named item but it has a fixed value that does not change.
ASCII (American Standard Code of Information Interchange) is an international code standard for
representation of characters, numbers, symbols and control characters, for use in data communication and
data storage. ASCII text does not include special formatting features and therefore can be exchanged and read
by most computer systems.
A string is a series of alphanumeric characters of any length. Strings are enclosed by double quotes in C++.
File processing consists of creating a file, storing data into a file, and retrieving data from a file. C++ performs
file processing with ifstream() and ofstream() functions that are defined in the <string> header file.

18 Programming with C++


REVIEW QUESTIONS

1. What is the output of the following program?


Line a b c
#include <iostream>
using namespace std; Ýnt a=1, b=2, c=3; 1 2 3
int main()
{ a = b + c; b = a - b*c;
cout <<"I am "; c = (a + c)/(c - b);
cout <<"learning "<<endl<<"C++"; a = a%b/c; b = -b;
return 0;
}

4. What are the most suitable variable types for the


given data?

Data Variable Type


2. What is the output of the following program?
#include <iostream> Age of a person unsigned short
using namespace std; Name of a person
int main()
{ Gender of a person ('F' or 'M')
int a=1, b=2;
cout <<a<<" "<<b; State of a electrical switch
a = a+b; (ON or OFF)
b = a+b; Number of the passengers in
cout <<b<<" "<<a;
an airplane
return 0;
} Area of a circle
Temperature

3. Calculate the values of variables in the given lines


and complete the table.
#include <iostream>
using namespace std;
int main()
{
int a=1, b=2, c=3;
a =b + c; b =a - b*c;
c =(a + c)/(c - b); a=a%b/c; b=-b;
return 0;
}

Introduction to Programming 19
PROGRAMMING PROBLEMS

1. (Sum of digits) Make a program that reads a three-digit integer from the file "number.in" and then
calculates sum of the digits and writes the result into the file "sum.out". Use the format of the sample
output in the file "sum.out". (Hint: Use the modulus (%) and integer division (/) operators.)

number.in sum.out

423 Sum of the digits is 4+2+3 = 9

2. (Swapping) You are given two integer variables, let's say a and b. How can you interchange the values
of those two variables? In other words, a should get the value of b, and b should get the value of a.
a. Use a temporarily third variable
b. Do not use any additional variable
c. Use the swap function (swap(a, b);).
3. (To Upper) Make a program that reads a letter from the keyboard and then converts the letter to upper
case, if the letter is lower case.
a. Change the ASCII code of the letter.
b. Use the toupper function (a = toupper(a);).

FLOWCHART PROGRAMMING (OPTIONAL)

Understanding Flowchart Programming


Flowchart is a symbolic language to express algorithms. It visually presents the
solution of a specific task.You have already seen flowcharts of some sample
programs in this book and you became familiar with some of the flowchart symbols.
Traditionally people begin with flowchart programming, learn the fundamental
techniques of programming (such as input, output, making calculations and
comparisons, decisions, repetition) and then start to write their programs with a
programming language. When starting the programming directly with a
programming language will face you two difficulties: learning the syntax of the
programming language and learning the programming techniques.
We have started the programming directly with a programming language (C++) in
this book, because the syntax of C++ is self-explanatory and easy to understand
for English speaking people.

20 Programming with C++


You will find an IDE (Integrated Development Environment) flowchart programming
(FCPRO) in the Web site of the book (http://book.zambak.com) where you can draw,
run, trace the variables, and debug your flowcharts. FCPRO was made in C++ by
Cosmin Raianu who was one of my best students from Romania.

By Using FCPRO, You Can Do The Following:


 Design your own flowcharts
 Save your flowcharts to disk and open them whenever you need to.
 Export your flowcharts as BMP files.
 Run your flowcharts, reading the input from the user and displaying the output.
 Debug your flowcharts, by stepping through them and inspecting the values of
variables and expressions by using the Watches.
 Compile your flowcharts into standalone Win32 Console applications.
 Edit, save and open programs written in a special pseudocode.
 Convert flowcharts to their corresponding pseudocode programs and vice versa.
 Learn all about flowcharts, pseudocode and the way FCPro works by using the
user-friendly integrated help system.

Refer to the FCPRO built-in


help to get detailed
information about flowchart
programming and to learn
how to use FCPRO.

Introduction to Programming 21
Flowchart Symbols
Terminal (Start, End)
The terminal symbol marks where the flowchar starts and where it
ends. Usually a starting terminal contains the word “START” or
“BEGIN”, and an ending terminal contains the word “END” or
“FINISH”.

Input (Get, Read)


The input symbols are used to get data from the user. The data is
stored in variables. You don’t have to declare the type of the
variables in FCPro. FCPro determines the type of the variables
The shapes of the flowchart according to the first value you assign them.
symbols can be slightly
different in some other Process (Do)
sources.
A process symbol denotes that a process (arithmetic, logic, or
assighment) will be carried out.
Decision (If)
It is a decision making and branching symbol. You can control the
flow of the program by means of the decision symbol. That is, you
can set loops and execute either part of the program depending
of the result of the logical expressin in the decision symbol.
Output (Print, Display)
An output symbol is used to print a message, values of variables
and results of expressions.

Flow Line (Arrow)


Lines indicate the sequence of steps and the direction of flow.
Connector (Joining)
The connector symbol connects two parts of a flowchart. It is
usually used to connect two pages of a flowchart when you are
manually drawing a flowchart on paper. In FCPro, It is used to
FCPro Arithmetic Operators: prevent an arrow intersect with a flowchart symbol for a better
+ : Addition view.
- : Subtraction
* : Multiplication Exercise: Flowcharts
/ : Integer Division
// : Fractional Division Draw and run all the flowchart programs (01hello, 03sum, 04sum,
% : Modulus 05calculator, 07string, 08file) that are given in this chapter in FCPRO.

22 Programming with C++


Introduction
In our daily life, we often encounter many options and we have to select one. Our
selections decide the way of our life. In every separation point we make our decision
and go on our way. While programming, we usually need to decide the path of the
program flow according to the parameters and conditions. Actually the ability of
making decision is one of the key points of intelligent programming. Thanks to
Relational and Equality control structures (decision & repetition) we are able to evaluate the condition and
Operators tests some kind of
relation between two entities. select the flow path. We have 4 types of decision structures in C++:
These include numerical
equality and inequalities.
 If
These operators usually return  If/Else
true or false, depending on
whether the conditional  Conditional Operator (?)
relationship between the two  Switch
operands holds or not. An
expression created using a The If/else statement chooses between two alternatives. This statement can be used
relational operator forms what
without the else, as a simple if statement. Another decision statement, switch,
is known as a condition.
Decision structures evaluate creates branches for multiple alternative sections of code, depending on the value
the conditions. of a single variable. Finally, the conditional operator is used in specialized situations.
C++ Relational and Equality
Operators are:
The if structure
> : Greater
The "if structure" is used to execute statement(s) only if the given condition is
>= : Greater or Equal
satisfied. The Computer evaluates the condition first, if it is true, statement is
< : Smaller executed if not the statement is skipped and the program continues right after this
<= : Smaller or Equal conditional structure. This can be illustrated as:
== : Equal
!= : Not Equal

The following code prints "passed" or "failed" depending on the average of the
student by using two separate if structures.

24 Programming with C++


if (average>60)
{
cout<<"passed"; //if the average is greater than 60
//print passed.
}

if (average<=60)
{
cout<<"failed"; //if the average is less than or equal
//to 60 print failed.
}

The first if structure checks whether the average is greater than 60, if so writes
"passed" to the output. The second if structure checks whether the average is less
than or equal to 60 if so writes "failed" to the output.
If we have a single statement in a "if" then it can be written without braces; but if we
have a compound statement to be executed we need to enclose them between
braces ({ }).

The if/else structure


We can additionally specify what we want to do if the condition does not hold with
Using “if” in a Flowchart
else. While the if statement lets a program decide whether a statement or block is
executed, the if/else statement lets a program decide which of two statements or
blocks is executed. This can be illustrated as :

Truth in C++
C++ has a very simple logic
to cope with truth. Any value
other than zero is regarded as
true. Thus 1 and -2 are both
true just like 0.0001.Since they
are all different from zero. In
If any student passed, namely the average is bigger than 60, it is unnecessary to
the same logic 0, 0.0 or +0.0
check if he failed. If he passed it is obvious that he didn't fail, and in the same manner and -0 are all accepted as
if he didn't pass it is obvious that he failed. false.

Decision Structures 25
if (average>60)
cout<<"passed"; //if the average is greater than 60
prints passed.
else
cout<<"failed"; //if condition does not hold then
prints failed.

Exercise: Odd or Even

Write a program that decides if a number is odd or even.


Input : An integer.
Output : "Odd" or "Even".
Using “if/else” in a Flowchart Hint : Even numbers are divisible by 2. That is to say when an even number
is divided by 2, the remainder is 0. Use modulus operator (%) to
obtain the remainder.

Let's improve our average example. What if we have an average value less than 0?
As a programmer we should always keep in mind the unexpected cases. We would
be able to respond to the user that any value less than 0 is not valid.
if (average>60)
{
cout<<"Passed";
}
else if (average<0)
{
cout<<"Wrong Input";
}
else
{
cout<<"Failed";
}

The if/else structure above checks the first condition, if it is satisfied, prints "Passed"
and skips the rest of the structure. If the first condition is not satisfied, the second
condition is checked, and so on. If none of the conditions is held, the last statement
is executed.

Exercise: Sign

Write a program that decides the sign of a number.


Input: An integer.
Output: Positive, Negative or Zero.

26 Programming with C++


Logical Operators
Logical operators simplify nested if and if/else structures. They combine multiple
logical expressions and return a single result (True or False). There are three logical
operators in C++:
! (Not)
 && (And)
 || (Or)

! (Logical Not) operator has only one operand (unary operator) and returns the X !X
opposite of it. Not Operator gives true if the operand is false, and gives false if the
operand is true. For example: 0 1
!(5 > 7) //evaluates to true. 1 0
!true //evaluates to false.
The Truth Table of the NOT
Operator (!)

&& (Logical And) operator has two operands (binary operator). It returns true only if
both operands are true, and returns false otherwise. So we may need this operator X Y X && Y
when we have to perform a task if two conditions are fulfilled at the same time. For 0 0 0
example we want to determine if a given integer (num) is divisible by 3 and 7.
0 1 0
if ((num % 3 == 0) && (num % 7 == 0)) 1 0 0
cout<<"It is divisible by 3 and 7";
1 1 1
The Truth Table of the AND
Operator (&&)

|| (Logical Or) operator has two operands. It returns false if both operands are false,
and returns true otherwise. It can be used in a case if at least one of two conditions X Y X && Y
has to be true to perform a task. For example we want to check if a number is 0 0 0
divisible by 3 or 7.
0 1 1
if ((num % 3 == 0) || (num % 7 == 0))
cout<<"It is divisible by 3 or 7"; 1 0 1
1 1 1
Exercise: Letter The Truth Table of the OR
Operator (||)
Write a program that checks if an entered character is between 'a' and 'z' or 'A'
and 'Z'. Namely check if it is a letter or not.
Input: One character.
Output: "IT IS A LETTER" or "IT IS NOT A LETTER".

Decision Structures 27
Let's have a look how to use logical operators to determine whether a given year is
a leap year. Leap years are years with an extra day (February 29); this happens
almost every four years. Generally, leap years are divisible by four, but century years
are special, they must also be divisible by 400. Given a year decide whether it is a
leap year or not.
We know that the set of numbers divisible by 400 is a subset of the set of numbers
divisible by 100. And the set of numbers divisible by 100 is a subset of numbers
divisible by 4.

Leap years are needed so U U = All of the years


that the calendar is in C C= Years divisible by 4
alignment with the earth's B
motion around the sun. A B= Years divisible by 100
A= Years divisible by 400
From the description it is clear that if the number is in the red area than it is a leap
year otherwise it is not. We can describe the red area as (A or (C and (Not B)))
if ((year%400==0)||((year%4==0)&&(!(year%100==0))))
cout << "Leap Year";
else
cout << "Not a Leap Year";

Exercise: Leap Year

Implement the leap year problem without logical operators (by nested if/else)
Input: An integer for year value.
Output: "IT IS A LEAP YEAR" or "IT IS NOT A LEAP YEAR".

The Conditional Operator (?)


C++ provides another selective operator that can be an alternative of simple if/else.
If we are choosing from two options based on a condition we can simply implement
it with a conditional operator. Let's implement our "pass" "fail" example with "?".

With if/else With ?

if (average>60)
cout<<"passed";
cout<<((average>60) ? "passed" : "failed");
else
cout<<"failed";

28 Programming with C++


Here condition (average > 60) is evaluated. If it is true, "passed" is written; If not,
"failed' is printed.
Our leap year problem can be written as:
february=((year%400==0)||((year%100!=0)&&(year%4==0))) ? 29 : 28;

If the condition is true it is a leap year, if false it is not.

The Switch Structure


Switch allows us to select from multiple choices based on constant values. If we are
to use several "if" and "else if" instructions to check constant values it is best to
implement it by using switch. For example we are getting the month number from the
user and printing the month name on the screen
/*
PROG: c2_01switch.cpp
Read the order of a month and prints its name.
*/
int main()
{
int month;
cout<<"enter the month number";
cin>>month;
switch (month) {
case 1 :
cout<<"it is january";
break;
case 2 :
cout<<"it is february";
break;
case 3 :
cout<<"it is march";
break;
case 4 :
cout<<"it is april";
break;
case 5 :
cout<<"it is may";
break;
case 6 :
cout<<"it is june";
break;
case 7 :
cout<<"it is july";
break;
case 8 :
cout<<"it is august";
break;
case 9 :

Decision Structures 29
cout<<"it is september";
break;
case 10 :
cout<<"it is october";
break;
case 11 :
cout<<"it is november";
break;
case 12 :
cout<<"it is december";
break;
default :
cout<<"wrong input";
}
Switch evaluates the value of expression and performs all of the instructions starting
from the true case of the expression's value till the ending brace.
If none of the cases has the value of expression then instructions under default part
are executed. You can have only one default statement in a switch statement block.
The break statement at the end of the case statement tells C++ to exit the switch
statement. C++ does not generate an error message if you omit a break statement.
However, if you omit it, C++ executes all the statements in the following case
statement, even if that case is false. In nearly all circumstances, this is not what you
want to do.
Sometimes we need to group the cases since we have the same operation for some
values. This can be understood better by an example. Again we are getting the
month number from the user but this time printing how many days this month has to
the screen.
/*
PROG: c2_02months.cpp
Read the order of a month and print how many days it has.
*/
switch (month)
{
case 2 : cout<<"it has 28 days"; break;
case 4 : case 6 : case 9 : case 11:
cout<<"it has 30 days"; break;
default : cout<<"it is 31 days"; break;
}

30 Programming with C++


Exercise: Traffic Lights

Implement the program which reads a character from the


user as the indication of color of the traffic light, and send a
comment to the user.

Input : A character indicating color of light ('r','y','g').


Output : "WAIT", "GET READY", "GO" or "WRONG INPUT".

SUMMARY

We need decision structures in order to give direction to the program flow.


We execute or skip a statement block by using simple if statement. If the condition holds then execute, if not
skip the statement block.
We choose one of two options by using an if/else structure. If the condition holds then execute statement block,
if not execute statement block 2.
C++ provides us with three kinds of logical operators in order to combine simple logical expressions and
construct compound complex. The C++ logical operators:
Not Operator (!) is used to get opposite of one expression.
And Operator (&&) is used to get intersection of two expressions.
Or Operator (||) is used to get union area of two expressions.
Conditional Operator (? :) can be used as an alternative of simple if /else.
Several if, if/ else structures can be expressed by a switch structure. If we have the case that an expression
may have constant values, it is best to check them by a switch instead of messy if/else components.

Decision Structures 31
REVIEW QUESTIONS

1. What are the possible four outputs of the following 3. What is the final value of x?
program segment depending on the values of c1
and c2 ? int x=1;
if (c1) if (x >= 0) x += 5;
if (c2) if (x >=5) x += 2;
cout <<"if"<<endl; else x*=3;
else
cout <<"if/else"<<endl;
else if (!c2)
cout <<"?"<<endl;
else
cout <<"switch"<<endl;

c1 c2 Output 4. We have the following code segment:


if ( weight+110 < height )
True True if cout << "normal weight" << endl;
True False else
cout << "over weight" << endl;
False True
False False Which of the following possible values for weight
and height cause the message “over weight” to
be printed?
I. weight = 50, height = 155
II. weight = 80, height = 192
III. weight = 25, height = 125

a) I and II b) II and III


c) I and III d) I, II and III
2. The given code segment copies the bigger of two
variables to the third one. Rewrite it by using
if/else.

With ‘?’ With ‘if/else’

c = (a>b) ? a : b;

32 Programming with C++


5. Which results do logical expressions evaluate with
given values.

a b c Expression Result
5 3 1 c && (a>b) true
0 4 4 (b==c) || a
((!a) && (b!=c)) &&
0 5 4
(b <= c )
4 2 3 (a > b) && (c < a)

6. The ranges of marks in a school as follows :

0 20 F
21 40 D

41 60 C

61 80 B
81 100 A

Does the following program segment automate


the assessment of marks? If not, correct the
program.

if (avg > 0)
mark = F;
else if (avg > 20)
mark = D;
else if (avg > 40)
mark = C;
else if (avg > 60)
mark = B;
else if (avg > 80)
mark = A;

Decision Structures 33
PROGRAMMING PROBLEMS

1. (2nd Degree Equation) Make a program that reads three integers (a, b, c) from a user as coefficients
of a quadratic equation and calculate the solution set (x1, x2) of the equation.

For ax2+bx+c=0

delta = b2-4ac
x1= (- b + sqrt (delta)) /2a
x2= (- b - sqrt (delta)) /2a)
C++ provides us with sqrt() function to perform square root operations. It is defined under <math.h>
library. e.g. x=sqrt(y) x becomes square root of y. Sqrt funtion returns a value type of double.
sample inputs sample outputs
1 3 -10 x1=2 and x2= -5
1 -4 4 x1=2 and x2=2
1 -2 4 No real roots

2. (Mini Calculator) Write a program which reads two integers as operands and a character as an operator
between them, and prints the result.
sample inputs sample outputs
3*7 21
5 - 12 -7
32767 / 1024 31

3. (Character Recognizer) Write a program that reads a character from the user and tells if it is a letter
('a'..'.z', 'A'…'Z'), digit ('1'…'9') punctuation mark ('.','?',',','!' etc.) or special character (other than these).
sample inputs sample outputs
a letter
5 digit
? punctuation mark
/ special character

34 Programming with C++


FLOWCHART PROGRAMMING (OPTIONAL)

Making A Decision
The diamond-shaped symbol is used to make a decision in flowchart programming.
This symbol is unique in that it has two arrows coming out of it, from the right point
and bottom point, one corresponding to Yes or True, and one corresponding to No
or False.

Example: Positive

Make a flowchart that gets an integer and then


prints “Positive” if the integer is bigger than zero.
FCPro Relational and
Equality Operators:
This is a single selection problem. That is how we
> : Greater
should determine whether to print “Positive”. If the
test condition A>0 is satisfied the output symbol is >= : Greater or Equal
executed, otherwise the program simply finishes. < : Smaller
<= : Smaller or Equal
== : Equal
!= : Not Equal

Exercise: Sum

Make a flowchart that gets two numbers (A and B), and then prints the sum of
these numbers (A+B) if the first number is bigger than the second number
(A>B).
input : Two numbers: A and B
output : A + B if A>B

Decision Structures 35
Example: Negative or Positive

Make a flowchart that gets an integer and


then prints “Positive” if the integer is bigger
than zero, and prints “Negative” otherwise.

This is a double selection problem. That is


we should determine whether to print
“Positive” or “Negative”. If the test condition
A>0 is satisfied “Positive” will be printed,
otherwise “Negative” will be printed and the
program finishes.

Exercise: Positive, Negative or Zero

Make a flowchart that gets an integer and then prints “Positive” if the integer
is bigger than zero, and prints “Negative” if the number is smaller than zero, or
prints “Zero” otherwise.
input : A number : A
output : “Positive” if A is bigger than zero
FCPro Logical Operators:
“Negative” if A is less than zero
! : Not
&& : And “Zero” if A is equal to zero
|| : Or

Exercise: Triangle
A C
Make a flowchart that gets three numbers and then determines if these three
numbers represent the length of all sides of a triangle.

B input : Three numbers : A, B and C


output : “Triangle” if A, B and C can represent sides of a triangle.
In a triangle, sum of any two
sides is always larger than the “Not Triangle” if A, B and C cannot represent sides of a triangle.
third side.

36 Programming with C++


Repetition Structures (Loops)
Any computer program is executed sequentially if the programmer doesn't change
the flow of the program. The sequential programs start from the first line of the
program code and execute all the statements one by one until the end of the
program.
There are two kinds of program flow controls: decision structures and repetition
structures.

Decision structures are used to


alter the normal flow of program
execution based on an
evaluation of one or more logical
expressions (condition). We
have already studied decision
structures in the previous
chapter.

Making decisions is a feature


granted to human beings.

Repetition structures are used to


repeat a block of code either a
specific number of times or while
some condition remains true.
For example, "Read 50 items
from the input file" or "While there
are more items in the input file,
continue reading the input."
Loops are everywhere.

Executing a block of code is one of the most basic but useful tasks in programming.
Many programs or Web sites that produce complex output are really only executing
a single task many times.

There are three kinds of repetition structures in C++:


 While
 Do While
 For

38 Programming with C++


The "while" Loop
The "while loop" is the easiest repetition structure to understand for beginners. Its Be careful with infinitive
structure suits the most to the description stated above. loops. An infinitive loop
executes forever without
The structure is made up of a logical condition and the block of code to be repeated. terminating. Usually
First, the condition is evaluated, if it is true the statements in the block of the code incorrectly setting the
are executed, and the condition is evaluated one more time. This process continues termination condition or
until the condition becomes false. The condition must become false at the end; incorrectly increasing or
otherwise we can fall into an infinitive loop. The while loop first checks the condition decreasing the loop-control
variables (counters) causes
and then decides whether executes the statements therefore, it is called a pre- an infinitive loop.
conditional repetition structure.

Let's make a basic program to understand the while loop. The following program
prints the numbers from 1 to 10. It prints the value of a variable (that is a counter)
one at a time, and repeats this process ten times. To print the numbers from 1 to 10,
the variable counter is initialized to one, and its value is increased by 1 in each
iteration. On the other hand, the condition "counter <= 10" checks if the counter
exceeds its final value.
The key concepts of looping are, the counter, the initial value of the counter, the final
value of the counter, increment or decrement factor of the counter, the condition and
the statements to be executed.
The variable "counter" is our counter in this program. Since it gets only the whole
numbers from 1 to 10, its type is integer. The initial value of counter is 1, the final
value of counter is 10, and the increment factor of the counter is 1.
"counter <=10" is the condition of the loop. The while loop checks the condition at
the header of the structure. This condition states that the statement will be executed
while the counter is not bigger than 10.
"cout <<counter<<" ";" is the statement that is executed each time in the looping
process. The purpose of the program is to print the consecutive numbers from 1 to
10 thus the value of the counter must get those values one by one in each turn.

Repetition Structures 39
The following three "counter++" increases the value of counter by one. This statement can be written as
statements are all the same: "counter = counter + 1". C++ used this syntax at the first time. Usually
c++; programmers use only 'c' instead of "counter" as a variable name, so "c++" means
c = c+1;
increase the value of a counter “c” by one. I think, this is where the name of this
programming language is comes from.
c += 1;
/*
PROG: C3_01while.cpp
Printing the numbers from 1 to 10 increasing by 1.
*/
#include <iostream>
using namespace std;
int main()
{
int counter = 1; //initialize the counter to its
//starting value
while (counter <= 10) //continue looping until counter
//is less than its final value
{
cout <<counter<<" "; //print the current value of the
//counter
counter++; //counter gets its next value
}
system("PAUSE"); return 0;
}
Flowchart of the Program
“while”
1 2 3 4 5 6 7 8 9 10 Press any key to continue . . .

Increment and Decrement Operators


C++ provides unary increment (++) and decrement (--) operators. Both operators
can be used after (a++, post-increment) or before (++a, pre-increment) their
operands. If the variable 'a' needs to be incremented by 1, "a++", "a=a+1", or
"a+=1" can be used. The following program demonstrates the use of increment and
decrement operators.
/*
PROG: C3_02inc_dec.cpp
Demonstrating increment and decrement operators
*/
#include <iostream>
using namespace std;

int main()
{
int a=5;
cout <<"initial a is "<<a<<endl;
cout <<"after a++ is "<<a++<<endl;
cout <<"current value of a is "<<a<<endl;
cout <<"after ++a is "<<++a<<endl;

40 Programming with C++


cout <<"current value of a is "<<a<<endl;
cout <<"after --a is "<<--a<<endl;

system("pause"); return 0;
}

initial a is 5
after a++ is 5
current value of a is 6
after ++a is 7
current value of a is 7
after --a is 6
Press any key to continue . . .

Example: Molecules

Calculate the mass of a molecule. A molecule is a chemical structure that is


made up of more then one atom. H2O is the molecule of water. It contains two
hydrogen and one oxygen atoms. The weight of hydrogen is 1, and the weight
of oxygen is 16. Thus the weight of water molecule is 2*1 + 16*1 = 18.
The first line of the input contains an integer (N) that denotes the number of the
atoms in the molecule. Each of the following N lines denotes an atom of the
molecule with two integers. The first integer is the mass of the atom, and the A Water (H2O) Molecule
second integer is the quantity of the atom.

chem.in chem.out

2 18
12
16 1

/*
PROG: c3_03molecules.cpp
*/
#include <fstream>
using namespace std;

int main()
{
int n, weight, quantity;
int sum=0, counter=1;

ifstream fin("chem.in");
ofstream fout("chem.out");

Repetition Structures 41
fin >> n; //How many kinds of atoms?

while (counter <= n)


{
fin >> weight >> quantity;
sum += weight*quantity; //add the weight for the new
//kind of atom.
counter++;
}

fout << sum <<endl;

fin.close();
fout.close();

system("pause");
return 0;

Exercise: Molecules

Modify the program “Molecules” so that it calculates the


weight of a molecule without using any variable as
counter.

Exercise: Train

A train leaves the first station with N passengers and visits K stations before
it arrives at the last station. In each station some passengers got off the train
and some passengers got on the train. Everybody in the train got off at the last
station. Make a program that calculates how many passengers got off the train
at the last station.
The first line of the input has two integers N and K. Each of the following K lines
contains two integers, the first one denotes the number of passengers who got
off the train at that station, and the second one denotes the number of
passengers got on the train at that station. The output should hava a single
integer that is number of passengers who got off the train at the last station.
Input file: train.in
output file: train.out

42 Programming with C++


Sample input Sample output
5 20 40
6 15
5 30
20 12
15 8
6 7

Counter-Controlled and Sentinel-Controlled


Repetitions
Counter-Controlled Repetition
Counter-controlled repetition uses a variable called a "counter" to control the number
of times the statements will be executed. The variable counter must be initialized
before the repetition and must be incremented or decremented during the repetition
process. Counter-controlled repetition is called "definite repetition" because the
number of repetitions is known before the loop begins executing.
The following program calculates a class average with a counter-controlled loop.
/*
PROG: c3_04countercont.cpp
Class average with a counter-controlled loop. Make a program to
calculate average of a class after an exam. There are N students in
the classroom and the marks are between 1 and 5.
*/
#include <iostream>
using namespace std;

int main()
{
int N, total, mark, counter;

//Get number of the marks.


cout<<"How many marks?";
cin >> N;
//Initialize the counter and total.
counter = 1;
total = 0;

//Get the mark one by one and add to total.


while (counter <= N)
{
//Get the next mark.
cout <<"Enter the next mark [1..5]: ";
cin >> mark; Flowchart of the Program
total+=mark; //Add the new mark to total. “countercon”

Repetition Structures 43
counter++; //Increment the counter.
}

float average = (float)total/N; //Calculate the average.

cout<<"The average is "<<average<<endl;

system ("pause");
return 0;
}

How many marks?5


Enter the next mark [1..5]: 4
Enter the next mark [1..5]: 5
Enter the next mark [1..5]: 3
Enter the next mark [1..5]: 4
Enter the next mark [1..5]: 5
The average is 4.2
Press any key to continue . . .

Sentinel-Controlled Repetition
In the case when users don't know the number of the repetitions in advance, a
sentinel-controlled repetition can be used instead of a counter-controlled repetition.
The idea of a sentinel controlled repetition is that there is a special value (the
"sentinel") that is used to say when the loop is done. The sentinel value must be
chosen carefully so that it cannot be confused with a legitimate value. Sentinel-
controlled repetition is called "indefinite repetition" because the number of repetitions
is not known in advance.
/*
PROG: c3_05sentinelcont.cpp
Class average with a sentinel-controlled loop. Make a program to
calculate average of a class after an exam. Your program will
process an arbitrary number of the marks. The marks are between 1
and 5. Use 0 as sentinel value to end the program execution.
*/
#include <iostream>
using namespace std;

int main()
{
int total, mark, nrMarks;
//Get the first mark and set the nrMarks to 1.
cout<<"Enter the first mark: ";
cin >> mark;
total = mark;
nrMarks = 1; //We have got one mark so far.

Flowchart of the Program //Get the rest of the marks one by one and add to total.
“sentinelcont” while (mark != 0) //Continue if mark is not sentinel

44 Programming with C++


{
//Get the next mark.
cout <<"Enter the next mark [1..5] to finish enter 0: ";
cin >> mark;
total+=mark; //Add the new mark to total.
nrMarks++; //Increment the counter.
}

nrMarks--; //Decrease for the sentinel.


float average = (float)total/nrMarks; //Calculate the average.
cout<<"The average is "<<average<<endl;
system ("pause"); Use setprecision function to
return 0; set the precision for floating-
} point values. Setprecision
function is defined in the
iomanip library.
Enter the first mark [1..5] to finish enter 0: 5
Enter the next mark [1..5] to finish enter 0: 3 #include <iomanip>
.
Enter the next mark [1..5] to finish enter 0: 4
.
Enter the next mark [1..5] to finish enter 0: 5 .
Enter the next mark [1..5] to finish enter 0: 3 cout<<"The average is"
Enter the next mark [1..5] to finish enter 0: 5 <<setprecision(3)
Enter the next mark [1..5] to finish enter 0: 0 <<average<<endl;
.
The average is 4.16667 .
Press any key to continue . . . .

The "do/while" Loop


The "do/while" statement is similar to the "while" statement with an important
difference: the "do/while" statement performs a test after each execution of the loop
body. Therefore, the loop body is executed at least once. The "do/while" statement is
usually preferred to design menu-driven programs.
A menu-driven program has
an interface that offers the
user a simple menu from
which to choose an option.
The opposite of menu-driven
is the command-driven.
There usually exists one
option to exit in the menu-
driven programs.
Make your choice:
1. New record
2. Modify
3. Delete
4. Print
5. Exit

Repetition Structures 45
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of The Diamond
Ship
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.

Title: The Diamond Ship

Author: Max Pemberton

Release date: November 18, 2017 [eBook #55993]


Most recently updated: October 23, 2024

Language: English

Credits: Produced by Mardi Desjardins & the online Distributed


Proofreaders Canada team at http://www.pgdpcanada.net

*** START OF THE PROJECT GUTENBERG EBOOK THE DIAMOND


SHIP ***
THE
Diamond Ship

BY
MAX PEMBERTON

CASSELL AND COMPANY, LTD


London, New York, Toronto and Melbourne
1912

To

THE REV. WILLIAM BAKER, D.D.


(LATE HEADMASTER OF MERCHANT TAYLORS’ SCHOOL),

THIS BOOK IS GRATEFULLY INSCRIBED

BY HIS OLD PUPIL.


“He spake, and into every heart his words
Carried new strength and courage.”

ALL RIGHTS RESERVED

CONTENTS.
CHAPTER PAGE

I.—The Preface of Timothy McShanus, Journalist 1

II.—In which Harriet Fabos tells of her Brother’s


Return to Deepdene Hall, in Suffolk 14

III.—In which Harriet Fabos continues her Narrative 20

IV.—Ean Fabos begins his Story 30

V.—The Man with the Three Fingers.—Dr. Fabos


continues his Story 38

VI.—A Challenge from a Woman.—Dr. Fabos joins


his Yacht, “White Wings” 49

VII.—My Friend McShanus.—Dr. Fabos at Dieppe 56

VIII.—We visit Africa.—The Voyage of the “White


Wings” 66

IX.—The Night is not Silent.—The Justification of


Dr. Fabos 72

X.—The Vision of the Ship.—Dr. Fabos proposes to


visit the Azores 81

XI.—Dead Man’s Raft.—The Voyage to the Azores


and an Epistle 94
XII.—Santa Maria.—Dr. Fabos leaves the Yacht,
“White Wings” 99

XIII.—The Cave in the Mountains.—Dr. Fabos makes


Himself acquainted with the Villa San Jorge 113

XIV.—Valentine Imroth.—Dr. Fabos meets the Jew 125

XV.—The Alarm.—Dr. Fabos is made a Prisoner 131

XVI.—At Valley House.—Joan Fordibras makes a


Confession 142

XVII.—The Nine Days of Silence.—Dr. Fabos comes


to Certain Conclusions 151

XVIII.—Down to the Sea.—Dr. Fabos leaves the


Valley House 163

XIX.—In the Meantime.—Dr. Fabos hears the News 175

XX.—The Skies Betray.—A Message comes from


the Diamond Ship 182

XXI.—A Pillar of Light.—“White Wings” Dares a


Venture 200

XXII.—The Crimson Rocket.—Joan Fordibras is


discovered on the Diamond Ship 210

XXIII.—We Defy the Rogues.—And receive an


Ultimatum from Them 218
XXIV.—Dawn.—And some Talk of a Ship that
passed in the Night 228

XXV.—The Thrasher and the Whale.—We determine


to harass the Diamond Ship 233

XXVI.—Seven Days Later.—The Rogues fall out 244

XXVII.—Dr. Fabos Boards the Diamond Ship.—And


learns the Truth there 257

XXVIII.—The Strong Room of the Ocean.—Dr. Fabos


fails to find Joan Fordibras 267

XXIX.—The Bridge and afterwards.—Dr. Fabos visits


Colin Ross 276

XXX.—Joan tells her Story.—And We are


Homeward Bound 298

XXXI.—The End of the Diamond Ship.—Dr. Fabos


turns his Eyes towards England 310

XXXII.—We hear of the Jew again.—Once more in


London 318

XXXIII.—The Master Card.—We visit Canvey Island 328

EPILOGUE.—The Epilogue of Timothy McShanus,


Journalist 346
Transcriber’s Notes can be found at the end of this eBook.

THE DIAMOND SHIP.


CHAPTER I.
THE PREFACE OF TIMOTHY McSHANUS, JOURNALIST.

It would have been at the Fancy Fair and Fête at Kensington


Town Hall that my friend, Dr. Fabos, first met Miss Fordibras. Very
well do I recollect that he paid the price of it for the honourable
company of the Goldsmith Club.
“McShanus,” said he, “if there’s anyone knows his way to a good
supper, ’tis yourself and no other. Lead forth to the masquerade, and
I follow. Spare no expense, McShanus. Your friends are my friends. I
would have this a memorable night—the last I may be in London for
many a year.”
There were seven of us who took him at his word and got into
the cab together. You must know that he had paid for a little dinner
at the Goldsmith Club already, and never a man who did not justice
to his handsome hospitality. The night was clear, and there were
stars in the heavens. I mind me that a little of the dulce and the
desipere moved us to sing “Rule, Britannia” as we went. ’Tis a poor
heart that never rejoices; and Ean Fabos paid for it—as I took the
opportunity to remark to my good friend Killock, the actor.
“Shall we pay for the cab?” says he.
“Would you insult the most generous heart in Great Britain this
night?” says I.
“On reflection,” says he, “the man who does not pay will have no
trouble about his change,” and with that we went into the hall. It is
true that we were a remarkable company. My old comrade, Barry
Henshaw, had come in a velvet shooting coat and a red neckcloth
that was not to the taste of the officials at the box-office. Killock
himself, the darling of the ladies, God bless him, had diamonds
strewn upon his vest thick enough to make a pattern of
chrysanthemums. My own cravat would have been no disgrace to
the Emperor Napoleon. And there we stood, seven members of
seven honourable professions, like soldiers at the drill, our backs to
the wall of the dancing room and our eyes upon the refreshment
buffet.
“’Tis time for a whisky and soda,” says Barry Henshaw, the
famous dramatist, directly his coat was off his back.
“Shame on ye,” says I,—“you that were lapping the poison they
call ‘kummel’ not the half of an hour ago. Beware of the drink, Barry
—the secret habit.”
“Oh,” says he, “then you’re coming with me, I suppose?”
And then he remarked:
“If Fabos were a gentleman he would join the procession and pay
for it. But that’s the worst of these shows. You always lose the man
with the money.”
I passed the observation by as impertinent, and we went to the
buffet. What they called the Fancy Fair was in full swing by this time;
though devil a wig on the green for all their money. Slips of beauty
dressed as shepherdesses mistook me and my friend for their sheep,
and would have fleeced us prettily; but our lofty utterance, coming
of a full heart and two shillings and tenpence in the purse, restrained
their ardour, and sent them to the right-about. ’Twas a fair, be it
told, for the sailor boys at Portsmouth; and when you had bought a
bunch of daisies for ten shillings, of a maid with blue eyes and
cherry lips, you could waltz with the same little vixen at five shillings
a time. My friend Barry, I observed, turned very pale at this
suggestion.
“Do you not lift the sprightly toe?” asked I.
“Man,” he said, “it’s worse than a Channel passage.”
“But Fabos is dancing,” said I, pointing to our host in the midst of
the rabble. “See what comes of the plain living, my boy. He’ll dance
until the sun shines and think nothing of it. And a pretty enough five
shillings’ worth he has on his arm,” I put in as an after-thought.
’Twas odd how we fell to discussing this same Dr. Ean Fabos
upon every occasion that came to us. Was it because of his money—
riches beyond dreams to poor devils who must please the public or
die dishonoured in the market-place? I venture, no. We of the
Goldsmith Club care for no man’s money. Bid the Vanderbilts come
among us, and we lift no hats. ’Tis true that in so far as they assist
the mighty sons of Homer and Praxiteles to meet their just
obligations upon quarter day, they have some use in the world. I
have known circumstances when they have kept precious lives from
the Underground Railway or the Round Pond in Kensington Gardens.
But this is to betray the secrets of my club and of my poor friends
Killock and Barry Henshaw and the rest.
What I was saying was that Ean Fabos’s riches made no more
mark upon us than a lady’s parasol upon the back of a mule. They
said he was a doctor of Cambridge, whose father had made a
fortune out of Welsh coal and then joined his ancestors. My homage
to his consideration, says I. May the warmth of his discovery glow in
many hearts and long blaze in beneficent profusion up the chimneys
of the Goldsmith Club! He has bequeathed us a noble son, whose
dinners are second to none in the empire. Again I say, hats off.
’Twas a gentleman entirely.
But I speak of his son dancing with the little girl in red at the
Fancy Fair at Kensington. Be sure that his six feet one would go
bending to sixty-eight inches and whispering soft things in her ear at
five shillings the waltz, as the programme told ye. And he such a
silent man ordinarily—not to be moved from that rogue of a taciturn
smile we see so often upon his face even when the wit of the club is
worthy of the name we bear. They call Ean Fabos many names.
Some say misogynist; others cynic; a few speak of his lacking heart;
there are those who call him selfish. What’s he to do with all his
money? Do his friends share it? The sacred shrines of Bacchus know
better. He buys diamonds, they say. Just that, great diamonds and
rubies and sapphires, not for a woman’s pretty arms or her white
shoulders, you must know; but to lock up in his safe at his great
house down Newmarket way; to lock up and hide from men and
gloat upon in the silence of the night. That’s what the world says. I’d
add to it that there’s no true charity in all London which has not
benefited secretly by his generous alms. But that is known to few,
and was never known to me until I met the daughter of my friend
Oscroft, the painter; left an orphan as she was in the same unkind
city.
What is it, then, about Ean Fabos that turns all eyes upon him in
whatever company he may be? Some, for sure, hope to borrow
money of him. So much my great heart for humanity must admit.
They hope to borrow money from him and to save him from others
who would do likewise. ’Tis their way of friendship. But, mark ye,
there are many more, strangers to him, enemies because of the
favour he enjoys, and these are on their knees with the rest. What is
it, then? I’ll tell you in a word. ’Tis that great power of what they call
personal magnetism, a power that we can give no right name to, but
must admit whenever we find it. Ean Fabos has it beyond any man I
have known. Let him say three words at a table, and the whole room
is listening. Let him hold his tongue and the people are looking at
him. You cannot pass it by. It grips you with both hands, draws you
forward, compels you to give best. And that’s why men gather about
my friend Dr. Ean Fabos, as they would about the fine gentlemen of
old Greece could they come back to this London of ours. They have
no will of their own while he is among them.
Now, this is the very man whom I saw dancing twice (at five
shillings a time, though naturally the money would be nothing to
him, while much to poor souls who have had their pictures flung into
the mud by the sorry Sassenachs who sit at Burlington House),
dancing twice, I say, with a black-haired shepherdess in a red cloak;
not one that I myself, who have a fine eye for the sex, would have
been lavishing my immortal wit upon; but just a merry bit of
laughing goods that you can sample in any ball-room. When he
surrendered her to her father, a stately old gentleman, stiff as a
poker in the back, and one who reminded me of my dead friend
General von Moltke, of Prussia—when he did this, I say, and I asked
him who she might be, he answered me with the frankness of a boy:
“Timothy McShanus,” says he, “she’s the daughter of General
Fordibras, whose ancestor went to America with the Marquis de
Lafayette. That is the beginning and end of my knowledge. Lead me
forth to the cellar, for I would quench my thirst. Not since I was the
stroke of the great Leander boat at Henley did there drop from my
brow such honest beads of sweat. Man alive, I would not go through
it again for the crown ruby of Jetsapore.”
“Your friend Lafayette was known to my grandfather,” says I,
leading him straight to the buffet, “though I do not remember to
have met him. As for the labour that ye speak of, I would ask you
why you do it if ye have no stomach for it. To dance or not to dance
—shall that be the question? Not for such men as we, Dr. Fabos; not
for those who dwell upon the Olympian heights and would fly higher
if ye could oblige them with the loan——”
He cut me very short, mistaking my words. Not a man who is
given to what is called dramatic gesture, I was much astonished
when he took me by the arm and, leading me away to a corner,
made the strangest confession that ever fell from such a man’s lips.
“I danced with her, McShanus,” said he, “because she is wearing
the bronze pearls that were stolen from my flat in Paris just three
years ago.”
Be sure that I looked hard enough at him.
“Is there but one bronze pearl in the world?” I asked him after a
while of surprise.
He turned upon me that weary smile which intellect may turn
upon curiosity sometimes, and rejoined as one who pitied me.
“There are just ten of that particular shape, McShanus,” says he,
“and she is wearing four of them in the pendant she has upon her
neck. The heart of it is a rose diamond, which once belonged to
Princess Marguerite of Austria. There is a sweet little white sapphire
in the ring she wears that I fancy I remember somewhere, though
the truth of it has gone out of my head. If she will give me another
dance by-and-by I will tell you more perhaps. But do not speculate
upon my actions any further. You have known me long enough to
say that waltzing is not an employment which usually occupies my
attention.”
“’Tis true as all the gospels,” cried I; “and yet, what a story to
hear! Would you have me think that yon bit of a girl is a thief?”
“Oh,” says he, his clear blue eyes full upon me, “does an
Irishman ever give himself time to think? Come, McShanus, use your
wits. If she or her father knew that the jewels were stolen, would
she be wearing them in a ball-room in London?”
“Why, no, she certainly would not.”
“Wrong every time, Timothy McShanus. She would wear them for
mere bravado. That’s what I’ve been telling myself while I danced
with her. If she does not know the truth, her father does.”
“What! The military looking gentleman who so closely resembles
my friend General von Moltke?”
“No other at all. I have my doubts about him. He knows that his
daughter is wearing stolen jewels, but he has not the smallest idea
that I know—either that, or he is clever enough to play Hamlet in a
tam-o’-shanter. Excuse my unwonted agitation, McShanus. This is
really very interesting.”
I could see that he found it so. In all the years I have known
him, never have I seen Ean Fabos so much put about or so little
anxious to escape from his own thoughts. Fine figure of a man that
he was, with great square shoulders hammered out in the rowing
boats, a very Saxon all over him with a curly brown wig and a clean-
shaven chin and boy’s eyes and a man’s heart—that was the body
corporate of Ean Fabos. His mind not a man among us had ever
read. I would have named him yesterday the most careless banker
of his riches and money in the three kingdoms of Ireland, Wales,
and England. And here I found him, set thinking like a philosopher,
because he had stumbled across a few paltry pearls stolen from his
cabinet. Should I alter my opinion of him for that? Devil a bit. ’Twas
the girl of whom he thought, I could see.
So here was Timothy McShanus deserting the baked meats, to
say nothing of his convenient corner in the buffet, to go out and
stare at a red shepherdess with picture books and maizypop to sell.
And what kind of a colleen was it that he saw? Why, nothing out of
the ordinary when viewed from afar. But come a little closer, and you
shall see the blackest and the wickedest pair of eyes that ever
looked out from the face of Venus. ’Tis no common man I am in my
judgment of the sex; but this I will say, that when the girl looked at
me, she found me as red in the face as a soldier at a court-martial.
Not tall above the common; her hair a deep chestnut, running
almost to black; her mouth just a rosebud between two pretty
cheeks; there was something of France and something of America
helping each other to make a wonder of her. Young as she was—and
I supposed her to be about eighteen—her figure would have given
her five years more according to our northern ideas; but I, who
know Europe as I know Pall Mall, said no—she is eighteen,
McShanus, my boy, and America has kept that peach-blossom upon
her cheeks. Had I been mistaken, her voice would have corrected
me. ’Twas a young girl’s voice when she spoke, clear and musical as
the song of silver bells.
“Now won’t you buy a novel?” she said, bustling up to me just
like a bunch of roses. “Here’s Sir Arthur Hall Rider’s very latest—an
autograph copy for one guinea.”
“Me dear,” says I, “’tis Timothy McShanus who reads his own
novels. Speak not of his poor rivals.”
“Why, how clever of you!” says she, looking at me curiously.
“And, of course, your books are the best. Why didn’t you send me
some to sell on my stall?”
“Bedad, and they’re out of print, every won av them,” says I,
speaking the Sassenach’s tongue to her as it should be spoken.
“Here’s the Archbishop and the Lord Chancellor together lamentin’ it.
‘Timothy,’ says his lordship, ‘the great masters are dead, Timothy. Be
up and doing, or we are lost entirely.’ The riches of America could
not buy one of my novels—unless it were that ye found one av them
upon an old bookstall at fourpence.”
She didn’t know what to make of me.
“How strange that I don’t know your name!” says she, perplexed.
“Did they review your novels in the newspapers?”
“My dear,” says I, “the newspaper reviewers couldn’t understand
’em. Be kind to them for it. Ye can’t make a silk purse out a sow’s
ear any more than ye can make black pearls out of lollypops. Could
it be, Timothy McShanus would be driving his own motor-car and
not rejuiced to the back seat of the omnibus. ’Tis a strange world
with more wrong than right in it.”
“You like my pearls, then?” she asked.
I said they were almost worthy of her wearing them.
“Papa bought them in Paris,” she ran on, as natural as could be.
“They’re not black, you know, but bronze. I don’t care a bit about
them myself—I like things that sparkle.”
“Like your eyes,” cried I, searching for the truth in them. For
sure, I could have laughed aloud just now at my friend Fabos’s tale
of her. “Like your eyes when you were dancing a while back with a
doctor of my acquaintance.”
She flushed a hair’s-breadth, and turned her head away.
“Oh, Dr. Fabos? Do you know him, then?”
“We have been as brothers for a matter of ten short years.”
“Is he killing people in London, did you say?”
“No such honourable employment. He’s just a fine, honest,
independent gentleman. Ye’ve nothing much richer in America,
maybe. The man who says a word against him has got to answer
Timothy McShanus. Let him make his peace with heaven before he
does so.”
She turned an arch gaze upon me, half-laughing at my words.
“I believe he sent you here to say so,” cries she.
“Indeed, an’ he did,” says I. “He’s anxious for your good opinion.”
“Why, what should I know of him?” says she, and then, turning
to stare after him, she cried, “There he is, talking to my father. I’m
sure he knows we’re picking him to pieces.”
“Pearls every one,” says I.
“Oh, dad is calling me,” she exclaimed, breaking away upon the
words and showing me as pretty an ankle, when she turned, as I am
likely to behold out of Dublin. A minute afterwards, what should I
see but the General and her walking off with my friend Fabos just as
if they had known him all their lives.
“And may the great god Bacchus, to say nothing of the little
divinities who preside over the baked meats, may they forgive him!”
I cried to Barry Henshaw and the rest of the seven. “He has gone
without leaving us the money for our supper, and ’tis two and
tenpence halfpenny that stands for all the capital I have in this
mortal world.”
We shook our heads in true sorrow, and buttoned our coats
about us. In thirst we came, in thirst must we return.
“And for a bit of a colleen that I could put in my pocket,” says I,
as we tramped from the hall.
But what the others said I will make no mention of, being a
respecter of persons and of the King’s English—God bless him!
CHAPTER II.
IN WHICH HARRIET FABOS TELLS OF HER BROTHER’S RETURN TO
DEEPDENE HALL IN SUFFOLK.

I have been asked to write very shortly what I know of General


Fordibras and of my brother’s mysterious departures from England in
the summer of the year 1904. God grant that all is well with him,
and that these lines will be read by no others than the good friends
who have not forgotten me in my affliction!
It was, I think, in the December of the previous year that he first
met the General in London, as I understood from him, at a
fashionable bazaar at Kensington. This circumstance he related to
me upon his return; and a sister’s interest in Joan Fordibras could
not be but a growing one. I recollect that the General drove over
one day in the spring from Newmarket and took luncheon with us.
He is a fine, stately man, with a marked American accent, and a
manner which clearly indicates his French birth. The daughter I
thought a pretty winsome child; very full of quaint sayings and ideas,
and so unlike our English girls. Ean had spoken of her so often that I
was not prepared for the somewhat distant manner in which he
treated her. Perhaps, in my heart, I found myself a little relieved. It
has always been a sorrow to me to think that one I had loved so
well as brother Ean might some day find my affection for him
insufficient.
General Fordibras, it appears, makes a hobby of yachting. He
lives but little in America, I understand, but much in Paris and the
South. Ean used to be very fond of the sea, but he has given it up so
many years that I was surprised to hear how much a sailor he can
be. His own pet things—the laboratory, the observatory in our
grounds, his rare books, above all, his rare jewels—were but spoken
of indifferently. General Fordibras is very little interested in them;
while his daughter is sufficiently an American to care chiefly for our
antiquities—of which I was able to show her many at Deepdene.
When they left us, it was to return to London, I understood; and
then to join the General’s yacht at Cherbourg.
Ean spoke little to me of these people when they were gone. I
felt quite happy that he made no mention of the daughter, Joan.
Very foreign to his usual habits, however, he was constantly to and
fro between our house and London; and I observed, not without
some uneasiness, that he had become a little nervous. This was the
more remarkable because he has always been singularly fearless and
brave, and ready to risk his own life for others upon the humblest
call. At first I thought that he must be out of health, and would have
had Dr. Wilcox over to see him; but he always resents my attempts
to coddle him (as he calls it), and so I forbore, and tried to find
another reason.
There is no one quicker than a sister who loves to detect those
ailments of the heart from which no man is free; but I had become
convinced by this time that Ean cared nothing for Joan Fordibras,
and that her absence abroad was not the cause of his disquietude.
Of other reasons, I could name none that might be credibly
received. Certainly, money troubles were out of the question, for I
know that Ean is very rich. We had at Deepdene none of those petty
parochial jealousies which are the cause of conflict in certain
quarters. Our lives were quiet, earnest, and simple. What, then, had
come to my brother? Happy indeed had I been if I could have
answered that question.
The first thing that I noticed was his hesitation to leave me alone
at the Manor. For the first time for some years, he declined to attend
the annual dinner of his favourite club, the Potters.
“I should not be able to catch the last train down,” he said one
morning at breakfast; “impossible, Harriet. I must not go.”
“Why, whatever has come to you, Ean?” said I. “Are you getting
anxious about poor old me? My dear boy, just think how often I have
been alone here.”
“Yes, but I don’t intend to leave you so much in future. When the
reasons make themselves known to me, they shall be known to you,
Harriet. Meanwhile, I am going to live at home. The little Jap stops
with me. He is coming down from town to-day, so I hope you will
make arrangements for him.”
He spoke of his Japanese servant Okyada, whom he brought
from Tokio with him three years ago. The little fellow had served him
most faithfully at his chambers in the Albany, and I was not
displeased to have him down in Suffolk. Ean’s words, however,
troubled me greatly, for I imagined that some danger threatened
him in London, and a sister’s heart was beating already to discover
it.
“Cannot you tell me something, Ean?”
He laughed boyishly, in a way that should have reassured me.
“I will tell you something, Harriet. Do you remember the bronze
pearls that were stolen from my flat in Paris more than three years
ago?”
“Of course, Ean; I remember them perfectly. How should I forget
them? You don’t mean to say⁠——”
“That I have recovered them? No—not quite. But I know where
they are.”
“Then you will recover them, Ean?”
“Ah, that is for to-morrow. Let Okyada, by the way, have the
room next to my dressing-room. He won’t interfere with my clothes,
Harriet. You will still be able to coddle me as much as you please,
and, of course, I will always warm the scissors before I cut my nails
in winter.”
He was laughing at me again—a little unjustly, perhaps, as I have
always believed that influenzas and rheums come to those who
allow anything cold to touch the skin—but this is my old womanish
fancy, while Ean is not altogether free himself from those amiable
weaknesses and fads which take some part in all our lives. He, for
instance, must have all his neckties of one colour in a certain
drawer; some of his many clothes must go to the press upon one
day and others upon the next. He buys great quantities of things
from his hosier, and does not wear one half of them. I am always
scolding him for walking about the grounds at night in his dress
clothes; but he never does so without first warming his cloth cap at
the fire, if it be winter. I make mention of these trifles that others
may understand how little there is of real weakness in a very
lovable, manly, and courageous character. Beyond that, as the world
knows well, Ean is one of the greatest linguists and most
accomplished scholars in all Europe.
Now, had I been clever, I should have put two and two together
and have foreseen that what Ean really feared was another attempt
upon the wonderful collection of rare jewels he has made—a
collection the existence of which is known to very few people, but is
accounted among the most beautiful and rare in the country. Ean
keeps his jewels—at least he kept them until recently—in a
concealed safe in his own dressing-room, and very seldom was even
I permitted to peep into that holy of holies. Here again some
eccentricity of a lovable character is to be traced. My brother would
as soon have thought of wearing a diamond in his shirt front as of
painting his face like an Indian; but these hidden jewels he loved
with a rare ardour, and I do truly believe that they had some share
in his own scheme of life. When he lost the bronze pearls in Paris, I
know that he fretted like a child for a broken toy. It was not their
value—not at all. He called them his black angels—in jest, of course
—and I think that he believed some of his own good luck went with
them.
This was the state of things in the month of May when Okyada,
the Japanese, came from London and took up his residence at the
Manor. Ean told me nothing; he never referred again to the subject
of his lost pearls. Much of his time was spent in his study, where he
occupied himself with the book he was writing upon the legends of
the Adriatic. His leisure he gave to his motor and his observatory.
I began to believe that whatever anxiety troubled him had
passed; and in this belief I should have continued but for the
alarming events of which I now write. And this brings me to the
middle of the summer—to be exact, the fifteenth day of June in the
year 1904.
CHAPTER III.
IN WHICH HARRIET FABOS CONTINUES HER NARRATIVE.

Ean, I remember, had come in from a little trip to Cambridge


about five o’clock in the afternoon. We had tea together, and
afterwards he called his servant, Okyada, to the study, and they
were closeted there almost until dinner time. In the drawing-room
later on, Ean proved to be in the brightest of spirits. He spoke,
among other things, of some of his deserted hobbies, and expressed
regret that he had given up his yacht.
“I’m getting old before my time, Harriet,” he said. “The pantaloon
and slippered stage is a tragedy for thirty-three. I think I shall get
another boat, sister. If you are good, I will take you to the Adriatic
again.”
I promised to be very good; and then, laughing together, we
chatted of the old days in Greece and Turkey, of our voyages to
South America, and of sunny days in Spain. I had never seen him
brighter. When we went to bed he kissed me twice, and then said
such an extraordinary thing that I could not help but remember it:
“Okyada and I will be working late in the observatory,” he said;
“there may be one or two men about assisting us. Don’t be afraid if
you hear a noise, Harriet. You will know it’s all right, and that I am
aware of it.”
Now, Ean is so very frank with me usually, looks me so straight in
the face, and tells me so plainly what he means, that his evident
attempt to conceal something from me upon this occasion, his
averted gaze and forced manner, could not but awake my just
curiosity. I did not press him at the moment, but in my own room I
thought much upon it all, and was quite unable to sleep. Books were
of no help to me, nor did my habitual self-composure help me.
Recalling his words, and trying to fit a meaning to them, I went
more than once to my window and looked out over the pleasure
garden beneath it. Deepdene, as many know, is an old Tudor
mansion with three sides of its ancient quadrangle still standing. My
own rooms are in the right-hand wing; the pleasure garden is below
them, and beyond its high wall is the open park which rims right
down to the Bury road. Let me ask anyone what my feelings should
have been, when chancing to look out over the garden at one
o’clock that morning I saw, as plainly as my eyes have ever seen,
the figures of three men crouching beneath the wall and evidently as
fearful of discovery as I was of their presence.
My first impulse, naturally, was to wake Ean and to let him know
what I had seen. No very courageous person at the best, I have
always been greatly afraid of the presence of strange men about the
house, and this visitation at such an hour would surely have alarmed
the bravest. As if to magnify my fears, there was the light of our
observatory shining brightly across the park to tell me plainly that
my brother was still at work, and that the invaluable Okyada must
be with him. My maid, Humphreys, and the poor old butler, Williams,
were my only janissaries, and what could one hope for from them in
such an emergency? I began to say that if the men succeeded in
entering the house, the peril were grave indeed; and then, upon
this, I recollected Ean’s warning, and tried to take comfort of it. Had
he not said that there might be men about the house assisting him?
Why, then, should I be afraid? I will tell you—because it came to me
suddenly that he must have been aware of a probable attack upon
the Manor, and had wished to prepare me for anything the night
could bring forth. There was no other reasonable explanation.
Judge, then, in what a dilemma I found myself. My brother away
at the observatory, half a mile at least from the Manor; two old
servants for my body-guard; a lonely house and strange men
seeking to enter it. Driven this way and that by my thoughts, at first
I said that I would take Ean at his word, and hide away from it all
like a true coward in my bed. This I would have done if the doing of
it had not been unsupportable. I could not lie. My heart was beating
so; every sound so distressed me, that I arose in desperation, and
putting on my dressing gown with trembling fingers, determined to
wake up my maid Humphreys; for, said I, she cannot be more afraid
than I am. Not an over-bold resolution at the best, the execution of
it would never have been attempted had I known what was in store
for me. Shall I ever forget it, if I live a hundred years? The dark
landing when I opened my bedroom door! The staircase with the
great stained window and the moonlight shining down through it!
These could not affright me. It was the whisper of voices I heard
below, the soft tread of feet upon velvet-pile. Ah! those were sounds
I shall ever remember!
The men had entered the house; they were coming upstairs. If I
crossed the dark landing to my maid’s room, assuredly I should
alarm them. These were the reflections as I stood simply paralysed
with fright and unable to utter a single cry or to move from the
place. Step by step I heard the thieves creeping up the stairs until at
last I could see them in the bay of the entresol and tell myself, in
truth, that I was not dreaming. Then I do believe that I half
swooned with terror.
They were coming up step by step to visit and to rob my
brother’s safe, kept in the dressing-room, where the Japanese,
Okyada, usually slept. This much even my agitated mind impressed
upon me. A terrified woman fearing discovery as something which
might bring these men’s vengeance upon her, yet for all the gold in
the world I could not have uttered a single cry. A sense of utter
dread robbed me of all power of will and speech. I could hear my
heart beating so that I thought even they must hear it as they
passed me by. And you shall imagine my feelings when I say that
the rays from the dark lanterns they carried were turned upon the
very door of my bedroom which I had but just shut behind me.
Had they been diverted a hair’s-breadth to the right, they would
have discovered me, standing with my back to the wall, a helpless
and, I do protest, a pitiable figure. But the robbers were too set
upon the jewels to delay for any such unlikely chance, and they
went straight on to my brother’s room; and entering it, to my
surprise, without difficulty, I heard them shut the door and lock it
behind them.
So there I stood, my limbs still trembling, but the spell of
immediate fear already a little removed from me. Dreading discovery
no longer, I crossed the landing silently and entered my maid’s
room. A courageous woman, far braver than her mistress—for she is
of Irish descent, and does not know what the meaning of fear is—
she heard me with as little concern as if I had been ordering her to
go shopping into Cambridge.
“The master’s away in the Park,” she said; “then we must fetch
him, mistress. I’ll go myself. Do you wait here with me until I am
dressed.”
I dreaded being left, and made no scruple to tell her so.
“Why, that’s all right,” she exclaimed, quite cheerily. “I’ll go and
call Williams. They’ll be off fast enough, mistress, if they get the
diamonds. Now, do you just sit here quietly, and think nothing at all
about it. I’ll be there and back like master’s motor-car. Sure, the
impudence of them—to come to this house of all places in the world!
They’ll be robbing Buckingham Palace next!”
She was dressing the while she spoke, and being ready almost
immediately, she put a shawl about her shoulders, and made to set
off through the Park. When she had gone I locked the door—coward
that I was—and sat all alone in the darkness, praying for my
brother’s coming. Indeed, I think that I counted the minutes, and
had come to the belief that Humphreys had been gone a quarter of
an hour—though I make sure now that it was not truly more than
five minutes—when a terrible cry, something so inhuman, so
dreadful, as to be beyond all my experience, rang out through the
house, and was repeated again and again until the very night
seemed to echo it.
What had happened? Had my brother returned, then? Was it his
voice I had heard? Not for a hundred thousand pounds could I have
remained any longer in that dark room with these dreadful questions
for my company—and, unlocking the door, I ran out to the landing,
calling “Ean! Ean! for God’s sake tell me what has happened!”
He answered me at once, my dear brother, standing at the door
of his dressing-room, just, as it seemed to me, as unconcerned as
though he had been called up at daybreak to go out with his dogs
and gun. Quick as he was, however, I had peeped into the room
behind him, and then I saw something which even his cleverness
could not hide from me. A man lay full length upon the floor,
apparently dead. By his side there knelt the Japanese, Okyada, who
chafed the limbs of the sufferer and tried to restore him to
consciousness. This sight, I say, Ean could not conceal from me. But
he shut the door at once, and, leading me away, he tried to tell me
what it was.
“My dear Harriet, you see what comes of touching scientific
implements. Here’s a man who wanted to look inside my safe. He
quite forgot that the door of it is connected up to a very powerful
electric current. Don’t be alarmed, but go back to your bed. Did I
not tell you that there would be strange men about?”
“Ean,” I said, “for pity’s sake let me know the truth. There were
three men altogether. I saw them in the garden; they passed me on
the stairs. They were robbers, Ean; you cannot hide it from me.”
“You poor little Harriet,” he said, kissing me. “Of course they
were robbers. I have been expecting them for a week or more. Did I
tell you I should be in the observatory? That was foolish of me.”
“But there was a light there, dear.”
“Ah, yes; I wished my guests to think me star-gazing. Two of
them are now returning to London as fast as their motor-car can
carry them. The other will remain with us to recuperate. Go back to
bed, Harriet, and tell yourself that all is as well as it could be.”
“Ean,” I said, “you are hiding something from me.”
“My dear sister,” he replied, “does a man in the dark hide
anything from anybody? When I know, you shall be the first to hear.
Believe me, this is no common burglary, or I would have acted very
differently. There are deep secrets; I may have to leave you to
search for them.”
His words astonished me very much. My own agitation could not
measure his recollection or the unconcern which the strange
episodes of the night had left to him. For my part, I could but pass
long hours of meditation, in which I tried to gather up the tangled
skein of this surpassing mystery. When morning came, my brother
had left the house and Okyada with him. I have never seen him
since that day, and his letters have told me little. He is upon a ship,
well and happy, he says, and that ship is his own. His voyages have
taken him to many ports, but he is not yet able to say when he will
return.
“Be assured, dear sister,” he writes, “that the work to which I
have set my hand would be approved by you, and that by God’s help
I shall accomplish it. More I am unable to commit to writing for
prudent reasons. You will keep the guards at the Manor until I am
home, and my valuables will remain at the bank. Fear nothing, then,
for yourself. The fellows who honoured us with their company—two
of them, I should say—are now in South Africa. The third, who was
a gentleman and may again become a man, is now on board this
yacht. If he continues to behave himself, a farm in Canada and a
little capital will be his reward. It is not the instruments but their
makers whom I seek; and when they are found, then, dear Harriet,
will we enjoy halcyon days together.”
To these words he added others, speaking of more private
matters and those which were of concern but to him and to me. By
the “guards” he meant an ex-sergeant-major and two old soldiers
whom he had engaged upon his departure to watch the house in his
absence. For myself, however, I was no longer afraid. Perhaps my
unrest had been less if Ean had been altogether frank with me; but
his vague intimation, the knowledge that he was far from me, and
the inseparable instinct of his danger, contributed alike to my
foreboding.
That these were not without reason subsequent events have fully
justified. I have heard of his yacht as being in the South Atlantic.
There have been rare letters from him, but none that says what
secret it is which keeps him away from me. And for a whole month
now I have received no letter at all. That other friends, unknown to
me personally but staunch to my dear brother, put the worst
construction upon his silence, the recent paragraph in the London
newspapers makes very clear. What can a helpless woman do that
these true friends are not doing? She can but pray to the Almighty
for the safety of one very dear to her—nay, all that she has to live
and hope for in this world of sorrow and affliction.
CHAPTER IV.
EAN FABOS BEGINS HIS STORY.

June 15th, 1904.


So to-night my task begins.
I am to prove that there is a conspiracy of crime so well
organised, so widespread, so amazing in its daring, that the police of
all the civilised countries are at present unable either to imagine or
to defeat it—I am to do this or pay the supreme penalty of failure,
ignominious and irrevocable.
I cannot tell you when first it was that some suspicion of the
existence of this great republic of thieves and assassins first came to
me. Years ago, I asked myself if it were not possible. There has
been no great jewel robbery for a decade past which has not found
me more zealous than the police themselves in study of its methods
and judgment of its men. I can tell you the weight and size almost
of every great jewel stolen, either in Europe or America, during the
past five years. I know the life history of the men who are paying
the penalty for some of those crimes. I can tell you whence they
came and what was their intention should they have carried their
booty away. I know the houses in London, in Paris, in Vienna, in
Berlin where you may change a stolen diamond for money as readily
as men cash a banknote across a counter. But there my knowledge
has begun and ended. I feel like a child before a book whose print it
cannot read. There is a great world of crime unexplored, and its very
cities are unnamed. How, then, should a man begin his studies? I
answer that he cannot begin them unless his destiny opens the
book.
Let me set down my beliefs a little plainer. If ever the story be
read, it will not be by those who have my grammar of crime at their
call, or have studied, as I have studied, the gospel of robbery as
long years expound it. It would be idle to maintain at great length
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like