100% found this document useful (4 votes)
34 views

Instant Access to Computer Programming E. Balagurusamy ebook Full Chapters

Balagurusamy

Uploaded by

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

Instant Access to Computer Programming E. Balagurusamy ebook Full Chapters

Balagurusamy

Uploaded by

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

Download Full Version ebookmass - Visit ebookmass.

com

Computer Programming E. Balagurusamy

https://ebookmass.com/product/computer-programming-e-
balagurusamy/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmass.com


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

Programming in C E. Balagurusamy

https://ebookmass.com/product/programming-in-c-e-balagurusamy/

ebookmass.com

Programming for Problem Solving E Balagurusamy

https://ebookmass.com/product/programming-for-problem-solving-e-
balagurusamy/

ebookmass.com

Problem Solving and Python Programming E. Balagurusamy

https://ebookmass.com/product/problem-solving-and-python-programming-
e-balagurusamy/

ebookmass.com

Amputation in Literature and Film: Artificial Limbs,


Prosthetic Relations, and the Semiotics of "Loss"
(Literary Disability Studies) 1st ed. 2021 Edition Erik
Grayson (Editor)
https://ebookmass.com/product/amputation-in-literature-and-film-
artificial-limbs-prosthetic-relations-and-the-semiotics-of-loss-
literary-disability-studies-1st-ed-2021-edition-erik-grayson-editor/
ebookmass.com
Purpose and Power: US Grand Strategy from the
Revolutionary Era to the Present Stoker

https://ebookmass.com/product/purpose-and-power-us-grand-strategy-
from-the-revolutionary-era-to-the-present-stoker/

ebookmass.com

Night of the Billionaire Wolf Terry Spear

https://ebookmass.com/product/night-of-the-billionaire-wolf-terry-
spear-3/

ebookmass.com

Teaching Public Health Writing Jennifer Beard

https://ebookmass.com/product/teaching-public-health-writing-jennifer-
beard/

ebookmass.com

