100% found this document useful (11 votes)
80 views

Computer Programming E Balagurusamy Full Chapter

ebook

Uploaded by

erin.hakimian447
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (11 votes)
80 views

Computer Programming E Balagurusamy Full Chapter

ebook

Uploaded by

erin.hakimian447
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Computer Programming E.

Balagurusamy
Visit to download the full and correct content document:
https://ebookmass.com/product/computer-programming-e-balagurusamy/
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


Introduction to Computers and Programming 1.23

1.7.1 Analysing the Requirements


In this step, the requirements related to the software, which is to be developed, are understood. Analysing
the requirements or requirement analysis is an important step in the process of developing a software. If the
requirements of the user are not properly understood, then the software is bound to fall short of the end user’s
expectations. Thus, requirement analysis is always the first step towards development of a software.
Software is abstract in nature; as a result, the users may not be able to provide the complete set of
requirements pertaining to the desired software during the requirement analysis stage. Thus, there should be
continuous interaction between the software development team and the end users. Moreover, the software
development team also needs to take into account the fact that the requirements of the users may keep changing
during the development process. Thus, proper analysis of user requirements is quite essential for developing
the software within a given timeframe. It will not only help in controlling the software development cost but
will also lead to faster and accurate development of a software.
The task of requirement analysis is typically performed by a business analyst. The person is a professional
in this field who understands the requirements of the novice end user, and documents and shares it with the
development team.

1.7.2 Feasibility Analysis


In this step, the feasibility of developing the software in terms of resources and cost is ascertained. In order
to determine the feasibility of software development, the existing system of the user is analysed properly.
Apart from studying the existing system, this step involves identifying the need of automation in the existing
system. The analysis done in this step is documented in a standard document called feasibility report, which
contains the observations and recommendations related to the task of software development. Some of the
important activities performed during the feasibility analysis stage are as follows:
Determining development alternatives This activity involves searching for the different
alternatives that are available for the development of software. There are mainly four alternatives
available for the development of a software. The first alternative is to allow the existing system
to continue without developing a new software for automation. The second alternative can be to
develop the new software using specific programming languages such as Java, C++, Visual Basic etc.
The third alternative is to develop the software using the architectural technologies such as Java 2
Enterprise Edition (J2EE) and mainframe based with thin clients. The fourth development alternative
is to buy an already developed software along with its source code from the market and customise it
according to the client’s requirements.
Analysing economic feasibility This activity involves determining whether the development of
a new software will be financially beneficial or not. This type of feasibility analysis is performed
to determine the overall profit that can be earned from the development and implementation of
the software. This feasibility analysis activity involves evaluating all the alternatives available for
development and selecting the one which is most economical.
Assessing technical feasibility The technical feasibility assessment involves analysing various
factors such as performance of the technologies, ease of installation, ease of expansion or reduction
in size, interoperability with other technologies, etc. The technical feasibility activity typically
involves the study of the nature of technology as to how easily it can be learnt and the level of
training required to understand the technology. This type of feasibility assessment greatly helps in
selecting the appropriate technologies to be used for developing the software. The selection should
be made after evaluating the requirement specification of the software. In addition, the advantages
and disadvantages of each identified technology must also be evaluated during technical feasibility
assessment.
1.24 Computer Programming

Analysing operational feasibility Operational feasibility assessment involves studying the


software on operational and maintenance fronts. The operational feasibility of any software is done
on the basis of several factors, such as:
– Type of tools needed for operating the software
– Skill set required for operating the software
– Documentation and other support required for operating the software

1.7.3 Creating the Design


After the feasibility analysis stage, the next step is creating the architecture and design of the new software.
This step involves developing a logical model or basic structure of the new software. For example, if the
new software is based on client–server technology then this step would involve determining and specifying
the number of tiers to be used in the client–server design. This step also involves documenting the varied
specifications pertaining to database and data structure design. The flow of the development process is mainly
illustrated in this stage using a special language known as Unified Modelling Language (UML). UML uses
pictorial representation methods for depicting the flow of data in the software. Some of the key features,
which are considered while designing a software are:
Extensibility The design of the software should be extensible so that it allows the addition of some
new options or modules in future. The architecture of the software should be flexible enough to not
get disturbed with the addition of new functionality.
Modularity The software should be modular in nature so that its working and data flow can be
understood easily. Modularity also helps in parallel development of the various software modules,
which are later integrated into a single software product.
Compatibility Software should run correctly in the existing system with an older version or with
other software. Thus, software should be compatible and work well in conjunction with other software.
Security Software must be able to control unauthorised access. While designing a new software, it
is ensured that there are proper security mechanisms incorporated in the product.
Fault tolerance The software should be capable of handling exceptions or faults that may occur
during its operation. The software must have the capability to recover from failures.
Maintainability The design of the software should be created in a simple manner with appropriate
details so that it is easy to maintain.

