ICS 103:
Computer Programming in C
Handout-01
Topic:
Introduction to Computing
Objective:
·
To
know some historical developments in the field of Computers.
·
Describe
the major components of a computer system and how they work together to solve
problems and manipulate data.
·
Define
the major categories of software and the kinds of languages in which they are
implemented.
·
To
learn some basic commonly used terminology in computers.
·
To
know about Software Development Method (i.e., Steps in writing good quality
program)
·
To
know how to apply Software Development Method (Steps) for writing good
programs.
What is a Computer System?
·
Computer
is an electronic device (machine) which is used for processing (manipulation)
of data. The output, which comes after processing data through computer, is
known as Information.
History of Computers:
·
The
“Analytical Engine” of Charles Babbage may be considered as the first true
digital computer built (1792-1871). No OS was used in the Analytical Engine.
However, we can categorize
the developments in the field of computers in the 1900’s and later into
different computer generations as follows:
Zero th generation (1942 to 1945):
·
Users
hand code all instructions.
·
Mechanical
calculators were developed as computing device.
First Generation (1945 to 1955):
·
Computers
were characterized by Vacuum tubes and Plug boards.
·
On
Ø
ENIAC
as the first electronic computer, was developed by Mr.
J. Presper Eckert and Mr. John Mauchly
at
Ø
It
uses 18,000 vacuum tubes and its cost was $500,000.
Ø
Its
weight was 30 tons and occupied a 30 by 50 foot space.
Ø
It
produced large amount of heat.
Ø
Its
speed was very slow.
·
Programming
was mainly in machine language, often by wiring up plug boards to control
machine's basic functions.
·
Problems
were mainly numerical calculations.
·
Punch
cards were introduced in 1950, which replaced plug boards.
Second generation (1955 to 1965):
·
In
second generation, vacuum tubes were replaced by transistors.
·
Speed
/ performance of this generation computers was improved in comparison to first
generation computers.
·
Size,
price, and heat produced reduced by using transistors.
·
Commercial
use of computers has become possible.
·
For
the first time, there was a clear separation between designers, builders,
operators, programmers and maintenance personnel.
·
They
were small enough and reliable enough to be manufactured and sold.
·
Computers
were kept in special dust-free air-conditioned rooms and attended by operators
only.
·
High-level
languages such as FORTRAN appeared.
·
Large
systems of this generation were used mostly for scientific and engineering
calculations (e.g., solving partial differential equations.)
·
Examples: The Character oriented, commercial computer IBM 1401 and the
word-oriented, large-scale scientific computer 7094.
Third generation (1965 to 1971):
·
In
third generation transistors was replaced by IC’s (Integrated Circuits i.e.,
fabrication of thousands electronic components on single silicon chip).
·
Using
this drastic reduction in the size of computers.
·
Speed
/ performance were high in comparison to second generation.
·
Heat
produced by computers was reduced.
·
Characterized
by Multiprogramming and Timesharing
·
A
representative machine of this generation is IBM family system/360,
which has combined the numeric and commercial applications in one machine.
·
The
360 is the first major computer line to use small scale ICs.
·
The
operating system consists of millions of lines of assembly language, and
written by thousands of programmers.
Fourth generation (1971 to 1980):
·
In
this generation, Small Scale and Medium Scale IC’s are replaced by LSI (Large
Scale Integrated Circuits: more number of electronic components on silicon
chip).
·
These
are low cast, small size and high performance in comparisons to third
generation computers.
·
Personal
Computers, Workstations, Distributed Systems and computer networks were the
main trend.
·
Chip
technology (LSI and VLSI) and microprocessor developments allowed mass
production of cheap but powerful computers, which made it possible for an
individual to have his/her own home as well as office computer.
Fifth generation (1980 to
present):
·
LSI
is replaced by VLSI (Very Large Scale Integrated Circuits).
·
Size
and cost of these computers is very less and performance is very high.
·
During
the mid 1980s networks of PCs running network
Components of Computer:
·
Computer
Hardware (H/W) includes following components:
Ø
Memory
(
Ø
CPU
(Central Processing Unit) = ALU (Arithmetic and Logic Unit) + CU (Control
Unit).
Ø
I/O
Devices.
What is A Program?
·
Computer
Program is a set of instructions in any computer programming language which
directs computer to do specific tasks.
·
Computer
programs are mainly of two types: application programs and System Programs.
What is Software (S/W)?
·
Computer
Software is a collection of computer programs.
S/W‘s are following two types:
·
System Software: Systems software is that
software which is used to manage computer hardware to enable us to execute and
write application programs/software. For example: Operating Systems, Compilers,
Assemblers, Interpreters etc:
§
The
OS acts as the manager of resources (Hardware, HW, and Software, SW) and
allocates them to the programs and users as necessary for their tasks.
§
An
OS can be viewed as a resource allocator.
List of some higher level programming languages:
· FORTRAN, Pascal, BASIC, C, C++, Java etc.
What is Compiler?
·
Compiler
is a System Software which is used to translate higher level language source
code into machine code. For example: C – compiler, FRTRAN compiler.
What is bit, byte, K.B and G.B?
Steps for good quality Program/ Software development:
·
To
develop reliable and good quality Program / Software we need to follow
following 5 steps:
1.
Requirement
Specification.
2.
Analysis.
3.
Design.
4.
Implementation.
5.
Verification
and testing.
For
example: take as a
case study:
finding the area and circumference of a circle
(see below that how we follow the above five steps to solve this problem).
1.
Problem
or Requirement Specification:
Take the radius of a circle
and compute and print its area and circumference.
2.
Analysis:
Clearly, the problem input is the circle radius.
There are two outputs are requested: the area of circle and its circumference.
From our knowledge of geometry, we know the relationship between the radius of
a circle and its area and circumference; we list these formulas along with the
data requirements.
Data
requirements:
Problem
Input:
radius
Problem
outputs:
Relevant
Formulas:
area of circle = π
r2
circumference of circle
= 2 π r
3.
Design:
Once you know the problem inputs and outputs, you
should list the steps necessary to solve the problem.
It is very
important that you pay close attention to the order of the steps.
Algorithm:
Step1: Get/Input circle
radius.
Step2:
area=PI*radius*radius.
Step3: circum=
2*PI*radius.
Step4: print area and
circumference.
4.
Implementation:
In implementation phase we convert
our algorithm into actual program using any
programming language which is given below:
/* Calculates
and displays the area and circumference of a circle */
#include <stdio.h> // preprocessor directive
#define PI
3.14159 // preprocessor directive
int main(void)
// main function
{
double
radius, area, circum; /* Variable
declarations */
/*
Get the circle radius */
printf("Enter
radius: ");
scanf("%lf",
&radius);
/* Calculate
the area */
area
= PI * radius * radius;
/* Calculate
the circumference */
circum
= 2 * PI * radius;
/* Display
the area and circumference */
printf("The area
is: %f\n", area);
printf("The
circumference is: %f\n", circum);
return(0);
} //
end of main
Sample Output:
Enter radius: 5.0
The area is: 78.539750
The circumference is:
31.415900
5.
Testing:
For testing, input different radius
values and verify results with standard results.