Kingdom of Exiles Maxym M. Martineau [Martineau

https://ebookmass.com/product/kingdom-of-exiles-maxym-m-martineau-
martineau/

ebookmass.com

Yours To Be: A Fake Engagement, Small Town Romance (Dixon


Creek Ranch Book 3) Emily Silver

https://ebookmass.com/product/yours-to-be-a-fake-engagement-small-
town-romance-dixon-creek-ranch-book-3-emily-silver/

ebookmass.com
Learn Engineering with LEGO: A Practical Introduction to
Engineering Concepts Grady Koch

https://ebookmass.com/product/learn-engineering-with-lego-a-practical-
introduction-to-engineering-concepts-grady-koch/

ebookmass.com
As per
JNTU-Kakinada
Syllabus Regulation
2016

Computer
Programming
About the Author

E Balagurusamy, former Vice Chancellor, Anna University, Chennai and Member, Union Public Service
Commission, New Delhi, is currently the Chairman of EBG Foundation, Coimbatore. He is a teacher, trainer,
and consultant in the fields of Information Technology and Management. He holds an ME (Hons) in Electrical
Engineering and PhD in Systems Engineering from the Indian Institute of Technology (IIT) Roorkee. His
areas of interest include Object-Oriented Software Engineering, E-Governance: Technology Management,
Business Process Re-engineering, and Total Quality Management.
A prolific writer, he has authored a large number of research papers and several books. His best-selling
books, among others include:
∑ Programming in ANSI C, 7/e
∑ Fundamentals of Computers
∑ Computing Fundamentals and C Programming
∑ Programming in Java, 5/e
∑ Programming in BASIC, 3/e
∑ Programming in C#, 3/e
∑ Numerical Methods
∑ Reliability Engineering
∑ Introduction to Computing and Problem Solving using Python, 1e

A recipient of numerous honors and awards, E Balagurusamy has been listed in the Directory of Who's
Who of Intellectuals and in the Directory of Distinguished Leaders in Education.
As per
JNTU-Kakinada
Syllabus Regulation
2016

Computer
Programming

E Balagurusamy
Chairman
EBG Foundation
Coimbatore

McGraw Hill Education (India) Private Limited


CHENNAI

McGraw Hill Education Offices


Chennai New York St Louis San Francisco Auckland Bogotá Caracas
Kuala Lumpur Lisbon London Madrid Mexico City Milan Montreal
San Juan Santiago Singapore Sydney Tokyo Toronto
McGraw Hill Education (India) Private Limited

Published by McGraw Hill Education (India) Private Limited


444/1, Sri Ekambara Naicker Industrial Estate, Alapakkam, Porur, Chennai - 600 116

Computer Programming
Copyright © 2017 by McGraw Hill Education (India) Private Limited.
No part of this publication may be reproduced or distributed in any form or by any means, electronic, mechanical, photocopying,
recording, or otherwise or stored in a database or retrieval system without the prior written permission of the publishers.
The program listings (if any) may be entered, stored and executed in a computer system, but they may not be reproduced for
publication.
This edition can be exported from India only by the publishers,
McGraw Hill Education (India) Private Limited

Print Edition:
ISBN-13: 978-93-5260-388-6
ISBN-10: 93-5260-388-5

Managing Director: Kaushik Bellani


Director—Products (Higher Education and Professional): Vibha Mahajan
Manager—Product Development: Koyel Ghosh
Specialist—Product Development: Sachin Kumar
Head—Production (Higher Education and Professional): Satinder S Baveja
Assistant Manager—Production: Jagriti Kundu
AGM—Product Management (Higher Education and Professional): Shalini Jha
Manager—Product Management: Kartik Arora
General Manager—Production: Rajender P Ghansela
Manager—Production: Reji Kumar

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

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

Cover Printer:

Visit us at: www.mheducation.co.in


Contents

Preface xiii
Roadmap to the Syllabus xvi

Chapter 1 Introduction to Computers and Programming 1.1—1.30


1.1 Introduction 1.1
1.2 Computer Systems 1.2
1.2.1 Input Devices 1.3
1.2.2 CPU 1.5
1.2.3 Output Devices 1.6
1.2.4 Memory 1.8
1.3 History of C 1.12
1.4 Data Types 1.13
1.4.1 Integer Types 1.14
1.4.2 Floating Point Types 1.15
1.4.3 Void Types 1.16
1.4.4 Character Types 1.16
1.5 Programming Languages 1.16
1.5.1 Machine Language (Low Level Languages) 1.16
1.5.2 Assembly Language (Symbolic Language) 1.16
1.5.3 High-Level Languages 1.18
1.6 Development of C Algorithms 1.19
1.6.1 Characteristics of Algorithms 1.20
1.6.2 Advantages of Algorithms 1.20
1.6.3 Disadvantages of Algorithms 1.20
1.7 Software Development Method 1.22
1.7.1 Analysing the Requirements 1.23
1.7.2 Feasibility Analysis 1.23
1.7.3 Creating the Design 1.24
1.7.4 Developing Code 1.24
1.7.5 Testing the Software 1.25
1.7.6 Deploying the Software 1.25
1.7.7 Maintaining the Software 1.25
1.8 Applying Software Development Method 1.25
Key Terms 1.27
Just Remember 1.28
Multiple Choice Questions 1.28
vi Contents

Answers 1.29
Review Questions 1.29

Chapter 2 Basics of C 2.1—2.90


2.1 Importance of C 2.1
2.2 Basic Structure of C Programs 2.1
2.3 Programming Style 2.2
2.4 Executing a ‘C’ Program 2.3
2.5 Sample Programs 2.4
2.5.1 Sample Program 1: Printing a Message 2.4
2.5.2 Sample Program 2: Adding Two Numbers 2.6
2.5.3 Sample Program 3: Interest Calculation 2.8
2.5.4 Sample Program 4: Use of Subroutines 2.10
2.5.5 Sample Program 5: Use of Math functions 2.10
2.6 C Character Set 2.12
2.6.1 Trigraph Characters 2.13
2.7 C Tokens 2.14
2.8 Keywords and Identifiers 2.14
2.9 Operators and Expressions 2.15
2.9.1 Arithmetic Operators 2.15
2.9.2 Relational Operators 2.18
2.9.3 Logical Operators 2.19
2.9.4 Assignment Operators 2.20
2.9.5 Increment and Decrement Operators 2.22
2.9.6 Conditional Operator 2.23
2.9.7 Bitwise Operators 2.25
2.9.8 Special Operators 2.25
2.9.9 Operator Precedence 2.27
2.9.10 Precedence of Arithmetic Operators 2.29
2.9.11 Some Computational Problems 2.30
2.9.12 Type Conversions in Expressions 2.31
2.9.13 Operator Precedence and Associativity 2.34
2.10 Constants 2.36
2.10.1 Integer Constants 2.37
2.10.2 Real Constants 2.38
2.10.3 Single Character Constants 2.38
2.10.4 String Constants 2.39
2.11 Variables 2.40
2.12 Declaration of Variables 2.41
2.12.1 Primary Type Declaration 2.41
2.12.2 User-defined Type Declaration 2.42
2.12.3 Declaration of Storage Class 2.43
2.12.4 Assigning Values to Variables 2.44
Contents vii

2.13 ANSI C Library Functions 2.50


2.14 Managing Input and Output Operations 2.53
2.14.1 Reading a Character 2.54
2.14.2 Writing a Character 2.56
2.14.3 Formatted Input 2.58
2.14.4 Points to Remember while Using scanf 2.65
2.14.5 Formatted Output 2.66
2.15 Case Studies 2.71
Key Terms 2.78
Just Remember 2.79
Multiple Choice Questions 2.80
Answers 2.84
Review Questions 2.84
Debugging Exercises 2.86
Programming Exercise 2.87

Chapter 3 Decision Making, Branching and Looping 3.1—3.70


3.1 Introduction 3.1
3.2 Decision Making with If Statement 3.1
3.2.1 Simple If Statement 3.2
3.2.2 The If.....Else Statement 3.6
3.2.3 Nesting of If....Else Statements 3.9
3.2.4 The Else If Ladder 3.11
3.3 Decision Making with Switch Statement 3.15
3.4 The ? : Operator 3.20
3.5 Decision Making with Goto Statement 3.22
3.6 Introduction to Looping Procedure 3.25
3.6.1 Sentinel Loops 3.26
3.7 The While Statement 3.27
3.8 The Do Statement 3.29
3.9 The For Statement 3.33
3.9.1 Simple ‘for’ Loops 3.33
3.9.2 Additional Features of For Loop 3.37
3.9.3 Nesting of For Loops 3.39
3.10 Jumps In Loops 3.43
3.10.1 Jumping Out of a Loop 3.43
3.11 Case Studies 3.45
Key Terms 3.56
Just Remember 3.57
Multiple Choice Questions 3.58
Answers 3.60
Review Questions 3.61
Debugging Exercises 3.65
Programming Exercises 3.66
viii Contents

Chapter 4 User-Defined Functions 4.1—4.52


4.1 Introduction 4.1
4.2 Need for User-Defined Functions 4.1
4.3 A Multi-Function Program 4.2
4.3.1 Modular Programming 4.4
4.4 Category of Functions 4.5
4.4.1 No Arguments and No Return Values 4.5
4.4.2 Arguments but No Return Values 4.7
4.4.3 Arguments with Return Values 4.10
4.4.4 No Arguments but Returns a Value 4.16
4.4.5 Functions that Return Multiple Values 4.16
4.4.6 Nesting of Functions 4.17
4.5 Elements of User-Defined Functions 4.19
4.6 Definition of Functions 4.19
4.6.1 Function Header 4.20
4.6.2 Name and Type 4.20
4.6.3 Formal Parameter List 4.20
4.6.4 Function Body 4.21
4.7 Return Values and their Types 4.21
4.8 Function Calls 4.22
4.8.1 Function Call 4.24
4.9 Function Declaration 4.24
4.9.1 Prototypes: Yes or No 4.25
4.9.2 Parameters Everywhere! 4.25
4.10 Recursion 4.26
4.10.1 Recursion versus Iteration 4.27
4.11 Passing Arrays to Functions 4.27
4.11.1 One-Dimensional Arrays 4.27
4.11.2 Two-Dimensional Arrays 4.31
4.12 Passing Strings to Functions 4.32
4.12.1 Pass by Value versus Pass by Pointers 4.32
4.13 The Scope, Visibility, and Lifetime of Variables 4.33
4.13.1 Automatic Variables 4.33
4.13.2 External Variables 4.35
4.13.3 External Declaration 4.37
4.13.4 Static Variables 4.39
4.13.5 Register Variables 4.40
4.14 Multifile Programs 4.42
4.15 Case Study 4.43
Key Terms 4.46
Just Remember 4.46
Multiple Choice Questions 4.47
Contents ix

Answers 4.48
Review Questions 4.49
Debugging Exercises 4.51
Programming Exercises 4.51

Chapter 5 Arrays 5.1—5.44


5.1 Introduction 5.1
5.1.1 Data Structures 5.2
5.2 One-Dimensional Arrays 5.2
5.3 Declaration of One-dimensional Arrays 5.3
5.4 Initialization of One-dimensional Arrays 5.6
5.4.1 Compile Time Initialization 5.6
5.4.2 Run Time Initialization 5.7
5.4.3 Searching and Sorting 5.11
5.5 Two-Dimensional Arrays 5.12
5.6 Initializing Two-Dimensional Arrays 5.16
5.6.1 Memory Layout 5.19
5.7 Multi-Dimensional Arrays 5.25
5.8 Dynamic Arrays 5.26
5.9 Case Studies 5.26
Key Terms 5.38
Just Remember 5.38
Multiple Choice Questions 5.39
Answers 5.40
Review Questions 5.40
Debugging Exercises 5.41
Programming Exercises 5.42

Chapter 6 Strings 6.1—6.34


6.1 Introduction 6.1
6.2 Declaring and Initializing String Variables 6.2
6.3 Reading Strings from Terminal 6.3
6.3.1 Using scanf Function 6.3
6.3.2 Reading a Line of Text 6.5
6.3.3 Using getchar and gets Functions 6.6
6.4 Writing Strings to Screen 6.11
6.4.1 Using printf Function 6.11
6.4.2 Using putchar and puts Functions 6.14
6.5 Arithmetic Operations on Characters 6.15
6.6 Putting Strings Together 6.16
6.7 Comparison of Two Strings 6.18
6.8 String-Handling Functions 6.18
6.8.1 strcat() Function 6.18
x Contents

6.8.2 strcmp() Function 6.19


6.8.3 strcpy() Function 6.20
6.8.4 strlen() Function 6.20
6.8.5 Other String Functions 6.22
6.9 Table of Strings 6.24
6.10 Case Studies 6.26
Key Terms 6.30
Just Remember 6.30
Multiple Choice Questions 6.30
Answers 6.31
Review Questions 6.31
Debugging Exercises 6.33
Programming Exercises 6.33

Chapter 7 Pointers 7.1—7.42


7.1 Introduction 7.1
7.2 Understanding Pointers 7.2
7.2.1 Underlying Concepts of Pointers 7.3
7.3 Initialization of Pointer Variables 7.3
7.3.1 Pointer Flexibility 7.4
7.4 Declaring Pointer Variables 7.5
7.4.1 Pointer Declaration Style 7.5
7.5 Accessing the Address of a Variable 7.6
7.6 Accessing a Variable Through its Pointer 7.8
7.7 Chain of Pointers 7.10
7.8 Pointer Expressions 7.11
7.9 Pointer Increments and Scale Factor 7.12
7.9.1 Rules of Pointer Operations 7.13
7.10 Pointers as Function Arguments 7.13
7.11 Functions Returning Pointers 7.16
7.12 Pointers to Functions 7.17
7.12.1 Compatibility and Casting 7.19
7.13 Pointers and Arrays 7.19
7.14 Pointers and Character Strings 7.23
7.15 Array of Pointers 7.25
7.16 Dynamic Memory Allocation 7.26
7.17 Allocating a Block of Memory: Malloc 7.27
7.18 Allocating Multiple Blocks of Memory: Calloc 7.29
7.19 Releasing the Used Space: Free 7.33
7.20 Case Studies 7.33
Key Terms 7.38
Just Remember 7.38
Multiple Choice Questions 7.39
Contents xi

Answers 7.40
Review Questions 7.40
Debugging Exercises 7.42
Programming Exercise 7.42

Chapter 8 Structures and Unions 8.1—8.59


8.1 Introduction 8.1
8.2 Defining a Structure 8.1
8.3 Declaring Structure Variables 8.2
8.3.1 Accessing Structure Members 8.4
8.4 Structure Initialization 8.5
8.5 Arrays of Structures 8.8
8.5.1 Arrays Within Structures 8.11
8.5.2 Structures Within Structures 8.13
8.6 Structures and Functions 8.15
8.6.1 Passing Structure Through Pointers 8.17
8.6.2 Self Referential Structure 8.18
8.7 Pointers and Structures 8.18
8.8 Unions 8.21
8.9 Bit Fields 8.23
8.10 Typedef 8.25
8.11 Command Line Arguments 8.37
8.11.1 Application of Command Line Arguments 8.48
8.12 Case Study 8.50
Key Terms 8.53
Just Remember 8.53
Multiple Choice Questions 8.54
Answers 8.54
Review Questions 8.55
Debugging Exercises 8.57
Programming Exercise 8.58

Chapter 9 Data Files 9.1—9.22


9.1 Introduction 9.1
9.2 Defining and Opening a File 9.2
9.3 Closing a File 9.3
9.4 Input/Output Operations on Files 9.4
9.4.1 The getc and putc Functions 9.4
9.4.2 The getw and putw Functions 9.8
9.4.3 The fprintf and fscanf Functions 9.10
9.5 Error Handling During I/O Operations 9.12
9.6 Random Access to Files 9.14
Key Terms 9.20
xii Contents

Just Remember 9.20


Multiple Choice Questions 9.21
Answers 9.21
Review Questions 9.21
Debugging Exercise 9.22
Programming Exercise 9.22

Appendix 1 C99/C11 Features A1.1—A1.8


Solved Question Paper Nov-Dec 2015 (Set 1— Set 4) SQP1—SQP32
Solved Question Paper May 2016 (Set 1— Set 4) SQP1—SQP29
Preface

INTRODUCTION
Computers plays an increasing important role in today’s world and a sound knowledge of computers has
become indispensable for anyone who seeks employment not only in the area of IT but also in any other
field as well. Computer programming is dedicated to the understanding of computer language, and writing
and testing of programs that computers’ follow to perform their functions. The programs are created using
programming languages and C is the most prevalent, efficient and compact programming language. C
combines the features of a high-level language with the elements of the assembler and is thus close to both
man and machine. The growth of C during the last few years has been phenomenal. It has emerged as the
language of choice for most applications due to its speed, portability and compactness of code. Thus, many
institutions and universities in India have introduced a subject covering Computer Programming.
This book is specially designed for first-year students of Jawaharlal Nehru Technological University
Kakinada (JNTU K) and would enable them to master the necessary skills for programming with C language.
The text has been infused with numerous examples and case studies to empower the learner. Furthermore, the
book also covers design and implementation aspect of data structures using standard ANSI C programming
language.

SIGNIFICANT FEATURES
∑ New! Completely in sync with the syllabus of JNTU Kakinada (2016 Regulation)
∑ New! Incorporates all the features of ANSI C that are essential for a C programmer.
∑ New! Solutions to latest 2015 (Nov/Dec) and 2016 (May) JNTU Kakinada question paper is placed
at the end of the book (All 4 sets)
∑ New! 149 Multiple Choice Questions incorporated at the end of each chapters help students tests
their conceptual understanding of the subject
∑ 22 Case Studies in relevant chapters with stepwise solution to demonstrate real-life applications
∑ New! Updated information on C99/C11 features
∑ New! Topics like ANSI C library functions, Negation, Swapping Values, Recursion v/s Iteration are
covered in detail
∑ Learning by example approach ensures smooth and successful transition from a learner to a skilled
C programmer
∑ Enhanced student-friendly chapter design including Outline, Introduction, Section-end Solved
Programs, Case Studies, Key Terms, Just Remember, Multiple Choice Questions, Review Questions,
Debugging Exercises, Programming Exercises
∑ Special box feature highlighting supplementary information that complements the text.
xiv Preface

PEDAGOGICAL FEATURES
∑ 134 Solved C Programs demonstrate the general principles of good programming style
∑ 171 Review Questions helps in testing conceptual understanding
∑ 28 Debugging Exercise helps in participating coding contests
∑ 179 Programming Exercises simulate interest to practice programming applications

CHAPTER ORGANIZATION
The content is spread across 9 chapters. Chapter 1 introduces computer systems, programming languages
and environment, software development method, and algorithms. Chapter 2 gives an overview of C and
explaining the keywords, identifiers, constants, variables, data types and various case studies on these.
Chapters 3 comprises of decision-making, branching and looping methods. Chapter 4 covers the functions
which are used in C language. Chapter 5 focuses on arrays while Chapter 6 deals with strings. Different
types of pointers and its types are discussed in Chapter 7. Chapter 8 presents structures and unions while
Chapter 9 covers file types and their management. Appendix 1 covers C99/C11 features in detail. In addition
to all this, Solved Question Papers of Nov/Dec 2015 (4 sets) and May 2016 (4 sets) are also given in this
book.

CD RESOURCES
The supplementary CD provided along with the book would help the students master programming language
and write their own programs using Computer programming concepts and data structures. The CD comprises
of the following resources:
∑ New! 2012, 2013, 2014, Jan/Feb 2015 solved question papers
∑ New! Lab Programs as per the new syllabus
∑ Two major programming projects—Inventory and Record Entry & two mini projects—Linked List
and Matrix Multiplication
∑ 100 Programming Exercises and 200 Objective Type Questions aligned as per the new syllabus
∑ 5 Solved Model Question Papers
∑ 79 Additional Solved Programs
∑ Additional content on Matrix Operation

ACKNOWLEDGEMENTS
A number of reviewers took pains to provide valuable feedback for the book. We are grateful to all of them
and their names are mentioned as follows:
S. Krishna Rao Sir CR Reddy College of Engineering, Eluru, Andhra Pradesh
Narasimha Rao Kandula Vishnu Institute of Technology, Bhimavaram, Andhra Pradesh
K. Phani Babu, Chundru Raja Ramesh Sri Vasavi Engineering College, Tadepalligudem, Andhra
Pradesh
Preface xv

Rama Rao Adimalla Lendi Institute of Engineering and Technology, Jonnada,


Andhra Pradesh
S. Rama Sree Aditya Engineering College, Peddapuram, Andhra Pradesh
M V S S Nagendranath Sasi Institute of Technology & Engineering, Tadepalligudem,
Andhra Pradesh
S. Satyanarayana Raghu Engineering College, Dakamarri, Andhra Pradesh
S C Satapathy Anil Neerukonda Institute of Technology and Sciences,
Visakhapatnam, Andhra Pradesh
Ch Vijaya Kumar DVR & Dr. HS MIC College of Technology, Kanchikacherla,
Andhra Pradesh

E Balagurusamy

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

Computer Programming
Revised Course from Academic Year 2016-2017

Unit 1: History and Hardware—Computer hardware, Bits and bytes, Components, Programming
Languages—machine language, assembly language, low-level and high-level languages, procedural and
object-oriented languages, Application and system software, Development of C algorithms, Software
development process

Go to
Chapter 1: Introduction to Computers and Programming

Unit 2: Introduction to C programming, Identifiers, main () function, printf () function, Programming


style, Indentation, Comments, Data types, Arithmetic operations, Expression types, Variables and
declarations, Negation, Operator precedence and associativity, Declaration statements, Initialization
assignment, Implicit type conversions, Explicit type conversions, Assignment variations, Mathematical
library functions, Interactive input, Formatted output, Format modifiers

Go to
Chapter 1: Introduction to Computers and Programming
Chapter 2: Basics of C

Unit 3: Control flow-relational expressions—logical operators, Selection—if-else statement—nested if,


examples—multi-way selection—switch—else-if, examples, Repetition—basic loop structures, Pretest
and post-test loops, Counter-controlled and condition-controlled loops, While statement, For statement,
Nested loops, do-while statement

Go to
Chapter 3: Decision Making, Branching and Looping
Roadmap to the Syllabus xvii

Unit 4: Modular programming: function and parameter declarations, Returning a value, Functions with
empty parameter lists, Variable scope, Variable storage class, Local variable storage classes, Global
variable storage classes, Pass by reference, Passing addresses to a function, Storing addresses variables,
Using addresses, Declaring and using pointers, Passing addresses to a function, Swapping values,
Recursion—mathematical recursion—recursion versus iteration.

Go to
Chapter 4: User-Defined Functions

Unit 5: One-dimensional arrays, Input and output of array values, Array initialization, Arrays as function
arguments, Two-dimensional arrays, Larger dimensional arrays—matrices, String fundamentals, Library
functions, String input and output, String processing

Go to
Chapter 5: Arrays
Chapter 6: Strings

Unit 6: Pointers—concept of a pointer, Initialisation of pointer variables, Pointers as function arguments,


Passing by address, Dangling memory, Address arithmetic, Character pointers and Functions, Pointers to
pointers, Dynamic memory management functions, Command line arguments
Structures—derived types, Structures declaration, Initialization of structures, Accessing structures,
Nested structures, Arrays of structures, structures and functions, Pointers to structures, self-referential
structures, Unions, typedef, bit-fields
Declaring, Opening, and Closing file streams, Reading from and Writing to text files, Random file
access

Go to
Chapter 7: Pointers
Chapter 8: Structures and Unions
Chapter 9: Data Files
Introduction to Computers
1 and Programming

CHAPTER OUTLINE
1.1 Introduction 1.4 Data Types 1.7 Software Development Method
1.2 Computer Systems 1.5 Programming Languages 1.8 Applying Software
1.3 History of C 1.6 Development of C Algorithms Development Method

1.1 INTRODUCTION
The term computer is derived from the word
compute. A computer is an electronic device Data INPUT PROCESS
OUTPUT
Information
that takes data and instructions as an input
from the user, processes data, and provides
useful information known as output. This
cycle of operation of a computer is known as Instructions
the input–process–output cycle and is shown Fig. 1.1 Input–process–output concept
in Fig. 1.1. The electronic device is known as
hardware and the set of instructions is known as software.
A computer consists of various components that function as an integrated system to perform computational
tasks. These components include the following:
Central Processing Unit (CPU) It is the brain of the computer that is responsible for controlling
and executing program instructions.
Monitor It is a display screen, which shows information in visual form.
Keyboard and Mouse These are the peripheral devices used by the computer for receiving inputs
from the user.
Figure 1.2 shows the various components of a computer.
The unique capabilities and characteristics of a computer have made it very popular among its various
users, including engineers, managers, accountants, teachers, students, etc.
Some of the key characteristics of a modern digital computer include, among others the following:
Speed The computer is a fast electronic device that can solve large and complex problems in few
seconds. The speed of a computer generally depends upon its hardware configuration.
Storage capacity A computer can store huge amounts of data in many different formats. The storage
area of a computer system is generally divided into two categories, main memory and secondary storage.
1.2 Computer Programming

Monitor
CPU

Keyboard

Mouse

Fig. 1.2 Components of a computer

Accuracy A computer carries out calculations with great accuracy. The accuracy achieved by a
computer depends upon its hardware configuration and the specified instructions.
Reliability A computer produces results with no error. Most of the computer-generated errors are
in actuality human errors that are instigated by the user itself. Therefore, computers are regarded as
quite trustworthy machines.
Versatility Computers are versatile machines. They can perform varied tasks and can be used for
many different purposes.
Diligence Computers can perform repetitive calculations any number of times with the same level
of accuracy.
These capabilities of computers have enabled us to use them for a variety of tasks. Application areas may
broadly be classified into the following major categories.
1. Data processing (commercial use)
2. Numerical computing (scientific use)
3. Text (word) processing (office and educational use)
4. Message communication (e-mail)
5. Image processing (animation and industrial use)
6. Voice recognition (multimedia)

1.2 COMPUTER SYSTEMS


A computer system comprises of hardware and software components. Hardware refers to the physical
parts of the computer system and software is the set of instructions or programs that are necessary for the
functioning of a computer to perform certain tasks. Hardware includes the following components:
Input devices They are used for accepting the data on which the operations are to be performed.
The examples of input devices are keyboard, mouse and track ball.
Processor Also known as CPU, it is used to perform the calculations and information processing on
the data that is entered through the input device.
Output devices They are used for providing the output of a program that is obtained after performing
the operations specified in a program. The examples of output devices are monitor and printer.
Memory It is used for storing the input data as well as the output of a program that is obtained
after performing the operations specified in a program. Memory can be primary memory as well
as secondary memory. Primary memory includes Random Access Memory (RAM) and secondary
memory includes hard disks and floppy disks.
Introduction to Computers and Programming 1.3

Software supports the functioning of a computer system internally and cannot be seen. It is stored on
secondary memory and can be an application software as well as system software. The application software
is used to perform a specific task according to requirements and the system software is mandatory for running
application software. The examples of application software include Excel and MS Word and the examples of
system software include operating system and networking system.
All the hardware components interact with each other as well as with the software. Similarly, the different
types of software interact with each other and with the hardware components. The interaction between
various hardware components is illustrated in Fig. 1.3.

1.2.1 Input Devices


Input devices can be connected to the computer system using cables. The most commonly used input devices
among others are:

Magnetic Magnetic
Tape Disk

EXTERNAL STORAGE UNITS

Input Input Memory Output Output


Media Unit Unit Unit Media

Arithmetic
Unit

Control
Data and results flow
Unit
Control Instructions to units
Instructions to control unit
CPU

Fig. 1.3 Interaction among hardware components

Keyboard
A standard keyboard includes alphanumeric keys, function keys, modifier keys, cursor movement keys,
spacebar, escape key, numeric keypad, and some special keys, such as Page Up, Page Down, Home, Insert,
Delete and End. The alphanumeric keys include the number keys and the alphabet keys. The function keys
are the keys that help perform a specific task such as searching a file or refreshing a Web page. The modifier
keys such as Shift and Control keys modify the casing style of a character or symbol. The cursor movement
1.4 Computer Programming

keys include up, down, left and right keys and are used to modify the direction of the cursor on the screen.
The spacebar key shifts the cursor to the right by one position. The numeric keypad uses separate keypads for
numbers and mathematical operators. A keyboard is show in Fig. 1.4.

Function Keys
(F1 to F12)
Escape Key
Special Keys

Numeric Keypad

Modifier Keys

Alphanumeric Spacebar Key Cursor Movement


Keys Keys

Fig. 1.4 Keyboard

Mouse
Wheel
The mouse allows the user to select elements on the screen, Right Button
such as tools, icons, and buttons, by pointing and clicking Left Button
them. We can also use a mouse to draw and paint on the
screen of the computer system. The mouse is also known
as a pointing device because it helps change the position of
the pointer or cursor on the screen.
The mouse consists of two buttons, a wheel at the top and
a ball at the bottom of the mouse. When the ball moves, the Fig. 1.5 Mouse
cursor on the screen moves in the direction in which the ball rotates. The left button of the mouse is used to select
an element and the right button, when clicked, displays the special options such as open and explore and shortcut
menus. The wheel is used to scroll down in a document or a Web page. A mouse is shown in Fig. 1.5.

Scanner
A scanner is an input device that converts documents and images as the
digitized images understandable by the computer system. The digitized
images can be produced as black and white images, gray images, or
colored images. In case of colored images, an image is considered
as a collection of dots with each dot representing a combination of
red, green, and blue colors, varying in proportions. The proportions
of red, green, and blue colors assigned to a dot are together called as
color description. The scanner uses the color description of the dots to
produce a digitized image. Fig. 1.6 shows a scanner.
There are the following types of scanners that can be used to
produce digitized images: Fig. 1.6 Scanner
Flatbed scanner It contains a scanner head that moves across a page from top to bottom to read the
page and converts the image or text available on the page in digital form. The flatbed scanner is used
to scan graphics, oversized documents, and pages from books.
Introduction to Computers and Programming 1.5

Drum scanner In this type of scanner, a fixed scanner head is used and the image to be scanned is
moved across the head. The drum scanners are used for scanning prepress materials.
Slide scanner It is a scanner that can scan photographic slides directly to produce files understandable
by the computer.
Handheld scanner It is a scanner that is moved by the end user across the page to be scanned. This
type of scanner is inexpensive and small in size.

1.2.2 CPU
The CPU consists of Control Unit (CU) and ALU. CU stores the instruction set, which specifies the operations
to be performed by the computer. CU transfers the data and the instructions to the ALU for an arithmetic
operation. ALU performs arithmetical or logical operations on the data received. The CPU registers store the
data to be processed by the CPU and the processed data also. Apart from CU and ALU, CPU seeks help from
the following hardware devices to process the data:

Motherboard
It refers to a device used for connecting the CPU with the input and output devices (Fig. 1.7). The components
on the motherboard are connected to all parts of a computer and are kept insulated from each other. Some of
the components of a motherboard are:
Buses Electrical pathways that transfer data and instructions among different parts of the computer.
For example, the data bus is an electrical pathway that transfers data among the microprocessor,
memory and input/output devices connected to the computer. The address bus is connected among
the microprocessor, RAM and Read Only Memory (ROM), to transfer addresses of RAM and ROM
locations that is to be accessed by the microprocessor.
System clock It is a clock used for synchronizing the activities performed by the computer. The
electrical signals that are passed inside a computer are timed, based on the tick of the clock. As a
result, the faster the system clock, the faster is the processing speed of the computer.

Fig. 1.7 A motherboard


1.6 Computer Programming

Microprocessor CPU component that performs the processing and controls the activities performed
by the different parts of the computer. The microprocessor is plugged to the CPU socket placed on the
motherboard.
ROM Chip that contains the permanent memory of the computer that stores information, which
cannot be modified by the end user.

Random Access Memory (RAM)


It refers to primary memory of a computer that stores information and programs, until the computer is used.
RAM is available as a chip that can be connected to the RAM slots in the motherboard.

Video Card/Sound card


The video card is an interface between the monitor and the CPU. Video cards also include their own RAM
and microprocessors that are used for speeding up the processing and display of a graphic. These video cards
are placed on the expansion slots, as these slots allow us to connect the high-speed graphic display cards to
the motherboard. A sound card is a circuit board placed on the motherboard and is used to enhance the sound
capabilities of a computer. The sound cards are plugged to the Peripheral Component Interconnect (PCI)
slots. The PCI slots also enable the connection of networks interface card, modem cards and video cards, to
the motherboard.

1.2.3 Output Devices


The data, processed by the CPU, is made available to the end user by the output devices. The most commonly
used output devices are:

Monitor
A monitor is the most commonly used output device that produces
visual displays generated by the computer (Fig. 1.8). The monitor,
also known as a screen, is connected as an external device using
cables or connected either as a part of the CPU case. The monitor
connected using cables, is connected to the video card placed on the
expansion slot of the motherboard. The display device is used for
visual presentation of textual and graphical information.
The monitors can be classified as cathode ray tube (CRT) monitors
or liquid crystal display (LCD) monitors. The CRT monitors are
large, occupy more space in the computer, whereas LCD monitors
are thin, light weighted, and occupy lesser space. Both the monitors
are available as monochrome, gray scale and color models. However,
the quality of the visual display produced by the CRT is better than Fig. 1.8 Monitor
that produced by the LCD.
Introduction to Computers and Programming 1.7

A monitor can be characterized by its monitor size and resolution. The monitor size is the length of
the screen that is measured diagonally. The resolution of the screen is expressed as the number of picture
elements or pixels of the screen. The resolution of the monitor is also called the dot pitch. The monitor with
a higher resolution produces a clearer image.

Printer
The printer is an output device that is used to produce a hard copy
of the electronic text displayed on the screen, in the form of paper
sheets that can be used by the end user (Fig. 1.9). The printer is an
external device that is connected to the computer system using cables.
The computer needs to convert the document that is to be printed to
data that is understandable by the printer. The printer driver software
or the print driver software is used to convert a document to a form
understandable by the computer. When the computer components are
upgraded, the upgraded printer driver software needs to be installed on Fig. 1.9 Printer
the computer.
The performance of a printer is measured in terms of dots per inch (DPI) and pages per minute (PPM)
produced by the printer. The greater the DPI parameter of a printer, the better is the quality of the output
generated by it. The higher PPM represents higher efficiency of the printer. Printers can be classified based
on the technology they use to print the text and images:
Dot matrix printers Dot matrix printers are impact printers that use perforated sheet to print the
text. The process to print a text involves striking a pin against a ribbon to produce its impression on
the paper.
Inkjet printers Inkjet printers are slower than dot matrix printers and are used to generate high
quality photographic prints. Inkjet printers are not impact printers. The ink cartridges are attached to
the printer head that moves horizontally, from left to right.
Laser printers The laser printer may or may not be connected to a computer, to generate an output.
These printers consist of a microprocessor, ROM and RAM, which can be used to store the textual
information. The printer uses a cylindrical drum, a toner and the laser beam.

Speaker
The speaker is an electromechanical transducer that converts an
electrical signal into sound (Fig. 1.10). They are attached to a computer
as output devices, to provide audio output, such as warning sounds and
Internet audios. We can have built-in speakers or attached speakers in a
computer to warn end users with error audio messages and alerts. The
audio drivers need to be installed in the computer to produce the audio
output. The sound card being used in the computer system decides the
quality of audio that we listen using music CDs or over the Internet.
The computer speakers vary widely in terms of quality and price. The
sophisticated computer speakers may have a subwoofer unit, to enhance
bass output. Fig. 1.10 Speakers
1.8 Computer Programming

Plotter
The plotter is another commonly used output device that is connected to a computer to print large documents,
such as engineering or constructional drawings. Plotters use multiple ink pens or inkjets with color cartridges
for printing. A computer transmits binary signals to all the print heads of the plotter. Each binary signal
contains the coordinates of where a print head needs to be positioned for printing. Plotters are classified on
the basis of their performance, as follows:
Drum plotter They are used to draw perfect circles and other graphic images. They use a drawing
arm to draw the image. The drum plotter moves the paper back and forth through a roller and the
drawing arm moves across the paper.
Flat-bed plotter A flat bed plotter has a flat drawing surface and the two drawing arms that move
across the paper sheet, drawing an image. The plotter has a low speed of printing and is large in size.
Inkjet plotter Spray nozzles are used to generate images by spraying droplets of ink onto the paper
(Fig. 1.11). However, the spray nozzles can get clogged and require regular cleaning, thus resulting in
a high maintenance cost.
Electrostatic plotter As compared to other plotters, an electrostatic plotter produces quality print
with highest speed. It uses charged electric wires and special dielectric paper for drawing.

Control
Buttons

Plotted
Paper

Fig. 1.11 An ink-jet plotter

1.2.4 Memory
The memory unit of a computer is used to store data, instructions for processing data, intermediate results of
processing and the final processed information. The memory units of a computer are classified as primary
memory and secondary memory. Figure 1.12 shows the memory categorization in a computer system.
Introduction to Computers and Programming 1.9

Fig. 1.12 Categorization of memory devices

Primary Memory
The primary memory is available in the computer as a built-in unit of the computer. The primary memory is
represented as a set of locations with each location occupying 8 bits. Each bit in the memory is identified by
a unique address. The data is stored in the machine-understandable binary form in these memory locations.
The commonly used primary memories are:
ROM represents Read Only Memory that stores data and instructions, even when the
computer is turned off. It is the permanent memory of the computer where the contents cannot be
modified by an end user. ROM is a chip that is inserted into the motherboard. It is generally used to
store the Basic Input/Output system (BIOS), which
performs the Power On Self Test (POST).
RAM is the read/write memory unit in
which the information is retained only as long as
there is a regular power supply (Fig. 1.13). When
the power supply is interrupted or switched off, the
information stored in the RAM is lost. RAM is a Integrated
volatile memory that temporarily stores data and chips
applications as long as they are in use. When the
Fig. 1.13 RAM
use of data or the application is over, the content in
RAM is erased.
Cache memory is used to store the data and the related application that was last
processed by the CPU. When the processor performs processing, it first searches the cache memory
and then the RAM, for an instruction. The cache memory is always placed between CPU and the main
memory of the computer system.
1.10 Computer Programming

Table 1.1 depicts some of the key differences between RAM and ROM.

TABLE 1.1 Differences between RAM and ROM


RAM ROM
It is a read/write memory It is a read only memory
It is volatile storage device It is a permanent storage device
Data is erased as soon as power supply is Data remains stored even after power supply
turned off has been turned off
It is used as the main memory of a computer It is used to store Basic input output system
system (BIOS).

Secondary Memory
Secondary memory represents the external storage devices that are connected to the computer. They provide
a non-volatile memory source used to store information that is not in use currently. A storage device is either
located in the CPU casing of the computer or is connected externally to the computer. The secondary storage
devices can be classified as:
The magnetic storage
devices store information that can be read,
erased and rewritten a number of times. These
include floppy disk, hard disk and magnetic tapes
(Fig. 1.14 and Fig. 1.15).
The optical storage
devices are secondary storage devices that use
laser beams to read the stored data. These include Fig. 1.14 Magnetic tape
CD-ROM, rewritable compact disk (CD-RW), and
digital video disks with read only memory (DVD-ROM).

Tracks
Sectors

Fig. 1.15 Magnetic disk


Introduction to Computers and Programming 1.11

Incident laser beam


Reflected laser beam

Fig. 1.16 Optical Disk

Reflective aluminium layer Magneto optical flim

Protective coating

Dielectric
layers

Laser beams

Substrate layer Lens

Fig. 1.17 Magneto-optical disk

The magneto-optical devices


are generally used to store information, such as large programs,
files and backup data (Fig. 1.17). The end user can modify the
information stored in magneto-optical storage devices multiple
times. These devices provide higher storage capacity as they use
laser beams and magnets for reading and writing data to the device.
Examples of magneto-optical devices include Sony MiniDisc,
Maxoptix T5-2600, etc.
USB drive or commonly
known as pen drive is a removable storage device that is interfaced
on the USB port of a computer system (Fig. 1.18). It is pretty Fig. 1.18 USB drive
1.12 Computer Programming

fast and compact in comparison to other storage devices like CD and floppy disk. One of the most
important advantages of a USB drive is that it is larger in capacity as compared to other removable
storage devices. Off late, it has become very popular amongst computer users.

1.3 HISTORY OF C
‘C’ seems a strange name for a programming language. But this strange sounding language is one of the most
popular computer languages today because it is a structured, high-level, machine independent language. It
allows software developers to develop programs without worrying about the hardware platforms where they
will be implemented.
The root of all modern languages is ALGOL, introduced in the early 1960s. ALGOL was the first
computer language to use a block structure. Although it never became popular in USA, it was widely used in
Europe. ALGOL gave the concept of structured programming to the computer science community. Computer
scientists like Corrado Bohm, Guiseppe Jacopini and Edsger Dijkstra popularized this concept during 1960s.
Subsequently, several languages were announced.
In 1967, Martin Richards developed a language called BCPL (Basic Combined Programming Language)

of BCPL and called it simply B. B was used to create early versions of UNIX operating system at Bell
Laboratories. Both BCPL and B were “typeless” system programming languages.
C was evolved from ALGOL, BCPL and B by Dennis Ritchie at the Bell Laboratories in 1972. C uses
many concepts from these languages and added the concept of data types and other powerful features. Since
it was developed along with the UNIX operating system, it is strongly associated with UNIX. This operating
system, which was also developed at Bell Laboratories, was coded almost entirely in C. UNIX is one of the
most popular network operating systems in use today and the heart of the Internet data superhighway.
For many years, C was used mainly in academic environments, but eventually with the release of many
C compilers for commercial use and the increasing popularity of UNIX, it began to gain widespread support
among computer professionals. Today, C is running under a variety of operating system and hardware
platforms.
During 1970s, C had evolved into what is now known as “traditional C”. The language became more popular
after publication of the book ‘The C Programming Language’

community. The rapid growth of C led to the development of different versions of the language that were similar
but often incompatible. This posed a serious problem for system developers.
To assure that the C language remains standard, in 1983, American National Standards Institute (ANSI)
appointed a technical committee to define a standard for C. The committee approved a version of C in
December 1989 which is now known as ANSI C. It was then approved by the International Standards
Organization (ISO) in 1990. This version of C is also referred to as C89.
During 1990’s, C++, a language entirely based on C, underwent a number of improvements and
changes and became an ANSI/ISO approved language in November 1977. C++ added several new
features to C to make it not only a true object-oriented language but also a more versatile language.
During the same period, Sun Microsystems of USA created a new language Java modelled on C and C++.
All popular computer languages are dynamic in nature. They continue to improve their power and scope
by incorporating new features and C is no exception. Although C++ and Java were evolved out of C, the
standardization committee of C felt that a few features of C++/Java, if added to C, would enhance the
usefulness of the language. The result was the 1999 standard for C. This version is usually referred to as C99.
The history and development of C is illustrated in Fig. 1.19.
Introduction to Computers and Programming 1.13

Fig. 1.19 History of C

Although C99 is an improved version, still many commonly available compilers do not support all of the
new features incorporated in C99.

1.4 DATA TYPES


C language is rich in its data types. Storage representations and machine instructions to handle constants
differ from machine to machine. The variety of data types available allow the programmer to select the type
appropriate to the needs of the application as well as the machine.
ANSI C supports three classes of data types:
1. Primary (or fundamental) data types
2. Derived data types
3. User-defined data types
The primary data types and their extensions are discussed in this section. The user-defined data types are
defined in the next section while the derived data types such as arrays, functions, structures and pointers are
discussed as and when they are encountered.
1.14 Computer Programming

All C compilers support five fundamental data types, namely integer (int), character (char), floating point
(float), double-precision floating point (double) and void. Many of them also offer extended data types
such as long int and long double. Various data types and the terminology used to describe them are given
in Fig. 1.20. The range of the basic four types are given in Table 1.2. We discuss briefly each one of them in
this section.

NOTE: C99 adds three more data types, namely _Bool, _Complex, and _Imaginary. See Appendix 1.

PRIMARY DATA TYPES

Integral Type

Integer Character

signed unsigned type char


int unsigned int signed char
short int unsigned short int unsigned char
long int unsigned long int

Floating point Type


void
float double Long double

Fig. 1.20 Primary data types in C

TABLE 1.2 Size and Range of Basic Data Types on 16-bit Machines
Data type Range of values
char –128 to 127
int –32,768 to 32,767
float 3.4e–38 to 3.4e+e38
double 1.7e–308 to 1.7e+308

1.4.1 Integer Types


Integers are whole numbers with a range of values supported by a particular machine. Generally, integers
occupy one word of storage, and since the word sizes of machines vary (typically, 16 or 32 bits) the size of
an integer that can be stored depends on the computer. If we use a 16 bit word length, the size of the integer
value is limited to the range –32768 to +32767 (that is, –215 to +215–1). A signed integer uses one bit for sign
and 15 bits for the magnitude of the number. Similarly, a 32 bit word length can store an integer ranging from
-2,147,483,648 to 2,147,483,647.
Introduction to Computers and Programming 1.15

In order to provide some control over the range of numbers and storage space, C has three classes of
integer storage, namely short int, int, and long int, in both signed and unsigned forms. ANSI C defines
these types so that they can be organized from the smallest
to the largest, as shown in Fig. 1.21. For example, short
short int
int represents fairly small integer values and requires half
the amount of storage as a regular int number uses. Unlike int
signed integers, unsigned integers use all the bits for the
long int
magnitude of the number and are always positive.
Therefore, for a 16 bit machine, the range of unsigned
integer numbers will be from 0 to 65,535. Fig. 1.21 Integer types
We declare long and unsigned integers to increase the range of values. The use of qualifier signed on
integers is optional because the default declaration assumes a signed number. Table 1.3 shows all the allowed
combinations of basic types and qualifiers and their size and range on a 16-bit machine.

NOTE: C99 allows long long integer types. See Appendix 1.

TABLE 1.3 Size and Range of Data Types on a 16-bit Machine


Type Size (bits) Range
char or signed char 8 –128 to 127
unsigned char 8 0 to 255
int or signed int 16 –32,768 to 32,767
unsigned int 16 0 to 65535
short int or
signed short int 8 –128 to 127
unsigned short int 8 0 to 255
long int or
signed long int 32 –2,147,483,648 to 2,147,483,647
unsigned long int 32 0 to 4,294,967,295
32 3.4E – 38 to 3.4E + 38
double 64 1.7E – 308 to 1.7E + 308
long double 80 3.4E – 4932 to 1.1E + 4932

1.4.2 Floating Point Types


Floating point (or real) numbers are stored in 32 bits (on all 16 bit and 32 bit machines), with 6 digits of
precision. Floating point numbers are defined in C by the keyword float. When the accuracy provided by
a float number is not sufficient, the type double can be
used to define the number. A double data type number uses
64 bits giving a precision of 14 digits. These are known float
as double precision numbers. Remember that double type double
represents the same data type that float represents, but with
long double
a greater precision. To extend the precision further, we
may use long double which uses 80 bits. The relationship
among floating types is illustrated Fig. 1.22. Fig. 1.22 Floating-point types
1.16 Computer Programming

1.4.3 Void Types


The void type has no values. This is usually used to specify the type of functions. The type of a function is
said to be void when it does not return any value to the calling function. It can also play the role of a generic
type, meaning that it can represent any of the other standard types.

1.4.4 Character Types


A single character can be defined as a character(char) type data. Characters are usually stored in 8 bits (one
byte) of internal storage. The qualifier signed or unsigned may be explicitly applied to char. While unsigned
chars have values between 0 and 255, signed chars have values from –128 to 127.

1.5 PROGRAMMING LANGUAGES


The operations of a computer are controlled by a set of instructions (called a computer program). These
instructions are written to tell the computer:

The communication between two parties, whether they are machines or human beings, always needs a
common language or terminology. The language used in the communication of computer instructions is
known as the programming language. The computer has its own language and any communication with the
computer must be in its language or translated into this language.
Three levels of programming languages are available. They are:

1.5.1 Machine Language (Low Level Languages)


As computers are made of two-state electronic devices they can understand only pulse and no-pulse
(or ‘1’ and ‘0’) conditions. Therefore, all instructions and data should be written using binary codes
1 and 0. The binary code is called the machine code or machine language.
Computers do not understand English, Hindi or Tamil. They respond only to machine language. Added to
this, computers are not identical in design, therefore, each computer has its own machine language. (However,
the script 1 and 0, is the same for all computers). This poses two problems for the user.
First, it is difficult to understand and remember the various combinations of 1’s and 0’s representing
numerous data and instructions. Also, writing error-free instructions is a slow process.
Secondly, since every machine has its own machine language, the user cannot communicate with other
computers (If he does not know its language). Imagine a Tamilian making his first trip to Delhi. He would
face enormous obstacles as the language barrier would prevent him from communicating.
Machine languages are usually referred to as the first generation languages.

1.5.2 Assembly Language (Symbolic Language)


The Assembly language, introduced in 1950s, reduced programming complexity and provided some
standardization to build an application. The assembly language, also referred to as the second-generation
Introduction to Computers and Programming 1.17

programming language, is also a low-level language. In an assembly language, the 0s and 1s of machine
language are replaced with abbreviations or mnemonic code.
The main advantages of an assembly language over a machine language are:

language.

An assembly language program consists of a series of instructions and mnemonics that correspond to a
stream of executable instructions. An assembly language instruction consists of a mnemonic code followed
by zero or more operands. The mnemonic code is called the operation code or opcode, which specifies the
operation to be performed on the given arguments. Consider the following machine code:
10110000 01100001
Its equivalent assembly language representation is:
mov al, 061h
In the above instruction, the opcode “move” is used to move the hexadecimal value 61 into the processor
register named ‘al’. The following program shows the assembly language instructions to subtract two
numbers:
ORG 500 /Origin of program is location 500
LDA SUB /Load subtrahend to AC
CMA /Complement AC
INC /Increment AC
ADD MIN /Add minuend to AC
STA DIF /Store difference
HLT /Halt computer
MIN, DEC 56 /Minuend
SUB, DEC -2 /Subtrahend
DIF, HEX 0 /Difference stored here
END /End of symbolic program
It should be noted that during execution, the assembly language program is converted into the machine
code with the help of an assembler. The simple assembly language statements had one-to-one correspondence
with the machine language statements. This one-to-one correspondence still generated complex programs.
Then, macroinstructions were devised so that multiple machine language statements could be represented
using a single assembly language instruction. Even today programmers prefer to use an assembly language
for performing certain tasks such as:

language code is stored in ROM


1.18 Computer Programming

1.5.3 High-Level Languages


High level languages further simplified programming tasks by reducing the number of computer operation
details that had to be specified. High level languages like COBOL, Pascal, FORTRAN, and C are more
abstract, easier to use, and more portable across platforms, as compared to low-level programming languages.
Instead of dealing with registers, memory addresses and call stacks, a programmer can concentrate more on
the logic to solve the problem with help of variables, arrays or Boolean expressions. For example, consider
the following assembly language code:
LOAD A
ADD B
STORE C
Using FORTRAN, the above code can be represented as:
C=A+B
The above high-level language code is executed by translating it into the corresponding machine language
code with the help of a compiler or interpreter.
High-level languages can be classified into the following three categories:
Procedure-oriented languages (third generation)

Procedure-oriented Languages
High-level languages designed to solve general-purpose problems are called procedural languages or third-
generation languages. These include BASIC, COBOL, FORTRAN, C, C++, and JAVA, which are designed
to express the logic and procedure of a problem. Although, the syntax of these programming languages
is different, they use English-like commands that are easy to follow. Another major advantage of third-
generation languages is that they are portable. We can use the compiler (or interpreter) on any computer and
create the object code. The following program represents the source code in the C language:
if( n>10)
{
do
{
n++;
}while ( n<50);
}
The third generation programming languages are considered as domain-specific programming languages
because they are designed to develop software applications for a specific field. For example, the third
generation programming language, COBOL, was designed to solve a large number of problems specific to
the business field.

Problem-oriented Languages
Problem-oriented languages are used to solve specific problems and are known as the fourth-generation
languages. These include query Languages, Report Generators and Application Generators which have
simple, English-like syntax rules. Fourth-generation languages (4 GLs) have reduced programming efforts
and overall cost of software development. These languages use either a visual environment or a text
environment for program development similar to that of third-generation languages. A single statement in
Introduction to Computers and Programming 1.19

a fourth-generation language can perform the same task as multiple lines of a third-generation language.
Further, the programmer just needs to drag and drop from the toolbar, to create various items like buttons,
text boxes, labels, etc. Also, the programmer can quickly create the prototype of the software application.
These languages are typically used in the WYSIWYG (What You See Is What You Get) environment
to facilitate faster and convenient application development. Visual Studio is one such environment that
encompasses a number of programming tools as well multiple programming language support to ensure
flexibility to the programmer during application development.

Natural Languages
Natural languages are designed to make a computer to behave like an expert and solve problems. The
programmer just needs to specify the problem and the constraints for problem-solving. Natural languages
such as LISP and PROLOG are mainly used to develop artificial intelligence and expert systems. These
languages are widely known as fifth generation languages.
The programming languages of this generation mainly focus on constraint programming, which is
somewhat similar to declarative programming. It is a programming paradigm in which the programmer only
needs to specify the solution to be found within the constraints rather than specifying the method of finding
the desired solution
The programming languages of this generation allow the users to communicate with the computer system
in a simple and an easy manner. Programmers can use normal English words while interacting with the
computer system.

1.6 DEVELOPMENT OF C ALGORITHMS


Algorithms help a programmer in breaking down the solution of a problem into a number of sequential
steps. Corresponding to each step a statement is written in a programming language; all these statements are
collectively termed as a program.
The following is an example of an algorithm to add two integers and display the result:

Algorithm
Step 1 – Accept the first integer as input from the user.
(num1)
Step 2 – Accept the second integer as input from the user.
(num2)
Step 3 – Calculate the sum of the two integers.
(sum = num1 + num2)
Step 4 – Display sum as the result.

There is a time and space complexity associated with each algorithm. Time complexity specifies the amount
of time required by an algorithm for performing the desired task. Space complexity specifies the amount of
memory space required by the algorithm for performing the desired task. While solving a complex problem,
it is possible to have multiple algorithms for obtaining the required solution. The algorithm that ensures best
time and space trade off should be chosen for obtaining the desired solution.
1.20 Computer Programming

1.6.1 Characteristics of Algorithms


The typical characteristics that are necessary for a sequence of instructions to qualify as an algorithm are the
following:

run infinitely.

1.6.2 Advantages of Algorithms


Some of the key advantages of algorithms are the following:

system using any programming language of user’s choice.

solution.

1.6.3 Disadvantages of Algorithms


Apart from the advantages, algorithms also posses certain limitations, which are

the logic becomes relatively difficult.

Example 1.1

Algorithm
Step 1 - Start
Step 2 – Accept a number from the user (num)
Step 3 – Initialize looping counter i = 2
Step 4 – Repeat Step 5 while i < num
Step 5 – If remainder of num divided by i (num%i) is Zero then goto Step 6 else
goto Step 4
Step 6 - Display “num is not a prime number” and break from the loop
Step 7 – If i = num then goto Step 8 Else goto Step 9
Step 8 – Display “num is a prime number”
Step 9 - Stop
Introduction to Computers and Programming 1.21

Example 1.2

Algorithm
Step 1 - Start
Step 2 – Accept the marks in three subjects from the user (marks1, marks2, marks3)
Step 3 – Calculate average marks using formula, average = (marks1 + marks2 +
marks3)/3
Step 4 – Display the computed average of three subject marks
Step 5 - Stop

Example 1.3 Write an algorithm to determine whether the given year is a leap year or not.

Algorithm
Step 1 - Start
Step 2 – Accept an year value from the user (year)
Step 3 – If remainder of year value divided by 4 (year%4) is 0 then goto Step 4
else goto Step 5
Step 4 – Display “’year’ is a leap year” and goto Step 6
Step 5 – Display “’year’ is not a leap year”]
Step 6 - Stop