1.7.4 Developing Code


In this step, the code for the different modules of the new software is developed. The code for the different
modules is developed according to the design specifications of each module. The programmers in the software
development team use tools like compilers, interpreters and debuggers to perform tasks such as finding errors
in the code and converting the code into machine language for its execution. The code can be written using
programming languages such as C, C++ or Java. The choice of the programming language to be used for
developing the code is made on the basis of the type of software that is to be developed. There are certain key
points or conventions, which must be kept in mind while writing code; for instance:
Introduction to Computers and Programming 1.25

1.7.5 Testing the Software


Testing is basically performed to detect the prevalence of any errors in the new software and rectify those er-
rors. One of the reasons for the occurrence of errors or defects in a new software is that the requirements of the
users or client were not properly understood. Another reason for the occurrence of errors is the common mis-
takes committed by a programmer while developing the code. The two important activities that are performed
during testing are verification and validation. Verification is the process of checking the software based on
some pre-defined specifications, while validation involves testing the product to ascertain whether it meets
the user’s requirements. During validation, the tester inputs different values to ascertain whether the software
is generating the right output as per the original requirements. The various testing methodologies include:

1.7.6 Deploying the Software


In this step, the newly developed and fully tested software is installed in its target environment. Software
documentation is handed over to the users and some initial data are entered in the software to make it
operational. The users are also given training on the software’s interface and its other functions.

1.7.7 Maintaining the Software


Once the software has been deployed successfully, a continuous support is provided to it for ensuring its
full-time availability. A corrupt file, a virus infection and a fatal error are some of the situations where the
maintenance personnel are asked to fix the software and bring it back to its normal functioning. Further, a
software may also be required to be modified if its environment undergoes a change. In order to successfully
maintain the software, it is required that it should have been properly documented at the time of its
development. This is because the maintenance person might not be the same who was originally involved in
the development of the software. Thus, a good code documentation serves vital for the maintenance person
to fix the software.

1.8 APPLYING SOFTWARE DEVELOPMENT METHOD


To understand how software development method is applied, consider a simple scenario where it is required
to convert the temperature given in Fahrenheit to its corresponding Celsius value.

Program Objective
To convert the temperature value from Fahrenheit to Celsius

Analysis
Input: Temperature value in Fahrenheit
Output: Temperature value in Celsius
1.26 Computer Programming

Conversion method: The formula C = (F–32) / 1.8 can be used to generate the desired output
Data elements: Real Variable F is used to store the input temperature value in Fahrenheit
Real Variable C is used to store the resultant temperature value in Celsius

Design

Algorithm
Step 1 – Read F
Step 2 – Compute C = (F-32) / 1.8
Step 3 – Display C

Development

Program
#include <stdio.h>
#include <conio.h>

void main()
{
float F, C;
clrscr();

printf("Enter the temperature value in Fahrenheit: ");


scanf("%f",&F);

C=(F-32.0)/1.8;

printf("The equivalent temperature value in degrees Celsius is: %.2f",C);


getch();
}

Testing
The program must be tested with multiple input values so as to ensure that there are no logical errors present
in the code.

Enter the temperature value in Fahrenheit: 0


The equivalent temperature value in degrees Celsius is: –17.78

Enter the temperature value in Fahrenheit: 175


The equivalent temperature value in degrees Celsius is: 79.44

Enter the temperature value in Fahrenheit: 250


The equivalent temperature value in degrees Celsius is: 121.11
Introduction to Computers and Programming 1.27