Example 1.4

Algorithm
Step 1 - Start
Step 2 – Accept a number from the user (num)
Step 3 – If remainder of num divided by 2 (num/2) is Zero then goto Step 4 else
goto Step 5
Step 4 – Display “num is an even number” and goto Step 6
Step 5 – Display “num is an odd number”
Step 6 - Stop
1.22 Computer Programming

Example 1.5 Write an algorithm to determine whether a given string is a palindrome or not.

Algorithm
Step 1 - Start
Step 2 – Accept a string from the user (str)
Step 3 – Calculate the length of string str (len)
Step 4 – Initialize looping counters left=0, right=len-1 and chk = ‘t’
Step 5 – Repeat Steps 6-8 while left < right and chk = ‘t’
Step 6 – If str(left) = str(right) goto Step 8 else goto step 7
Step 7 – Set chk = ‘f’
Step 8 – Set left = left + 1 and right = right + 1
Step 9 - If chk=’t’ goto Step 10 else goto Step 11
Step 10 – Display “The string is a palindrome” and goto Step 12
Step 11 – Display “The string is not a palindrome”
Step 12 - Stop

1.7 SOFTWARE DEVELOPMENT METHOD


The entire process of software development and implementation involves a series of steps. Each successive
step is dependent on the outcome of the previous step. Thus, the team of software designers, developers and
operators are required to interact with each other at each stage of software development so as to ensure that
the end product is as per the client’s requirements. Figure 1.23 shows the various software development steps:

Analysing the requirements

Feasibility Analysis

Creating the Design

Developing code

Testing the software

Deploying the software

Maintaining the software

Fig. 1.23 Software development steps


Exploring the Variety of Random
Documents with Different Content
found under the new law to measure 231,277 tons, showing a difference of only 7
per cent.
[173] My own firm had somewhere about 100,000 tons of shipping (a large
proportion of which consisted of steam-vessels) under our management engaged
as transports for the Government of France. It was then that I for the first time
met the Emperor. I had occasion to visit Marseilles with regard to the fitting of
some of these ships, and, on my return to Paris, I had an interview with Marshal
Vaillant, the then Minister of War, which led to an audience with his Majesty. I
daresay the Emperor had sent for me to confirm, or otherwise, certain calculations
of his own which he had been making as to the number of ships requisite to
transport a given number of men, and so forth; for, after a long audience, I
remarked at parting, “Sire, you had no need to send for me, as you know more
about ships and their capacity than I do.” The fact is, he was thoroughly master of
the subject, and could tell me to a man the number of troops to be placed on a
given ship, and to an animal the number of horses a ship of 1000 tons could or
should carry from Marseilles to Kaemish; the space required for each, and for their
fodder and water, the height of deck requisite to allow for the toss of the head;
and the important, but not generally known fact, that though a horse must feel its
own weight on its own legs at sea, it must also be slung, for if it lie down the
chances are that it will not be able to get up again. At least, if the Emperor did not
know all about these things when I entered the Tuileries, he was the most apt
scholar I ever met, for he knew all about them before I left. I mention this
circumstance because this audience, subsequently, enabled me to render some
assistance in a matter of far greater importance to both France and England and
to mankind, to which I shall hereafter refer, viz.: the change in the French
navigation laws, which is more to the purpose of this work, than the transport of
troops and horses to a field of slaughter.
[174] Annual circular of W. S. Lindsay & Co. for 1854, quoted in Tooke’s ‘History of
Prices.’
[175] When war was declared, the greater portion of the work of engaging
transports devolved upon the Civil Lord of the Admiralty; and though, perhaps,
few men could have been found more competent for the duty than Captain (now
Admiral Sir Alexander) Milne, who then filled that office, it was impossible for any
one man to get through the work he was expected to do, especially with the
system, or rather want of all system, which then prevailed. From my knowledge of
what took place, I have no hesitation in saying that everything relating to the
engagement of the requisite number of ships, and to the transport of troops and
stores to the Crimea, was a huge chaos; and I fear some serious disaster would
have ensued had the pluck and genius of the nation not come to the rescue in the
mode of conducting affairs at home, as well as, so far as I could ascertain, in the
field of action abroad. At home, there was certainly no organisation, so far as
regards the transport service, or, at best, it was of the most imperfect description.
Stores were shipped without bills of parcels, and, frequently, without bills of
lading; and the current stories, at the time, of the shipload of boots and shoes
which lay at anchor in Balaclava harbour unknown to our authorities, while the
troops were bootless and shoeless; of the tops of mess tables sent to the Crimea
without the legs, and of the guns without carriages, were no exaggerations. The
Admiralty, it is true, were responsible for the transport of the troops; but the Civil
Lord, by whom it was represented, had no control over shipments by either the
Ordnance or by the Medical Departments. A case came under my own knowledge
which would be ludicrous were it not melancholy. One day, when I had occasion to
visit a transport which lay at Woolwich, two gentlemen, when I stepped on board,
were wrangling over the main hatchway. One was from the Ordnance, the other
was evidently in charge of certain medical stores which, with piles of shot and
shell, lay on the wharf ready for shipment. The shot and shell representative
insisted on having his goods in the centre compartment of the vessel because they
were heavy; the other gentleman was as determined to have his physic stored in
the same division of the ship because it was perishable. Each would have his own
way; and, as neither would give way, after an hour’s altercation, they, to the
amazement and horror of the mate of the ship, came to a compromise by ordering
the stores of both departments to be stowed in this one favourite position! It is
needless to state the result; I may just, however, say that when the ship arrived at
the Crimea it was found that the shot and shell had played sad havoc with the
medicine cases, and that the floor of her centre compartment was strewed with
fragments of fragile cases, demolished physic bottles, and countless numbers of
squashed pill-boxes.
[176] When the war ceased, the Transport Board was abolished, and the mode of
conducting this important branch of the public service reverted pretty much to
what it had been previously. The Admiralty found ships for the transport of troops
at home and to our colonies abroad, but a board at the India Office engaged
vessels for all the troops and stores to and from our possessions in the East, while
other departments had their own separate shipping offices; all of which, when
vessels were in demand, were bidding against each other, and also against
another department of the government, the Emigration Office. The rates of freight
were, of course, materially enhanced by this unnecessary competition; and there
would have been the same sad story to tell as in the case of the Crimea, had we
been unfortunately involved in another war. Unable to obtain the necessary reform
by any other means, I, on the 5th of January, 1860, brought the existing state of
affairs under the notice of the House of Commons (see ‘Hansard,’ vol. clviii. pp.
2051-2061), when a committee was unanimously appointed on my motion, “To
inquire into the organisation and management of those branches of the Admiralty,
War Office, India Office, and Emigration Board, by which the business of
transporting, by means of shipping, troops, convicts, emigrants, materials of war,
stores, and any other similar services, is now performed.” After a diligent inquiry
which lasted the whole session, the Committee did me the honour to almost as
unanimously adopt my report. But some time elapsed before a permanent
Transport Board was established, so numerous were the obstacles, or rather
prejudices, which had to be overcome. That board is now, or ought to be,
responsible for the conveyance of all troops and Government stores from their
embarkation until landed at their port of destination.
[177] The Great Republic belonged to the well-known mercantile firm of Messrs.
A. A. Law & Co., of New York. When launched she registered 4000 tons; but,
having unfortunately been partially destroyed by fire shortly after she was built,
her upper deck was removed, thus reducing her size to 3400 tons. Her dimensions
were 305 feet in length, fifty-three feet extreme breadth, and thirty feet depth of
hold. She was fitted with double topsails, an American invention then rare in this
country, but now very common; she had on board a steam-engine of eight horse-
power for working ship, or loading and discharging cargo. She brought 3000 tons
of guano as “ballast” from New York to London, and made the passage to the
Scilly Islands in thirteen days, beating up the English Channel thence against an
easterly gale in three days to the Downs. But, on her arrival in London, where she
was consigned to the care of my firm, I found she was much too large to be
employed, profitably, in any of the ordinary channels of commerce; and, had not
the French Government, then in want of transports for the Crimean War, been
induced, by the large space she afforded for the conveyance of their troops, to
engage her for this purpose, she must have remained long after her arrival
unemployed.
[178] When I was a member of the House of Commons, there was a great brewer,
a most excellent man, who sat close to me on the cross benches, who frequently
complained of the heavy “losses” he sustained in his trade. I was under the
impression that the brewing trade was a very lucrative one, especially to persons
like himself, who conducted it on a gigantic scale, and I was puzzled to understand
how, in the face of such “losses,” he could continue adding vat to vat, and rearing
fresh mountains of beer-barrels every year to his brewery yard. Turning one night
to a mutual friend who knew him more intimately than I did, I asked, in the
simplicity of my heart, if it really was the case that the great establishment of
which our friend was the senior was a losing concern. “It is so,” he answered,
“according to our friend’s way of calculating; for every pound less than 75,000l.
per annum, which is estimated as his share of the net profits, is booked as loss!”
Such must also have been the way in which some of our large shipowners
calculated their “losses” after the repeal of the Navigation Laws.
[179] See ‘Copies of Address to the Queen from owners of British ships and others
interested in the prosperity of British navigation, and of the subsequent
correspondence relating thereto.’ Presented to both Houses of Parliament, by
command, 1859.
[180] Table showing the total amount of French and Spanish tonnage which
entered and cleared in the United Kingdom in the indirect trade, viz., trade with
other countries than France and Spain respectively in each year, from 1853 to
1857 inclusive:—