Key Terms
Computer: It is an electronic device that Input devices: Input devices accept the data
takes data and instructions as input from the from the end users on which the operations
user, processes the data, and generates useful are to be performed.
information as an output. Output devices: Output devices are used for
Vacuum tube: It was used in the first genera- providing the output of a program that is ob-
tion computers for developing the circuitry. It tained after performing the operations speci-
comprised of glass and filaments. fied in a program.
Transistor: It is a solid state device used in CPU: It is the heart of a computer that is used
the second generation computers. It replaced to process the data entered through the input
vacuum tubes. device.
IC: It is a silicon chip that embeds an elec- Memory: It is used for storing the input data
tronic circuit comprising of several compo- as well as the output of a program that is ob-
nents, such as transistors, diodes, and resis- tained after performing the operations in a
tors. It is used in third generation computers. program.
Microprocessor: It is a processor chip used Scanner: It is an input device that converts
in fourth generation computers. It integrates documents and images as the digitized im-
thousands of components on a single chip. ages understandable by the computer system.
LAN: It is a network, where multiple com- Motherboard: It is a device used for con-
puters in a local area, such as home, office, or necting the CPU with the input and output
small group of buildings, are connected and devices.
allowed to communicate among them. RAM: It is the primary memory of a com-
WAN: It is a network, which facilitates con- puter that stores information and programs,
nection and communication of hundreds of until the computer is used.
computers located across multiple locations. Monitor: It is an output device that produces
MAN: It is a network that is used to connect visual displays generated by the computer.
the computers over a large geographical area, Printer: It is an output device that prints the
such as district or city. computer generated information onto the pa-
GUI: It is a user-friendly interface that pro- per sheets.
vides icons and menus to interact with the Speaker: It is an electromechanical trans-
various computer applications. ducer that converts an electrical signal into
Microcomputer: It is defined as a computer sound.
that has a microprocessor as its CPU. Plotter: It is an output device that is connect-
Minicomputer: It is a medium-sized com- ed to a computer to print large documents,
puter that is designed to serve multiple users such as engineering and constructional draw-
simultaneously. ings.
Mainframe computer: It is a computer, System software: It refers to a computer
which helps in handling the information pro- program that manages and controls hardware
cessing of various organizations like banks, components.
insurance companies, hospitals and railways. Application software: It is a computer pro-
Supercomputer: It is the most powerful and gram that is designed and developed for per-
fastest computer. It is used for complex sci- forming specific utility tasks; it is also known
entific applications. as end-user program.
Another random document with
no related content on Scribd:
will be sewed by arbitration at an early day. Under the
circumstances the Commission, while continuing its deliberations
in the preparation and orderly arrangement of many valuable maps,
reports, and documents, which have been procured and used in the
course of its labors, does not propose to formulate any decision
for the present of the matters subject to its examination. It
will continue its sessions from time to time, but with the hope
and expectation that a friendly and just settlement of all
pending differences between the nations interested will make
any final decision on its part unnecessary." This hope was
substantially realized a few days later, when a convention
embodying the agreement of the United States and Great Britain
was signed by Secretary Olney and the British Ambassador, Sir
Julian Pauncefote. The agreement was carried to its next stage on
the 2d of February, 1897, when a treaty between Great Britain and
the United States of Venezuela was signed at Washington, which
provided as follows:

{692}

"Article I.
An Arbitral Tribunal shall be immediately appointed to
determine the boundary-line between the Colony of British
Guiana and the United States of Venezuela.

"Article II.
The Tribunal shall consist of five Jurists: two on the part of
Great Britain, nominated by the Members of the Judicial
Committee of Her Majesty's Privy Council, namely, the Right
Honourable Baron Herschell, Knight Grand Cross of the Most
Honourable Order of the Bath, and the Honourable Sir Richard
Henn Collins, Knight, one of the Justices of Her Britannic
Majesty's Supreme Court of Judicature; two on the part of
Venezuela, nominated, one by the President of the United
States of Venezuela, namely, the Honourable Melville Weston
Fuller, Chief Justice of the United States of America, and one
nominated by the Justices of the Supreme Court of the United
States of America, namely, the Honourable David Josiah Brewer,
a Justice of the Supreme Court of the United States of
America; and of a fifth Jurist to be selected by the four
persons so nominated, or in the event of their failure to
agree within three months from the date of the exchange of
ratifications of the present Treaty, to be selected by His
Majesty the King of Sweden and Norway. The Jurist so selected
shall be President of the Tribunal. In case of the death,
absence, or incapacity to serve of any of the four Arbitrators
above named, or in the event of any such Arbitrator omitting
or declining or ceasing to act as such, another Jurist of
repute shall be forthwith substituted in his place. If such
vacancy shall occur among those nominated on the part of Great
Britain, the substitute shall be appointed by the members for
the time being of the Judicial Committee of Her Majesty's
Privy Council, acting by a majority, and if among those
nominated on the part of Venezuela, he shall be appointed by
the Justices of the Supreme Court of the United States, acting
by a majority. If such vacancy shall occur in the case of the
fifth Arbitrator, a substitute shall be selected in the manner
herein provided for with regard to the original appointment.

"Article III.
The Tribunal shall investigate and ascertain the extent of the
territories belonging to, or that might lawfully be claimed
by, the United Netherlands or by the Kingdom of Spain
respectively at the time of the acquisition by Great Britain
of the Colony of British Guiana, and shall determine the
boundary-line between the Colony of British Guiana and the
United States of Venezuela.

"Article IV.
In deciding the matters submitted, the Arbitrators shall
ascertain all facts which they deem necessary to a decision of
the controversy, and shall be governed by the following Rules,
which are agreed upon by the High Contracting Parties as Rules
to be taken as applicable to the case, and by such principles
of international law not inconsistent therewith as the
Arbitrators shall determine to be applicable to the
case:—

Rules.
(a.) Adverse holding or prescription during a period of fifty
years shall make a good title. The Arbitrators may deem
exclusive political control of a district, as well as actual
settlement thereof, sufficient to constitute adverse holding
or to make title by prescription.

(b.) The Arbitrators may recognize and give effect to rights


and claims resting on any other ground whatever valid
according to international law, and on any principles of
international law which the Arbitrators may deem to be
applicable to the case, and which are not in contravention of
the foregoing rule.

(c.) In determining the boundary-line, if territory of one


Party be found by the Tribunal to have been at the date of
this Treaty in the occupation of the subjects or citizens of
the other Party, such effect shall be given to such occupation
as reason, justice, the principles of international law, and
the equities of the case shall, in the opinion of the
Tribunal, require. …

Article XIII.
The High Contracting Parties engage to consider the result of
the proceedings of the Tribunal of Arbitration as a full,
perfect, and final settlement of all the questions referred to
the Arbitrators:"

Great Britain, Papers by Command:


Treaty Series Number 5, 1897.

Before the Arbitrators named in the treaty had entered on


their duties, a vacancy in the tribunal was created by the
death of Baron Herschell, and the Lord Chief Justice of
England, Lord Russell of Killowen, was appointed in his place.
His Excellency, Frederic de Martens, Privy Councillor and
Permanent Member of the Council of the Ministry of Foreign
Affairs in Russia, was selected to be the fifth Arbitrator. As
thus constituted, the Arbitral Tribunal met in Paris on the
15th of June, 1899. In the hearings before it, Venezuela was
represented by Benjamin Harrison, ex-President of the United
States, and other counsel; the British government by Sir
Richard Webster, Attorney-General of Great Britain, and
others. The decision of the Tribunal, which is said to have
been rendered with unanimity, was announced on the 3d of
October, 1899, as follows:

"We the undersigned Arbitrators do hereby make and publish our


decision, determination, and Award of, upon, and concerning
the questions submitted to us by the said Treaty of
Arbitration, and do hereby, conformably to the said Treaty of
Arbitration, finally decide, award, and determine that the
boundary-line between the Colony of British Guiana and the
United States of Venezuela is as follows:

Starting from the coast at Point Playa, the line of boundary


shall run in a straight line to the River Barima at its
junction with the River Mururuma, and thence along the
mid-stream of the latter river to its source, and from that
point to the junction of the River Haiowa with the Amakuru,
and thence along the mid-stream of the Amakuru to its source
in the Imataka Ridge, and thence in a south-westerly direction
along the highest ridge of the spur of the Imataka Mountains
to the highest point of the main range of such Imataka
Mountains opposite to the source of the Barima, and thence
along the summit of the main ridge in a south-easterly
direction of the Imataka Mountains to the source of the
Acarabisi, and thence along the mid-stream of the Acarabisi to
the Cuyuni, and thence along the northern bank of the River
Cuyuni westward to its junction with the Wenamu, and thence
following the mid-stream of the Wenamu to its westernmost
source, and thence in a direct line to the summit of Mount
Roraima, and from Mount Roraima to the source of the Cotinga,
and along the mid-stream of that river to its junction with
the Takutu, and thence along the mid-stream of the Takutu to
its source, thence in a straight line to the westernmost point
of the Akarai Mountains, and thence along the ridge of the
Akarai Mountains to the source of the Corentin called the
Cutari River.
{693}
Provided always that the line of delimitation fixed by this
Award shall be subject and without prejudice to any questions
now existing, or which may arise, to be determined between the
Government of her Britannic Majesty and the Republic of
Brazil, or between the latter Republic and the United States
of Venezuela.