Entered. Cleared. Total.


France 1853 23,554 85,052 108,606
” 1854 23,284 122,763 146,047
” 1855 24,094 55,164 79,258
” 1856 21,618 79,288 100,906
” 1857 36,401 125,775 162,176
Spain 1853 11,606 20,085 31,691
” 1854 18,681 14,068 32,749
” 1855 6,180 8,883 15,063
” 1856 8,200 4,810 13,010
” 1857 12,720 10,373 23,093

[181]

Entered. Cleared. Total.


France 1853 35,160 23,367 58,527
” 1854 33,955 47,709 81,664
” 1855 104,147 127,630 231,777
” 1856 198,842 152,919 351,761
” 1857 66,845 46,383 113,228
Spain 1853 24,967 109,591 134,558
” 1854 67,051 123,373 190,424
” 1855 91,416 105,166 196,582
” 1856 52,030 102,663 154,693
” 1857 .. .. ..

[182] Act 18 and 19 Vict., chap. vii.


[183]
Coasting Trade of the United Kingdom, 1857.
Nationality of Entered. Cleared.
Vessels.
Sailing Vessels. Steam Sailing Vessels. Steam
Vessels. Vessels.
Vessels. Tons. Vessels. Tons. Vessels. Tons. Vessels. Tons.
Russian 4 1,603 .. .. 5 1,729 .. ..
Swedish 22 3,755 .. .. 22 3,630 .. ..
Norwegian 27 5,580 .. .. 26 5,426 .. ..
Danish 85 9,633 .. .. 85 9,692 .. ..
Prussian 50 9,953 .. .. 44 9,043 .. ..
Mecklenburg-Schwerin 17 3,600 .. .. 19 4,400 .. ..
Hanoverian 30 2,176 .. .. 36 2,448 .. ..
Oldenburg and 4 330 .. .. 4 451 .. ..
Knyphausen
Hamburg 6 694 .. .. 5 689 1 250
Bremen .. .. .. .. .. .. .. ..
Lubeck .. .. .. .. .. .. .. ..
Dutch 47 4,535 2 336 40 4,143 .. ..
Belgian 4 593 .. .. 3 337 5 840
French 4 507 .. .. 9 854 .. ..
Spanish 3 572 .. .. 2 401 .. ..
Portuguese .. .. .. .. 1 95 .. ..
Sardinian .. .. .. .. .. .. .. ..
Tuscan .. .. .. .. .. .. .. ..
Papal 2 381 .. .. .. .. .. ..
Two Sicilies 3 615 .. .. 5 1,080 .. ..
Austrian 1 387 .. .. 4 1,002 .. ..
Greek 1 312 .. .. 2 532 .. ..
America, U.S. 7 4,797 .. .. 12 5,883 .. ..
317 50,023 2 336 324 51,835 6 1090
Vessels, 319. Vessels, 330.
Tons, 50,359. Tons, 52,925.