"In fixing the above delimitation the Arbitrators consider and


decide that in times of peace the Rivers Amakuru and Barima
shall be open to navigation by the merchant-ships of all
nations, subject to all just regulations and to the payment of
light or other like dues: Provided that the dues charged by
the Republic of Venezuela and the Government of the Colony of
British Guiana in respect of the passage of vessels along the
portions of such rivers respectively owned by them shall be
charged at the same rates upon the vessels of Venezuela and
Great Britain, such rates being no higher than those charged
to any other nation: Provided also that no customs duties
shall be chargeable either by the Republic of Venezuela or by
the Colony of British Guiana in respect of goods carried on
board ships, vessels, or boats passing along the said rivers,
but customs duties shall only be chargeable in respect of
goods landed in the territory of Venezuela or Great Britain
respectively."

Great Britain, Papers by Command:


Venezuela Number 7, 1899, pages 6-7.
VENEZUELA: A. D. 1898-1900.
Change in the Presidency.
Death of ex-President Crespo.
Revolution.
Rebellion.

General Joaquin Crespo retired from the presidency and was


succeeded by General Ignacio Andrade on the 1st of March,
1898. A revolutionary movement was soon started, with General
Hernandez at its head, and ex-President Crespo, who led the
forces of the government against it, was killed in a charge,
on the 16th of April. Hernandez was surprised and captured a
few weeks later, and the rebellion then subsided for a time.
In the spring of 1899 Hernandez was set at liberty by Andrade,
who, meantime, had crushed a minor revolt, undertaken by one
General Guerra. August found the harassed President assailed
by a fresh rising, started by General Cipriano Castro, and the
restless revolutionist, Hernandez, was soon in league with it.
This proved to be a revolution in earnest, and, after hard
fighting, President Andrade fled from the capital and the
country in October; Puerto Cabello, the last town to hold out
for him, was bombarded and stormed the following month, and a
new government was established, nominally under the Vice
President, Rodriguez, but with Castro for its actual head.
Before this had been fully accomplished, however, Hernandez
was in arms against Castro, with his accustomed ill-success.
Before the year closed he had fled the country; but early in
1900 he was once more in the field, maintaining a troublesome
war until May, when he was defeated, and again a prisoner in
his opponents' hands.

VICTORIA, Queen:
The Diamond Jubilee celebration of her accession to the throne.

See (in this volume)


ENGLAND: A. D. 1897 (JUNE).
VICTORIA, Queen:
Her death and funeral.
Tributes to her character.

See (in this volume)


ENGLAND: A. D. 1901 (JANUARY).

VICTORIA.

See (in this volume)


AUSTRALIA; and CONSTITUTION OF AUSTRALIA.

VICTORIAN ORDER, The.

A new order of knighthood, to be known as the Victorian Order,


and to be conferred as a mark of high distinction, was
instituted by Queen Victoria on the 21st of April, 1896.

VIENNA: A. D. 1895-1896.
Anti-Semitic agitation.

See (in this volume)


AUSTRIA-HUNGARY: A. D. 1895-1896.

VIENNA: A. D. 1897.
Scenes in the Reichsrath.

See (in this volume)


AUSTRIA-HUNGARY: A. D. 1897 (OCTOBER-DECEMBER).

VIENNA: A. D. 1900.
Census.

According to a report from the United States Consul at Vienna,


the census taken December 31, 1900, shows a population of
1,635,647, or nearly 63,000 less than that of Chicago, when
the recent census of that city was taken. These figures show
Vienna to rank next after London, Paris and Berlin among the
European capitals, while in this country only New York and
Chicago are larger. In the last ten years Vienna has increased
21.9 per cent, or slightly faster than the average for the
whole United States. Of the two American cities larger than
Vienna New York increased in ten years 37.8 per cent. and
Chicago 54.4 per cent.

VIEQUEZ.

See (in this volume)


PORTO RICO: AREA AND POPULATION.

VILLIERS, Sir J. H. de:


Advice to President Kruger.

See (in this volume)


SOUTH AFRICA (THE TRANSVAAL): A. D. 1899 (MAY-AUGUST).

VIRDEN, Conflict with striking miners at.

See (in this volume)


INDUSTRIAL DISTURBANCES: A. D. 1898.

VIRGINIUS AFFAIR, The.

See (in this volume)


CUBA: A. D. 1868-1885.

VISAYAN ISLANDS, American occupation of the.

See (in this volume)


PHILIPPINE ISLANDS: A. D. 1899 (JANUARY-NOVEMBER).

VISAYANS, The.
See (in this volume)
PHILIPPINE ISLANDS: THE NATIVE INHABITANTS.

VOLKSRAAD, South African.

See (in this volume)


CONSTITUTION (GRONDWET) OF THE SOUTH AFRICAN
REPUBLIC.

VOLUNTARY SCHOOLS, English.

See (in this volume)


ENGLAND: A. D. 1896-1897.

VOLUNTEERS OF AMERICA, The.

See (in this volume)


SALVATION ARMY.

VOTING, Plural or Cumulative, and Compulsory.

See (in this volume)


BELGIUM: A. D. 1894-1895.

{694}

WADAI.

See (in this volume)


NIGERIA, A. D. 1882-1899.

WALDECK-ROUSSEAU, M.:
The Ministry of.

See (in this volume)


FRANCE: A. D. 1899 (FEBRUARY-JUNE), and after.
WALES, The Prince or.

It has been announced that Prince George, Duke of Cornwall and


York, the only living son of King Edward VII., of England, and
heir to the British throne, will be created Prince of Wales,
by royal patent, after his return from Australia.

See (in this volume)


AUSTRALIA: A. D. 1901 (MAY).

WANA:
Inclusion in a new British Indian province.

See (in this volume)


INDIA: A. D. 1901 (FEBRUARY).

WAR:
Measures to prevent its occurrence and to mitigate its
barbarities.

See (in this volume)


PEACE CONFERENCE.

WAR BUDGETS:
Military and naval expenditures of the great Powers.

The following compilation of statistics of the military and


naval expenditure of the leading Powers (Great Britain
excepted) was submitted to the House of Representatives at
Washington by the Honorable George B. McClellan of New York,
in a speech, February 12, 1901, on the bill then pending in
Congress, to make appropriations for the support of the Army
of the United States. The tabulated statements were introduced
with explanations and comments as follows:

"For purposes of comparison, I have taken the armies and


navies of Austria-Hungary, France, the German Empire, Italy,
and Russia. I have not included Great Britain, for its
conditions have been abnormal for nearly two years. I have
based my estimates on the enlisted strength of the armies
referred to, excluding commissioned officers. The figures are
the most recent obtainable without direct communication with
foreign authorities and are for the most part for the last
fiscal year of the several countries, although in some cases
they are for 1898-99. The German naval budget does not include
the extraordinary expenditures for the new navy authorized by
the recent enactment of the Reichstag. This does not begin to
be effective until the next fiscal year. In estimating the
equivalent in dollars of the Italian budget I have allowed 6
per cent for the depreciation of the present paper currency—a
very moderate estimate. The Russian budget will appear
abnormally low, for I have recently seen it stated at
$159,000,000. This is because the ruble has been assumed to be
the gold ruble, worth 52 cents, but the budget is expressed in
paper rubles, and is now, under a recent order of M. Witte,
uniformly reckoned at two-thirds of the gold ruble. I have
therefore called it 34.6 cents."

As to the military expenditure of the United States, "the


House has during the present session appropriated, or is about
to appropriate, for the support of what may be called the
active Army, $152,068,100.84. The appropriations growing out
of past wars amount to a total of $154,694,292. I have charged
to this account every item that could by any possible
construction be assumed to refer to past wars and not to the
maintenance of the present Army. The pension appropriation
bill carried $145,245,230. The cost of administering the
Pension Bureau will amount to $3,352,790. The Record and
Pension Office costs $585,170. I have further included
appropriations for National and State Homes, back pay, etc.,
cemeteries, and $712,580 for extra clerks due to the Spanish
war. Adding the appropriations due to past wars to the
appropriation for the active Army, we find a total of
$306,762,392.84, which represents the total of our Army
budget. Taking the total cost of our active Army, and assuming
the enlisted strength of the Army to be 100,000, we find the
cost per annum of each enlisted man to be $l,520. Taking the
total Army budget, including appropriations arising from past
wars, we find the cost per annum of each enlisted man $3,067.