The Entrances and Clearances of British ships in the same year amounted to
upwards of 80,000,000 tons!!
[184] I have great doubt whether the Board of Trade was justified in making this
statement. The Royal Decree of 10th December, 1852, refers to a Law 9th July,
1841, which I have before me; but, when the differential tonnage duty was
abolished, the Gibraltar merchants presented addresses thanking the authorities
for the restoration of the flag. The ports between the Garonne and the Bidassoa
are, surely, not under similar geographical conditions as either the ports or voyage
between the Hudson and the Columbia.
[185] I really do not see it in that light. British ships would, indeed, have a shorter
voyage from England to California, but they would still be precluded from going
from New York to California viâ the Canal or passage at the Isthmus. The
restriction would continue and would prove even more vexatious, as might be
shown in a variety of ways.
[186] I deny this altogether. I cannot admit that a ship taking a cargo from
Cronstadt to Odessa, thus making almost the circumnavigation of Europe, could be
justly deemed to be making a Coasting voyage, however much Russian municipal
law might declare it to be so.
[187] Table showing the total amount of tonnage of British and Foreign Vessels
respectively, with cargoes and in ballast, entered and cleared in the United
Kingdom in each year, from 1842 to 1857 inclusive.

Years. British. Foreign. Total.


Tons. Tons. Tons.
1842 6,669,995 2,457,479 9,127,474
1843 7,181,179 2,643,383 9,824,562
1844 7,500,285 2,846,484 10,346,769
1845 8,546,090 3,531,215 12,077,305
1846 8,688,148 3,727,438 12,415,586
1847 9,712,464 4,566,732 14,279,196
1848 9,289,560 4,017,066 13,306,626
1849 9,669,638 4,334,750 14,004,388
1850 9,442,544 5,062,520 14,505,064
1851 9,820,876 6,159,322 15,980,198
1852 9,985,969 6,144,180 16,130,149
1853 10,268,323 8,121,887 18,390,210
1854 10,744,849 7,924,238 18,669,087
1855 10,919,732 7,569,738 18,489,470
1856 12,945,771 8,643,278 21,589,049
1857 13,694,107 9,484,685 23,178,792

[188] Table showing the total number and tonnage of Sailing and Steam Vessels
built and registered in the United Kingdom in each year, from 1842 to 1857
inclusive.

Years. Vessels. Tons. Years. Vessels. Tons.


1842 914 129,929 1850 689 133,695
1843 698 83,097 1851 672 149,637
1844 689 94,995 1852 712 167,491
1845 853 23,230 1853 798 203,171
1846 809 125,350 1854 802 196,942
1847 936 145,834 1855 1098 323,200
1848 847 122,552 1856 1150 244,578
1849 730 117,953 1857 1278 250,472

From this it will be seen that the total of such tonnage was in—

1842 129,929
1849 117,953
Decrease 11,976
1850 133,695
1857 250,172
Increase 116,777

[189] Table showing the number and tonnage of registered Sailing and Steam
Vessels (exclusive of river steamers) of the United Kingdom employed in the Home
and Foreign Trade respectively in each year, from 1849 to 1857 inclusive.

Employed in the Home Trade. Employed in the Foreign Trade.


Years. Vessels. Tons. Years. Vessels. Tons.
1849 9,610 719,815 1849 6,694 2,089,037
1850 9,150 721,153 1850 7,235 2,188,420
1851 9,266 764,461 1851 7,411 2,348,892
1852 9,134 768,409 1852 7,580 2,449,364
1853 8,851 774,813 1853 8,357 2,791,224
1854 8,778 748,714 1854 7,418 2,759,120
1855 8,590 748,543 1855 7,957 3,018,951
1856 9,707 787,476 1856 8,551 3,190,011
1857 10,064 860,406 1857 8,100 3,168,105
Employed Home and
partly in the partly in the
Total Number Employed.
Foreign Trade.
1849 1,917 287,490 1849 18,221 3,096,342
1850 1,507 227,639 1850 17,892 3,137,212
1851 1,507 247,582 1851 18,184 3,360,935
1852 1,105 163,111 1852 17,819 3,380,884
1853 998 164,050 1853 18,206 3,730,087
1854 1,211 221,259 1854 17,407 3,729,093
1855 1,281 222,676 1855 17,828 3,990,170
1856 1,012 178,590 1856 19,270 4,156,077
1857 1,164 182,971 1857 19,328 4,211,482

[190] Tonnage entered and cleared with cargoes and in ballast at ports of the
United Kingdom, in 1857 and 1858 respectively.

British. Foreign. Total.


1857 13,691,107 9,484,685 23,178,792
1858 12,891,405 9,418,576 22,309,981
Number and tonnage of Sailing and Steam Vessels built and registered in the
United Kingdom, in 1857 and 1858.

Vessels. Tonnage.
1857 1278 250,472
1858 1000 208,080

[191] Total tonnage of British Vessels entered and cleared with cargoes (including
repeated voyages) in the months of December 1858, and January 1859, as
compared with corresponding months of 1856-7-8.

1856. 1857. 1858. 1859.


December 848,762 853,619 970,174 ..
January .. 678,705 603,393 700,445

[192] As an indication of this progress, it is enough to show how vastly the


exports of British produce had advanced in value in that period. Thus the Foreign
Trade rose from 39,163,407l. in 1847, to 85,039,991l. in 1857, and the Colonial
Trade from 13,686,038l. in 1847, to 37,115,257l. in 1857.
[193] The shipping accounts of the United States of America for the year ended
30th June, 1858, showed a corresponding decline in the employment of United
States tonnage.
The total tonnage entered and cleared of United States ships in the two years
1856-7, and 1857-8, having been

1856-7, 9,302,021 tons.


1857-8, 8,885,675 tons; Decrease 416,346 tons.

[194]

1857. 1858.
£ £
Imports 135,051,444 115,218,811
Exports 122,066,107 116,614,331
257,117,551 231,833,142
231,833,012 Decrease per cent.
Decrease, 1858 25,284,409 9 4-5

Shipping (total entered and cleared in Cargo and Ballast).

Years. Total. British.


Tons. Tons.
1857 23,178,792 13,694,107
1858 22,309,981 12,891,405
CHAPTER XIV.
Further returns of the Board of Trade, and address of the Shipowners’
Society to the electors, 13th April, 1859—Shipowners’ meeting in
London—Character of the speeches at it—Mr. Lindsay proposes an
amendment—Effect of the war between France and Austria—Mr.
Lindsay moves for an inquiry into the burdens on the Shipping
Interest, 31st January, 1860—Report of the Committee thereon—
Views with regard to foreign countries—The Netherlands—The United
States—Generally unsatisfactory state of the intercourse with foreign
nations—The present depression beyond the influence of
Government—General results of Steamers versus Sailing Vessels—
The Committee resists the plan of re-imposing restrictions on the
Colonial Trade—Difficulty of enforcing reciprocity—Want of energy on
the part of the English Foreign Office—Rights of belligerents—
Privateering abolished in Europe; America, however, declining to
accept this proposal—Views of the Committee thereon, and on the
liability of Merchant Shipping—Burden of light dues—Pilotage
Charges made by local authorities now, generally, abolished, as well
as those of the Stade dues—The report of 1860, generally, accepted
by the Mercantile Marine—Magnificent English Merchant Sailing
vessels, 1859-1872—The Thermopylæ—Sir Lancelot and others—
Americans completely outstripped—Equal increase in the number as
well as the excellence of English shipping—Results of the Free-trade
policy.

Besides the statistical returns supplied by the Board of Trade on their