"Without including appropriations arising from past wars, we


find the cost of the Army per capita of population to be
$1.99. Including appropriations arising from past wars, we
find the cost of the Army per capita of population to be
$4.02. The army budget of Austria-Hungary is $67,564,446, the
cost of maintaining 1 enlisted man for one year being $183.86,
and the cost of the army per capita of population $1.50. The
army budget of France is $128,959,064, the cost of maintaining
1 enlisted man is $218.74, and the cost per capita of
population is $3.34. The army budget of the German Empire is
$156,127,743, the cost per annum of 1 enlisted man is $277.85,
the cost per capita of population is $2.98. The army budget of
Italy is $43,920,132, the cost of maintaining 1 enlisted man
per annum is $202.65, the cost per capita of population is
$1.39. The army budget of Russia is $99,927,997, the cost of
maintaining 1 enlisted man is $119.65, the cost per capita of
population is 77 cents.

"The appropriations for the support of the naval establishment


are by no means so widely distributed as are those for the
Army. The naval bill carries $77,016,635.60. In the
legislative, executive, and judicial bill there are carried
appropriations directly chargeable to the support of the Navy,
including pay of the clerical force in the Auditor's office,
the office of the Secretary, the office of the heads of the
bureaus, maintenance of building, and contingent expenses,
amounting to $399,150. In the sundry civil bill there are
carried, for printing and binding, appropriations amounting to
$127,000. Up to the present time the Secretary of the Treasury
has submitted to the House a statement of deficiencies for the
support of the naval establishment amounting to $2,491,549.64,
making a total of $80,034,335.24 that the House has
appropriated or is about to appropriate during the present
session for the support of the naval establishment. In
addition to this the legislative, executive, and judicial bill
carries an appropriation of $21,800 for the payment of extra
clerks whose employment is necessitated by the Spanish war,
making a total naval budget of $80,056,135.24.

"The naval budget of Austria-Hungary is $7,028,167, a cost per


capita of population of 15 cents. The naval budget of France
is $61,238,478, a cost per capita of population of $1.58. The
naval budget of the German Empire is $32,419,602, a cost per
capita of population of 62 cents. The naval budget of Italy is
$18,455,111, a cost per capita of population of 58 cents. The
naval budget of Russia is $48,132,220, a cost per capita of
population of 37 cents.

{695}

"The combined appropriations for the Army and Navy represent


the total war budget, or, as some European countries prefer to
call it, the 'defense budget.' The total war budget of the
United States, excluding appropriations due to past wars,
amounts to $233,102,435, or a cost per capita of population of
$3.03. Our total war budget, including appropriations due to
past wars, amounts to $386,818,527, a cost per capita of
population of $5.06. The total war budget of Austria-Hungary
is $74,592,613, a cost per capita of population of $1.66. The
total war budget of France is $190,197,542, a cost per capita
of population of $4.92. The total war budget of the German
Empire is $188,547,345, a cost per capita of population of
$3.60. The total war budget of Italy is $62,375,243, a cost
per capita of population of $1.97. The total war budget of
Russia is $148,060,017, a cost per capita of population of
$1.14. The combined total war budgets of France and of the
German Empire amount to $378,744,887, or $8,073,640 less than
that of the United States.
"The criticism has been made that there can be no comparison
between the cost of maintaining our Army and the cost of
maintaining those of Europe, for the reason that the European
private receives 'no pay' and ours receives $156 a year. As a
matter of fact, while service is compulsory on the Continent,
the continental private is paid a small sum, amounting on the
average to about $56 a year. In other words, our private
receives about $100 more than his comrade of Europe. This
criticism does not affect comparisons, as will be seen on the
consideration of a few figures. The war budget of the German
Empire is the largest in Europe. Were the Prussian private to
receive the same pay as our private the Prussian army budget
would be swelled to $212,354,343. Were the Russian private to
receive the same pay as our private the Russian budget would
be swelled to about $190,000,000 per annum. The difference in
pay does not account for the proportionate difference in the
size of the budgets, for were our Army to be increased to the
size of that of the German Empire our budget would be
increased by $702,644,320, making a total of $854,712,420,
without including expenses due to past wars, or, including
such expenses, making an Army budget of $1,009,406,712. Were
our Army to be increased to the size of Russia's, our budget
would be increased by $1,132,120,220, making a total Army
budget, without including appropriations due to past wars, of
81,284,188,320, or, including appropriations due to past wars,
making a total budget of $1,438,882,612.

"I submit these figures to the consideration of the House


without any comment whatsoever. Comment is unnecessary.

"TABLE A.
Analysis of the war budget of the United States as agreed to,
or about to be agreed to, by the House of Representatives,
first session Fifty-sixth Congress.

1. ARMY.
Appropriations for the active Army.

Army bill
$117,994,649.10
Military Academy bill
700,151.88
Fortification bill
7,227,461.00

Legislative, executive, and judicial bill:

Office of the Secretary of War


$104,150
Office of the Auditor for the War Department
318,300
Offices of heads of so-called "staff"
departments 653,826
Maintenance of three-eighths of Department
building 45,990
Rent
13,500
Stationery
32,500
Postage
1,000
Contingent expenses
58,000
Total
1,227,266.00

Sundry civil bill:


Arsenals and armories
281,550
Military posts
1,008,960
Bringing home dead
150,000
Maps, etc.
5,100
Printing and binding
241,000
Repairs, three-eighths Department building
31,500
Total
1,721,110.00

Deficiencies submitted:
December 11, 1900
12,062,223.36
January 21, 1901
5,835,239.50
January 26, 1001
5,300,000.00
Total
23,197,462.36

Total, active Army


152,068,100.84

Appropriations growing out of past wars.

Pensions
$145,245,230.00
Salaries, Pension Bureau, etc.
3,352,700.00
Record and Pension Office
585,170.00
National Homes for Disabled Volunteer Soldiers
3,074,142.00
State Homes for Disabled Volunteer Soldiers
950,000.00
Back pay and bounty (civil war)
325,000.00
Arrears of pay (Spanish war)
200,000.00
National cemeteries
191,880.00
Artificial limbs and appliances
27,000.00
Headstones and burials
28,000.00
Apache prisoners
2,500.00
Secretary of War, extra clerks (Spanish war)
600,000.00
Auditor for War Department,
extra clerks(Spanish war)
112,580.00

Total.
154,694,292.00

Appropriations for the active Army


152,068,100.84

Total Army budget.


300,762,392.81
2. NAVY.

Naval bill
$77,016,635.60
Legislative, executive, and judicial bill:
Office of the Secretary of the Navy
$47,900.00
Office of the Auditor for the Navy
Department 68,080.00
Offices of heads of bureaus, etc.
224,430.00
Maintenance of three-eighths
of Department building
45,990.00
Contingent expenses
12,750.00
Total
$399,150.00

Sundry civil bill:


Printing and binding
127,000.00

Deficiencies submitted:
December 11, 1900
74,481.09
December 17, 1900
20,000.00
January 21, 1901
2,267,068.55
January 25, 1901
130,000.00
Total
2,491,549.64

Total, active Navy


80,034,335.24
Auditor for Navy Department,
extra clerks (Spanish war)
21,800.00

Total Navy budget


80,056,135.24

3. RECAPITULATION.

Active Army
$152,068,100.84
Active Navy
80,034,335.24
Total
$232,102,436.08

Army (past wars)


154,694,292.00
Navy (past wars)
21,800.00
Total War Budget
154,716,092.00

Total war budget


386,818,528.08

{696}
TABLE B. Analysis of war budgets of various armies.

Country Population Latest Total


Cost of Cost of Latest Cost of
Total war
by last Obtainable
enlisted maintaining army per obtainable
navy per budget Cost of army and
census Army Budget
strength, one enlisted capita of naval
capita of combined
peace
man for population budget population
per capita of

footing one year.


population.

Austria-Hungary 44,901,036 $67,564,446


368,002 $183.86 $1.50 $7,028,167
$0.15 $74,502,613 $1.66
France 38,517,975 128,959,064
589,541 218.74 3.34 61,238,478
1.58 190,197,542 4.92
German Empire 52,246,589 156,127,743
562,266 277.85 2.98 32,419,602
.62 188,547,345 3.60
Italy 31,479,217 43,020,132
216,720 202.65 1.39 18,455,111
.58 62,375,243 1.97
Russia 129,211,113 99,927,797
835,143 119.85 .77 48,132,220
.37 148,060,017 1.14

You might also like