report on the memorial of the Shipowners to her Majesty, this Board,
on the 25th February, 1859, published further returns which were
seized upon by the Shipowners’ Association, and made the basis for
an energetic manifesto addressed to the constituencies of the United
Kingdom at the general election in the spring of 1859.[195]
The returns in question consisted of five
Further returns statements, including the period from 1834 to
of the Board of 1858. They are too voluminous to be given here,
Trade,
but it was clear from them that, if the increase of
the entrances and clearances of British ships at the
and address of ports of the United Kingdom, since the repeal of
the Shipowners’ the Navigation Laws, had been 3,221,767, the
Society to the
increase of foreign ships on the other hand
electors, April
13, 1859. amounted to 5,083,826 tons. To these leading
facts, the Shipowners’ Association, triumphantly,
referred the different constituencies, and, although British ships in
the eight years over which these returns extended, had increased to
a far greater extent than they had in any similar previous period, the
Association pointed to the still greater increase of foreign shipping,
and implored the electors of the leading maritime ports to send such
representatives to the new Parliament, who would be exponents of
the opinions they sought to perpetuate; and who would save British
Shipowners from the certain ruin in their opinion awaiting them, as
was so clearly demonstrated by the “appalling” number of foreign
ships frequenting our ports. Pertinaciously adhering in this
celebrated manifesto to their extreme Protectionist principles, they
now reasserted with confidence, and with a brazen front the more
astonishing, after what they had previously admitted, every doctrine
that had proved to be fallacious, every “fact” which had long since
been shown to have had its origin in the regions of fancy or fiction,
every appeal to be saved from ruin as baseless as the shepherd’s
wolf cry, and every theory as visionary as their own fears; by such
means, hoping to revive a system, which the Legislature and every
class of the community, except themselves, had pronounced to be
neither wise, just, nor beneficial. But, with these principles patent to
the whole world, fully confirmed, too, as they were, by the
extraordinary success resulting from the repeal of the Navigation
Laws, they kept harping on the one string, that foreign shipping
entering and clearing from our ports had, since that period,
increased in a greater ratio than our own, and this one fact produced
to a large extent the desired effect on the maritime portions of the
constituencies.
It was vain to tell them that, under the new policy, we had increased
our shipping to an extent far beyond what had been hitherto
accomplished; or that the nation at large, by obtaining all it required
from foreign nations at materially reduced rates, was greatly and
proportionately benefited by the change. Nor was it of any use to
show that our exports and imports, and, consequently, the general
wealth of the country, had already increased far beyond the most
sanguine hopes of even the Free-traders. To attempt to prove to a
maritime constituency that the more intercourse we had with other
countries the better it would be for us, and that the impoverishment
of our neighbours by restrictive laws was not the best means of
enriching ourselves, was then a mere waste of time, and all such
arguments were, at too many of our seaports, only received with
scorn and ridicule. At all such places, the one fact I have named
carried the day. Among various other seaport representatives who
held Free-trade principles, I lost my seat for the Tynemouth
boroughs; at least, I found such a phalanx of Shipowners arrayed
against me, that I should have had a great struggle to retain it.[196]
However, within a week, I found another seat at Sunderland, and,
though the bulk of the Shipowners there, too, were opposed to my
views, I was returned over my Conservative opponent (the late
George Hudson) by a very large majority.[197] But it fared,
otherwise, with many better men who lost their seats and did not
find others.
The one fact in the Shipowners’ manifesto, apparently, strengthened
their cause in Parliament. I say apparently, because though the new
men were pledged to vote for the removal of all “grievances” in the
shape of peculiar and special burdens and for “reciprocity,” whatever
that might mean, I question if any one of them would have voted for
a reversion of our policy. It was idle to talk about it. “Protection to
native industry” was gone, and gone for ever! England had adopted
a policy which can never be reversed. But the General Shipowners’
Society of London, elated with success, resolved to make one more
determined effort to, at least, restore the Colonial trade to the
vessels of Great Britain, and to induce Parliament to recommend her
Majesty in Council to exclude from our carrying trade the vessels of
those nations which did not reciprocate.
With these objects in view, they invited to their aid
Shipowners’ delegates from all the seaports in the kingdom,
meeting in and every person of influence in and out of
London.
Parliament likely to aid their cause. Another public
meeting was held in the London Tavern, at which Mr. R. W.
Crawford, one of the members for the City, took the chair. I had,
unexpectedly, received an invitation to attend, which I accepted, as
the question to be discussed, apart from my duty to my constituents,
was one in which I had a large personal interest. Knowing, however,
that few persons in the vast assembly which had been got together
agreed with the view I entertained, I took my seat, almost out of
sight, in the rear of the platform. The meeting was, indeed, one of a
most influential character. Many men were there whose cheque for
10,000l. would have passed as freely as a 5l. note, and whose hale
and ruddy countenances did not at all betoken that they were on
“the road to ruin.” Perhaps it was malicious on the part of the ‘Times’
to describe the meeting “as the largest collection of political and
commercial fossils which could be got together in these adverse
days for political antiquarianism;” but it is quite true that their views,
generally, so far as they could be comprehended, were certainly of
an antiquarian character.
Mr. Frederick Somes, the member for Hull, who
Character of the moved the first resolution, declared “that nothing
speeches at it. but ruin could result to the shipping interest,” if the
existing policy was pursued; and Mr. Bramley-
Moore, who seconded it, stated that “the coasting trade was
gradually drifting into the hands of foreigners” (a very extraordinary
statement in the face of the official returns), while he argued that,
“we should have the right of selling to, as well as purchasing from,
the foreigner,” as if any person or any law prevented him from doing
so if he pleased. Mr. George Marshall, one of our largest and most
intelligent shipowners, spoke, from experience, of the depressed
state of British shipping, owing to the “inability to compete with
foreigners;” and Mr. Duncan Dunbar told the meeting, but not in a
doleful tone, for he was the jolliest of men, with the happiest of
countenances, “that the very property he had made by his industry
and hard labour was melting away like snow before the sun.”[198]
It was hopeless to expect that the Legislature would attempt to do
anything, even if they could, for a body of men who, representing a
great national interest, delivered such sentiments as these, and had,
evidently, assembled for the purpose of obliging other people to
make good any losses they might have sustained, if any there were,
during the two previous years, while pocketing in silence, for their
own special benefit, the large profits they had secured during the
Crimean war. What had Government to do with the profits and losses
of Shipowners any more than it had to do with those of any other
branch of trade? Invited, as I had been, to take part in these
deliberations, I felt that I should do wrong were I not, regardless of
any insults to myself, to step forward and attempt to expose the
fallacy of the course pursued by the meeting, especially, as the
Shipowners had grievances which really ought to be redressed, and
to which the Legislature, I felt sure, would readily listen, if properly
appealed to. Shipowners were then, unquestionably, subjected to
various burdens which would never have been imposed upon them
had they not been a protected class, and, as such, supposed to
derive advantages from which other classes of the community were
excluded; burdens, too, I am bound and willing to add, from which
they ought to have been relieved when the Navigation Laws were
repealed.
Feeling, therefore, that the time of this large and
Mr. Lindsay important meeting would be wasted in vain and
proposes an useless resolutions, I stepped forward to the front
amendment.
of the platform, resolved, at all hazards, to endure
every contumely, and, if I could not carry an amendment, which I
saw was altogether hopeless, to at least enter my protest as a
British Shipowner against such subservient and worthless appeals to
the Legislature of our country. My appearance on the front row was
the signal for a yell of derision; and my amendment, which I had
hastily written in pencil, “that a petition be presented to both Houses
of Parliament, praying for an inquiry into the actual condition of
British navigation, and for relief from all peculiar burdens and
restrictions that still fetter maritime enterprise,” was received with
hisses and the loudest and rudest demonstrations of dissatisfaction.
Although these events are matters for history, they are of too
personal a character to be pursued at length; however, that my
readers may form some idea of the feelings of a very large number
of the most influential Shipowners of the period, I furnish in a foot-
note[199] extracts from the report which appeared in the ‘Times’ and
of other journals of the proceedings of this great meeting.
But, even if the Legislature had been disposed to
Effect of the consider the wailings of the Shipowners, or to
war between listen to their unreasonable demands, an event
France and
supervened which for a time changed the aspect
Austria.
of their affairs. Critical questions arose in Europe.
Political relations between France and Austria had become most
unsatisfactory. The Emperor of the French, having recently, by a
member of his family, contracted an alliance with a Princess of the
House of Savoy, welded another political link with the King of
Sardinia, and, on the 1st January, 1860, announced an approaching
rupture with Austria. “A cry of anguish” arose from the provinces of
Lombardy; and all the miseries the Italians, during many years, had
suffered from Austrian domination were suddenly and ostentatiously
paraded before the world. Free Europe witnessed with astonishment
the scene in which the despotic Emperor of the French complained
of the tyranny exercised by another despot in Austria, over a portion
of Austrian subjects, whilst the Emperor of Russia, more despotic
than either, joined in the strange and mysterious confederacy, and
affected sympathy for the down-trodden and oppressed Italians.
It was impossible for Great Britain to remain indifferent while events
so momentous were happening in rapid succession on the continent
of Europe; hence, when Austria summoned Sardinia to disarm, and
the French troops were put in motion to cross the Alps, the English
people, carried away by their sympathies for the oppressed Italians,
and forgetting to inquire “Can grapes come from thorns, or figs from
thistles?” were almost willing to join France and aid her in her real
object, the advancement of the eastern portion of the Empire
towards the Rhine. But, whatever the results of the short but great
war then publicly proclaimed by France and Sardinia against Austria,
its effect, by increasing the demand for shipping, combined with
other causes, proved very salutary to the fortunes of British
Shipowners.
Though England had been startled by the
Mr. Lindsay proceedings on the Continent, and had made
moves for an preparations for any emergency, she happily kept
inquiry into the
clear of “entanglement,” so that Parliament had
burdens on the
Shipping time to direct its attention to other less exciting,
Interest, but to her more important subjects. Under these
January 31, circumstances, I consequently, on the 31st
1860.
January, 1860, renewed my motion,[200] for an
inquiry into the state of our merchant shipping, and the operations
of the burdens and restrictions especially affecting that interest.
After a long and interesting discussion, the House was pleased to
adopt my motion, extending the inquiry into various Acts of
Parliament then in force;[201] and, on the 16th February of that year,
the Committee was appointed:[202] the whole of that session was
devoted to the inquiry, and to the complaints and suggestions of the
Shipowners and other persons interested, who were heard in detail:
no less than 6813 questions were asked, and as many answers given
in reply, and voluminous appendices swelled the Report.
No Committee ever commenced its duty with a
Report of the more fixed determination to grant impartial justice
Committee and remedy any existing evils. I shall not venture
thereon.
to offer an opinion on the Report, as it was drawn
up by myself, at the request of my colleagues. But I ought to state
that the Committee examined most carefully and anxiously, in all its
bearings, the great question with which it had to deal, and enabled
me to prepare a report which was strictly just and thoroughly
exhaustive, and which I hope has rendered unnecessary any further
appeals, at least, on similar grounds, for relief to the Legislature. In
prosecution of their inquiries the Committee examined numerous
persons residing in London and the outports connected with the
shipping interests, many of whom were extensively engaged in the
home, colonial, and foreign trades. They also examined several
officers in various departments of her Majesty’s Government, and
others representing two of the corporations, which exercise trading
powers affecting shipping, so as to more fully elucidate the subjects
with which they were respectively acquainted. They then reviewed in
detail the various measures which had been introduced during the
previous quarter of a century affecting maritime commerce, directing
attention to that part of the evidence which stated that the reason,
why the Coasting trade was not thrown open until 1854, was the
assertion on the part of the officers of Customs that there would be
a difficulty in enforcing effectual regulations to guard the revenue.
Referring to existing treaties, the Committee
Views with remarked that, though the Government of the
reference to Netherlands placed the ships of England,
foreign
ostensibly, on the same footing as Dutch vessels,
countries.
English vessels, however, in consequence of the
regulations of the Dutch East India Company, were
The practically prevented from trading with the
Netherlands.
valuable settlements of the Dutch in the Eastern
seas.
When directing attention to the different nations
The United who still withheld from British ships the
States. advantages of their coasting trade, they could not
fail to notice the often repeated fact, that the
United States of North America not only shut out British vessels from
the carrying of goods in the vast coasting trade of their Atlantic and
Pacific sea-boards, but that British vessels running between New
York and Aspinwall, and between Panama and San Francisco, were
denied the ordinary privileges enjoyed by the American national flag;
and that, thus, the indirect carrying trade between the eastern and
western coast of the United States was, practically, confined to
American shipping, as well as the coasting trade proper.
With regard to British colonial possessions the Committee stated
that, while the coasting trade had been thrown open to foreign
vessels in the British East Indies, Ceylon, the Cape of Good Hope,
and Victoria, the coasting trade of our North American colonies was
still confined to British vessels; foreign ships being, however,
permitted to carry on the inter-colonial trade with our various
possessions.
The Committee, especially, noticed the entire
Generally unanimity of the witnesses whom they had
unsatisfactory examined with regard to the unsatisfactory state of
the laws then regulating international intercourse,
state of the not merely with the United States of America, but
intercourse with also with France, Spain, and Portugal; nor could
foreign nations. they fail to perceive that every witness viewed with
the greatest jealousy the restrictions still imposed
by those nations on our shipping, and further, that we had not been
met by them in that spirit of fairness and reciprocity we had a right
to expect.
So far as regards the great question—the repeal of the Navigation
Laws—into which the Committee inquired minutely and impartially, I
may say that they were, unanimously, of opinion that it would be
impossible to reverse the established policy of Free-trade, and that,
in fact, it would not be to the interests of our Shipowners, if they
had been able to do so. Indeed, the representatives of the then
most conservative ports in the kingdom (Mr. Horsfall for Liverpool,
and Mr. Liddell, now Lord Eslington, one of the members for
Northumberland) were decidedly of opinion that any reversal of our
policy would not merely be prejudicial to the great trading interests
of this country, but, specially so, to those engaged in its maritime
commerce; and, in fact, though they felt the advantages derivable
by reciprocal advantages from foreign nations, they were not
prepared to support an Order in Council against the admission to our
ports of the ships of those nations which did not reciprocate.
While admitting the depressed state of the
The present shipping interest during the previous two or three
depression years, the Committee pointed out that this
beyond the
depression had arisen in great measure from
influence of
Government. causes beyond the reach or province of legislation.
They remarked, for instance, with great force, that
as one-fourth part of the whole coasting trade was then carried on
by means of steam-vessels, while one steamer could accomplish as
much work as five sailing vessels, it must follow that the owners of
the latter would suffer; the result clearly showing that the
depression arose in the north of England ports to a great extent
from causes no government could control. Instancing Sunderland,
they remarked that while in 1852 there were no steamers whatever
engaged in trade at that port, the number of such vessels built there
since that period (between 1852 and 1860) had displaced the
enormous number of 4000 sailing ships, each of 250 tons capacity.
Hence, while the Committee could not but regret the heavy loss thus
entailed on one industrious class of men, many of whom were, no
doubt, totally ruined, it was impossible for them to remedy a state of
things brought about mainly by the progress of science, and one,
moreover, with which the change in our policy had nothing whatever
to do. Indeed, not one of the witnesses examined, although many of
them had been sufferers in this way, proposed to recur to the
absolutely restrictive system in vogue previously to 1850.
When the figures brought forward by the
General results opponents of repeal were closely examined, it
of Steamers appeared that, while the increase of all the sailing
versus Sailing
ships in the United Kingdom had for nine years
vessels.
previously to the change in our Navigation Laws
been only 23½ per cent., the increase of steamers, during the same
period, had been as much as 81 per cent.; but that since then to the
end of 1859, while the increase of sailing ships had been 26½ per
cent., steamers had increased no less than 184 per cent. These were
transient evils against which no legislation could provide; and it was,
therefore, obvious that, instead of attempting to render
remunerative a class of vessels, now obsolete owing to the
improvements of the age, Shipowners would have done better to
direct their attention to the development of the new power, for
which they possessed in vast abundance the requisite materials of
iron and coal: in this way, there could be no doubt that they would
be able to compete successfully with all other nations. In how
remarkable a manner these words have been fulfilled I shall be able
to show when I come to treat of the progress of steam navigation in
the Transatlantic trades. Nor has our success been less remarkable
in our competition with the Swedes and Norwegians, with whom it
was repeatedly alleged we were unable to compete; for they, in
1859, had already become large buyers of ships in our markets, and,
I may add, are still frequently to be found purchasers of British-built
vessels.
The question having now been narrowed to that of
The Committee re-imposing the monopoly of the carrying trade to
resists the plan and from our Colonial possessions, the Committee
of re-imposing
soon arrived at the conclusion that the extent,
restrictions on
the Colonial diversified interests, and increasing power of our
Trade. possessions abroad, offered insuperable obstacles
to the re-imposition of restrictions on that trade,
while the daily increase of feelings of independence in our Colonies
naturally tended to resist a system which would place the grower of
British plantation sugar and coffee in the West Indies at a greater
disadvantage than then existed, especially when compared with the
producer of slave-grown sugar and coffee in Brazil and Cuba. The
Committee, therefore, looking to our relations with Canada, our
possessions in the East and West Indies, and, above all, in Australia,
considered it their duty, unhesitatingly, to declare that any proposal
having for its object the re-establishing an exclusive monopoly of the
carrying trade to and from our colonial possessions must, both on
political and commercial grounds, be rejected as altogether
impracticable. Moreover, that, while such a step would be unjust to
our fellow-subjects in the colonies, it would very likely embroil us
with those foreign Powers to whom we were bound by existing
treaties.
The question, however, of the expediency of
Difficulty of requiring foreign Powers, having colonial
enforcing possessions, to reciprocate every advantage to us,
reciprocity.
which Great Britain had accorded unconditionally
to them, though, commercially, when compared with other branches
of commerce, unimportant, was one which demanded peculiar
attention, as it was, and still is, a source of great annoyance, in that
it creates a feeling that we have been very illiberally, if not unjustly,
dealt with by these Powers. British Shipowners who, carried on the
restricted and scarcely tolerated intercourse with the colonies of
France, Spain, and Portugal, found their ships placed at an immense
disadvantage, in the unequal competition they had to encounter,
while they had the mortification to see foreign ships resort to our
own colonies and secure much higher freights than our own ships
when chartered to a port in Europe.[203]
For instance, it was given in evidence that Spanish vessels were
chartered in English ports to Manilla at 3l. or 4l. per ton, while the
British vessel could not obtain 30s. per ton. From the Mauritius to
Europe a French ship, enjoying the option of both the British and
French markets, obtained a freight for sugar of 3l. 10s. per ton at a
time when English ships were obliged to accept 10s. per ton. Thus,
in all our colonies and possessions, French, Spanish, and Portuguese
vessels[204] could generally procure a freight greatly in excess of
that obtained by British ships, as the foreign national flag secured
for them, on arrival at a port of call in England, the advantage of our
markets, with the option of sending on the cargo to the respective
countries of Europe to which the national flag belonged, but from
which markets such produce was excluded by heavy differential
duties, if conveyed thither in British ships.
The Committee naturally felt that a sense of justice demanded that
our Shipowners should, as far as practicable and consistent with the
interests of the community, be placed on equal
Want of energy terms in the race of competition, and that,
on the part of whatever difficulties might stand in the way of
the English
having recourse to retaliatory measures, there had
Foreign Office.
been, they regretted to state, an apparent apathy
on the part of the executive government, in remonstrating with
those nations which then excluded our vessels from their trade; in
other words, that the Foreign Office had not employed the influence
it might have exercised to secure, by diplomatic negotiation, the
advantages of reciprocity.
As the question of belligerent rights at sea was
Rights of one which deeply affected alike the British
belligerents. Shipowner in the prosecution of his business and
the general interests of Great Britain, the
Committee devoted their especial attention to the evidence
advanced on this important question.
In the recent war with Russia, England, as we
Privateering have already incidentally noticed, when she formed
abolished in an alliance with France, agreed with that country
Europe;
to waive her right to confiscate an enemy’s goods
on board neutral ships as also neutral goods found on board an
enemy’s, so long as they were not, in either case, contraband of war.
This mutual but provisional waiver of belligerent rights placed the
allies in harmonious action, and, practically, countenanced the
principle that “free ships make free goods.” Upon the return of
peace, as I have explained in a previous portion of this work, the
declaration of Paris of April, 1856, signed by Austria, France, Great
Britain, Prussia, Russia, Sardinia, and Turkey gave a formal sanction
to this principle. Privateering was also abolished.
America was invited to be a party to this general
America, international agreement, but demurred, and
however, coupled at first her assent to the abolition of
declining to
privateering, with the condition that private
accept this
proposal. property at sea should no longer be subject to
capture. Finally, she refused to be a party to a
Views of the convention, whereby she would be precluded from
Committee resorting to her merchant marine for privateering
thereon,
purposes, in case she became a belligerent. But
this, in the opinion of the Committee, was not surprising, as the
United States had obtained the recognition of the rights of neutrals,
for which she contended throughout a long period of hostilities, and
Great Britain had surrendered those rights without any equivalent
from her. The Committee were therefore of opinion that our
Shipowners would thereby be placed at an immense disadvantage in
the event of a war breaking out with any important European Power.
Indeed, they went so far as to give it as their deliberate conviction
that “the whole of our carrying trade in the event of a great
European war would be inevitably transferred to American and other
neutral bottoms.”
“We must therefore,” they continued, “either secure the general
consent of all nations to establish the immunity of merchant ships
and their cargoes from the depredations of both privateers and
armed national cruisers during hostilities, or we must revert to the
maintenance of our ancient rights, whereby, relying upon our
maritime superiority, we may not merely hope to guard unmolested
our merchant shipping in the prosecution of their business, but may
capture enemy’s goods in neutral ships, and thus prevent other
nations from seizing the carrying trade of this kingdom during a
state of hostility.”
Looking at this important question in all its bearings, and considering
that we have at all times a much larger amount of property afloat
than any other nation, the Committee were of opinion, that, though
grave objections had been urged by high authorities against any
further step in advance, they could not close their remarks without
expressing an earnest hope, and, at the same time, giving it as a
deliberate opinion, that “in the progress of civilisation, and in the
cause of humanity, the time had arrived when all private property
(not contraband of war) should be exempt from capture at sea.”
Having reviewed the question of liability, of which
and on the many Shipowners had complained, the Committee
liability of were of opinion that it was not advisable to reduce
Merchant
that liability to any extent below the value of the
Shipping.
ship and freight, taking the value of the former at
15l. per ton. For to confine it simply to the actual value of the ship
“would,” they urged, “be an encouragement to unprincipled persons
to employ inadequate and worn-out vessels in the conveyance of
passengers, and that, on the other hand, to subject shipowners to
unlimited liability might induce men of property and character to
withdraw their fortunes from so great a hazard.” The Committee
could not, however, overlook the additional liability to which
Shipowners were exposed by the operation of the municipal laws of
foreign states, for, as the law now stands, the liability of the foreign
shipowner is not limited to our courts, and the liability of the English
shipowner by the same rule, if it were applied in the United States,
would not be limited in their courts.[205] Therefore, although the
English law may have contemplated the limitation of the British
shipowners’ liability, any damage sustained by collision on the high
seas between a British ship and a foreign vessel, would not fall
within the statutory limit, and, practically, the liability of the British
shipowner, in the event of loss of life, would be unlimited, or at least
co-extensive with the loss, which a jury might assess according to
the rank of life and the injuries sustained by the relatives and
families of the deceased. It was further recommended that the
practicability and desirability of an international arrangement with
maritime countries,[206] so as to arrive at some uniform reciprocal
principles, should be seriously considered by Government.
The incidence of the light dues paid by the
Burden of light Shipowners of the Empire, necessarily received
dues. consideration from the Committee, more especially
as it was a serious burden on all merchant vessels.
So far back as 1845, a Committee appointed specially to inquire into
those dues, recommended, “That all expenses for the erection of
lighthouses, floating-lights, buoys, and beacons, on the coast of the
United Kingdom, be henceforth defrayed out of the public revenue.”
Entirely agreeing with this resolution, the Committee of 1860, while
recommending Government to adopt that resolution, added: “That
the lighting of our shores is a high imperial duty which we owe, not
merely to ourselves, but to strangers, whom we invite to trade with
us.”
They felt that the justice as well as the policy of such a course was
strengthened by the fact that the large debt of 1,250,000l., the
result of improvident grants, incurred under the authority of
Parliament for buying up the lighthouses held by private individuals,
had, since that period (1845), been paid out of light dues, raised out
of a tax upon shipping, and they had less hesitation in
recommending the adoption of this enlightened policy from the fact
that the Congress of the United States of America appropriates an
annual vote for lights throughout their whole territory, which is
borne by the entire federation, and that no charge for light dues is
levied on foreign vessels frequenting the ports of that country.
The question of pilotage was also one which
Pilotage. received every consideration, the evidence
showing that when a voluntary system prevailed,
even where the navigation was difficult and, at times, dangerous, no
inconvenience arose from the absence of legal compulsion for the
employment of a pilot. Many of the members of the committee were
of opinion that the whole pilotage of the kingdom should be thrown
open; but no decided recommendation was offered, as it had been
pretty clearly demonstrated in evidence that the compulsory system
of pilotage still exercised at London, Liverpool, and Bristol, had
worked in a manner satisfactory to those persons who were most
directly interested in this matter.
The charges levied by local authorities on ships
Charges made and goods entering or clearing from their ports,
by local had so frequently been under the consideration of
authorities, now
Parliament, that the Committee could do little more
generally than refer to the various reports on this subject,
abolished; and especially to that of the Royal Commissions of
1854, with the expression of their regret that not
one of the recommendations of that commission had been carried
into effect.[207]
The Committee, after inquiring into the
as well as those management of the Trinity Houses of Newcastle
of the Stade and Hull, and the nature of the charges levied by
dues.
the Russian Company and by the King of Hanover
on shipping, under the name of Stade dues, both of which have
since then been happily abolished, reviewed our mercantile marine
legislation since 1835, and were of opinion that, though, in many
respects the measures adopted had been judicious and beneficial, a
few had been carried to excess in matters of detail (an opinion very
different to that which at present prevails in the House of
Commons); nor, indeed, could they have arrived at any other
conclusion, as various witnesses clearly showed that, in some
instances, a zealous wish to accomplish improvements, and to
protect the interests of the public, had led to the adoption of
legislative measures of a too minute and restrictive character, and,
above all, that any unnecessary interference as to how a ship should
be built, fitted, manned, and navigated, was frequently attended
with prejudicial consequences, while it had as frequently retarded
beneficial advance.
Such were the leading points of the report of the
The Report of Merchant Shipping Committee of 1860. It seems to
1860 generally have satisfied all parties as far as anything could
accepted by the
satisfy men whose policy had been ignored; at
mercantile
marine. least no further inquiry into the state of British
shipping, or for relief from oppressive and unjust
burdens has since been considered either expedient or necessary.
Indeed, the great majority of the recommendations have since been
carried out by successive Governments. The Local Charges Bill,
which had been referred to a Select Committee in 1856, was dealt
with by separate inquiries; the important case of Liverpool occupying
the whole of the Session of 1857, ultimately resulting in a reform of
the Dock management, and in the transfer of the Liverpool town
dues to the Dock estate.
In 1861, Mr. Milner Gibson, then President of the Board of Trade,
introduced a Bill[208] by which most of the other grievances were
removed. All taxes on shipping, raised for the purpose of granting
pensions and other, so-called, charitable objects, were abolished;
local differential charges on foreign shipping were, to a large extent,
prohibited;[209] the passing tolls levied for the support of such
harbours as Ramsgate, Dover, and Bridlington were swept away, and
power (on the recommendation originally of the Harbours of Refuge
Commission of 1854) was given to the Public Works Loan
Commissioners to lend money for the improvement of trading
harbours at a low rate of interest.[210] France, to whose shipping
laws I shall hereafter refer, abolished her local charges and
differential dues; Italy, in 1863, admitted British ships to national
treatment; and Austria also, by treaty, in 1868, has followed her
example.
Unfortunately, Shipowners are still taxed for the maintenance of the
National lights; but, although the recommendations of various
Committees have not in this respect been adopted, reductions in the
charges levied have been made to no less an extent than 75 per
cent, since 1853.[211] Great improvements have also been made
since Mr. (now Lord) Cardwell put in motion this scale of reduction,
which has proved so valuable in its results; since then no less than
fifty-seven new lighthouses have been built, and fifteen new light
ships moored on the coast, whilst thirty-seven old lighthouses have
been rebuilt and re-organised at an aggregate cost of more than one
million pounds sterling.
From 1860 the Shipowners of Great Britain, though they have
experienced in their trade, like all other branches of trade, periods of
depression, and rarely more so than at the present moment, have
never looked backwards. All special and peculiar burdens having now
been removed, their only present desire is, and it is not an
unreasonable one, that they should be interfered with as little as
possible—certainly not more so than is necessary for the protection
of the public—in the management of their own affairs, and that they
should have a fair and free field: they seek no favours.
What they have done since they have had free scope to their
industry and skill, and been relieved from all unfair taxation on the
one hand, and the swaddling-clothes of protection on the other, is
truly astonishing. Since then, no country has produced more
magnificent steam and sailing ships, the former having all but
monopolised the great Transatlantic carrying trade, to which I shall
fully refer hereafter, and the latter having driven the American
clippers entirely from the China trade.[212] Such are the effects of
wholesome competition.
Perhaps no merchant ocean-going ships of any
Magnificent country or of any age have equalled, certainly
English none have ever surpassed, the sailing clippers
Merchant sailing
launched from the yards of Great Britain between
ships, 1860-72.
1860 and 1872, vessels far superior to those I
have already named, including the Falcon, the Fiery Cross, Undine,
Lahloo, Leander, the Isles of the South, Min, Kelso, Serica, Taeping,
Ariel, Titania, Spindrift, Sir Lancelot, and Thermopylæ. As the
Thermopylæ and the Sir Lancelot are the fastest sailing ships that
ever traversed the ocean,[213] I have given a representation of the
former under full sail at page 416, and the following drawing to scale
of her midship section may interest my nautical readers.
Transverse Midship Section, “Thermopylæ.”
THE “THERMOPYLÆ.”
On her first voyage from London to Melbourne,
The starting in November 1868, the Thermopylæ made
Thermopylæ. the quickest passage on record between those
ports—viz. in sixty days from pilot to pilot. Nor was
Sir Lancelot and this a mere chance passage, for on the next
others. voyage from London to Melbourne she
accomplished the same distance in sixty-one days,
Americans still faster than any other known passage between
completely these ports; and, so far as I can ascertain, these
outstripped. voyages have never since been equalled by any
other sailing vessels. On her first voyage, after
leaving Melbourne she took on board a cargo of coals at Newcastle
(New South Wales) for Shanghai, and accomplished the passage
thence in twenty-eight days—the quickest on record. Leaving Foo-
chow-foo soon afterwards with a cargo of tea, she made the
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!

ebookmass.com

You might also like