Está en la página 1de 10

CHAPTER I

INTRODUCTION TO COMPUTERS & PROGRAMMING


1. Concept of Computer & Computer Systems
(i)
Computers
(a) Definition: computers are the electromechanical device that functions semi
automatically and are capable of accepting instructions and data, performing
computations, and manipulating data to produce useful results.
(b) Classification of Computer: computers are categorized according to their size
(memory and number of processors), functions and area of application. Generally
there are two main types of computer, (i) General-purpose computers and (ii)
special-purpose computers.
(i)

General purpose computers: they can run different many different


programing languages and solve many different types of problems. They are
broadly classified as mainframe, supercomputer, personal computer, laptop,.
Based on physical size, memory size, word size, processing speed, number of
peripheral devices supported and network devices.
Mainframe computer: they are found in installation where there is a high
demand for computer power and a large amount of data to be processed.
Mainframe computers are powerful computers used primarily by corporate
and governmental organizations for critical applications, bulk data processing
such as census, industry and consumer statistics, enterprise resource
planning, and transaction processing.
If you ever used an automated teller machine (ATM) to interact with your
bank account, you used a mainframe computer. Businesses today rely on the
mainframe to:

Perform large-scale transaction processing (thousands of transactions


per second)
Support thousands of users and application programs concurrently
accessing numerous resources
Manage terabytes of information in databases
Handle large-bandwidth communication

Supercomputer: supercomputer are extremely fast machines used primarily


for complex and scientific calculations.
Personal computer: they are found at homes, in schools, libraries, business
and small installations where there are limited amounts of data to be
processed.
Laptop: It is a small portable computer with capabilities similar to those of
personal computers.
Servers: servers are the large computer system that store large varieties of
programs and database to provide service to the organizations and people
using the internet.
(A database is an organized collection of data for one or more purposes,
usually in digital form. Each program consists of sequence of instructions
which direct to input and manipulate the data based on the solution
algorithm to produce an answer to the problem and output the results.)

CHAPTER I
Workstations: workstations are capable of large computation. They can be
configured based on the memory and processing needs to be stand-alone units
with processing power and graphic capabilities or they can be connected to
other computers for special activities such as email and internet access.
(ii)

Computer systems: computer system consists of hardware, software and firmware.


(i)
(ii)
(iii)

Hardware: hardware means the collection of all the physical components that
constitute a computer.
Software: software is the collection of all the programs that run on the hardware
of the computer.
Firmware: firmware is the part of hardware that is permanently programmed. In a
computer that would be the ROM/BIOS. Some examples include, the software
running in your Internet firewall/router, the software running in your DVD player,
your car computer system, software running your cell phone, etc.

2. Hardware Components & Functions

(i)

Input Unit:
Computers need to receive data and instruction in order to solve any problem. Therefore
we need to input the data and instructions into the computers. The input unit consists of
one or more input devices. Keyboard is the one of the most commonly used input device.
Other commonly used input devices are the mouse, CD/DVD/BLUERAY, Pen drive,
scanner etc. All the input devices perform the following functions.
# Accept the data and instructions from the outside world.
# Convert it to a form that the computer can understand.
# Supply the converted data to the computer system for further processing.

(ii)

Storage Unit:
The storage unit of the computer holds data and instructions that are entered through the
input unit, before they are processed. It preserves the intermediate and final results before
these are sent to the output devices. It also saves the data for the later use. The various
storage devices of a computer system are divided into two categories.
(a) Primary Storage: Stores and provides very fast. This memory is generally used to
hold the program being currently executed in the computer, the data being received

CHAPTER I
from the input unit, the intermediate and final results of the program. The primary
memory is temporary in nature. The data is lost, when the computer is switched off.
In order to store the data permanently, the data has to be transferred to the secondary
memory. Therefore most computers have limited primary storage capacity. For
example random-access memory (RAM) is the Primary Storage device. It is smallsized, light, but quite expensive at the same time
(b) Secondary Storage: Secondary storage is used like an archive. It stores several
programs, documents, data bases etc. The programs that you run on the computer are
first transferred to the primary memory before it is actually run. Whenever the results
are saved, again they get stored in the secondary memory. Some of the commonly
used secondary memory devices are Hard disk, CD, etc.
(iii)

Memory Size:
All digital computers use the binary system, i.e. 0s and 1s. The set of 8 bits is called a
byte. Byte is the space occupied in the memory. A character occupies 1 byte space. A
numeric occupies 2 byte space. Bit means in short for binary digit, the smallest unit of
information on a machine.
1 bit = a 1 or 0 (b)
8 bits = 1 byte (B)
1024 bytes = 1 Kilobyte (KB)
1024 Kilobytes = 1 Megabyte (MB)
1 Megabyte = 8192 kilobits (kb)
1024 Megabytes = 1 Gigabyte (GB)
1024 Gigabytes = 1 Terabyte (TB)
The terms 32-bit and 64-bit refer to the way a computer's processor (also called a CPU),
handles information. The 64-bit version of Windows handles large amounts of random
access memory (RAM) more effectively than a 32-bit system.

(iv)

Output Unit:
The output unit of a computer provides the information and results of a computation to
outside world. Printers, monitor are the commonly used output devices.

(v)

Arithmetic Logical Unit (ALU):


It is the part of a computer processor (CPU). All calculations are performed in the
Arithmetic Logic Unit (ALU) of the computer. It also does comparison and takes
decision. The ALU can perform basic operations such as addition, subtraction,
multiplication, division, etc and does logic operations viz, >, <, =, etc. Whenever
calculations are required, the control unit transfers the data from storage unit to ALU once
the computations are done, the results are transferred to the storage unit by the control
unit and then it is send to the output unit for displaying results.

(vi)

Control Unit:
The control unit is the circuitry that controls the flow of information through the
processor, and coordinates the activities of the other units within it. In a way, it is the
"brain within the brain", as it controls what happens inside the processor. It controls all
other units in the computer. The control unit instructs the input unit, where to store the
data after receiving it from the user. It controls the flow of data and instructions from the
storage unit to ALU. It also controls the flow of results from the ALU to the storage unit.
The control unit is generally referred as the central nervous system of the computer that
control and synchronizes its working.

(vii)

Central Processing Unit:

CHAPTER I

The control unit and ALU of the computer are together known as the Central Processing
Unit (CPU). The CPU is like brain performs the following functions:
It performs all calculations.
It takes all decisions.
It controls all units of the computer.
Processor Manufacturers
* American Micro Devices (AMD)
* Intel
* IBM
* Motorola
* Cyrix
* Texas Instruments

3.

Software Components & Functions


(i)
Program: a program is a sequence of instructions written in a programming language that
directs a computer in problem solving.
(ii)

Software: Software consists of program written to support the basic operations of the
system and program written to carry out an application.

(iii)

System software: the software that controls the execution of an application program is
called system software. The major system software components are operating system and
language system.
(a) Operating system: it makes the system facilities available to the application programs
and controls their use.
(b) Language system: language systems are classified as high-level and low-level
languages.
High-level language: languages that are reasonably machine independent and people
oriented are called high-level language.
Low-level language: Assembly language and machine oriented languages are called
low-level language. Low-level languages can be converted to machine code without
using a compiler or interpreter, and the resulting code runs directly on the processor.
A program written in a low-level language can be made to run very fast, and with a
very small memory footprint;

(iv)

Compilers: compilers are the language system that translates programs written in highlevel language such as C, C++, java etc. into machine code which the hardware can
interpret and execute directly.

(v)

Debug: In computers, debugging is the process of locating and fixing or bypassing bugs
(errors) in computer program code.

4. Algorithm & program development

CHAPTER I
Solving a problem on a computer requires a thorough understanding and analysis of the problem
and data. Once the problem has been analyzed, the detailed design of a solution can be developed.
One of the steps in designing and developing a computerized solution to a problem is to develop
an algorithm to solve the problem.
5. Concept of an algorithm
Definition of algorithm: an algorithm is a procedure consisting of a finite number of precisely
defined steps for solving a problem. Each step of an algorithm must be an unambiguous (Having
or exhibiting a single clearly defined meaning) instruction which, when written in a computer
language, can be executed by a computer.
Example: the following example shows the algorithm to solve a design problem.
Calculate in kg, total amount of steel required to build a pipeline to carry water.
1.
2.
3.
4.
5.
6.

Step: Input dimension of pipelines


Step: check their validity
Step: calculate the cross sectional area
Step: calculate the volume of steel
Step: calculate the weight
Step: Output the result i.e. weight

6. Concept of programs and Data


A program is sequence of executable, unambiguous instructions written in a computer language.
The computer can understand instructions of various types.
(i)
(ii)
(iii)
(iv)
(v)

Input/output instruction: to input data into the computer and output answers of it.
assignment instruction: to rearrange the data.
Arithmetic instruction: to perform calculations
Control instruction: to control selection & repetition of actions
Logic instructions: to help the computer make choices

(i)

Input/output instruction
Input refers to data sent to the computer processor from a file on an automatic storage
device or from an outside source (keyboard, external device).
Output refers to the datra sent out from the computer processor to automatic storage
device or to an outside device (printer, monitor).

(ii)

Assignment instruction
Assignment refers to the copying of data from one memory location to another. For
example
a = b;
in C language
does not mean that a and b are the same thing. Its meaning is the value contained in the
memory location named b is copied into the memory location named a. after this
assignment instruction whatever the memory location a contains, memory location b will
also contain the same value.

(iii)

Arithmetic instruction
Arithmetic instruction refers to the basic arithmetic operation of addition, subtraction,
multiplication, division, remainder and exponentiation and assigning the answer to a
variable.
a = 2.5 + 6.5 / 3.25;

(iv)

Control instruction

CHAPTER I
Control instructions are used to switch from one set of instruction to another set of
instruction depending upon the logical comparison of data values. For example, the
computer might choose between addition or subtraction depending on whether a number
is + or not.
if ( x > o)
z = x + 5;
else
z = x - 5;
MATLAB m-file
%this program adds first integer value

N = input('\nEnter the value of N: '); %input instruction


j = 1;

%assignment instruction

total = 0;

%assignment instruction

while N > j

%control instruction

total = total + j;
j = j + 1;
end

%arithmetic instruction
%arithmetic instruction
%control assignment

fprintf('Sum is = %d', total); %output instruction

______________________________________________________________
C program
//PROGRAM TO DETERMINE THE SUM OF FIRST INTEGER
#include <stdio.h>
//MODULE OF SYSTEM LIBRARY
#include <math.h>
int N;
int j, total;

//ASSIGNING VARIABLES

int main()
{
j = 1;
total = 0;
printf("PLEASE ENTER A VALUE=");
scanf("%d", &N);

//ASSIGNMNET INSTRUCTION

while (N > j)
{
total = total + j;
j = j + 1;

//OUTPUT INSTRUCTION
//READING THE INPUT DATA & STORING
//IT IN MEMORY LOCATION
//CONDITIONS OF LOOPING

}
printf("THE SUM IS=%d\n", total);
return 0;

//ARITHMATHICAL INSTRUCTION

//OUTPUT INSTRUCTION
//END OF PROGRAM

}________________________________________________________________

CHAPTER I

7. Flowchart
A flowchart uses standard symbols to show different operations and order of execution of the
steps of the algorithm. Lines and arrows are used to show the flow of control.
Start

Input N

N>j?

False

True
total = total + 1
j =j + 1

total = total + j

Print total

Fig: 1.7 shows the


flowchart for adding first integer value.
Stop
Process Box: this is a rectangle box with one control line into it and one leading out, used to move
data from one memory place to another place in memory, computes etc.
Statement

Input/outputbox: this is a parallelogram symbole with one control into it and one leading out, used to
represent input/output statemnt.

CHAPTER I

Input/output

Decesion box: a diamond shaped symbole used for the comparison of quantiites for equality.

False

Decision

True

Connector: A small circle is used as a connector symbol when two flow lines are to be coming
together.

Flow lines: it is used to connect process box and decision box symbols in the order of the logic and
control flow of the program.

8. Program processing, compilation, testing & execution


Once the algorithm and flowchart have been prepared carefully, the computer program can be
written. The program consists of source code and documentation.
Source code: Source code means data specification and instruction for the computer to interpret.
Documentation: documentation means comments the code and the whole programming process as
an aid to the programmer and the other people who may need to read or alter the code.
When the programmer finishes the editing of program in an editor, it has to be submitted to the
computer for checking error. The errors in a program are called bugs and the process of detecting
and removing them is called debugging.
The first step in testing and debugging a program on the computer is called compilation.
Compilation is done by compiler. In all IDE software, the compilers are integrated. The compilers
not only checks for errors in grammar, spelling and punctuation but also converts the source code
to object code (machine language). Usually it is necessary to compile the code several times,
making corrections, before it compiles correctly.
The resulting object code is linked to the modules (module is part of a program) of the system
library. This is called build. Again there is a possibility of error if all of the modules are not
linked properly.

CHAPTER I
When a program finally links correctly, it is executed using input data and providing output data.
Demo: Program executing in MATLAB m-file and in C
9. Introduction to string, float, and types of float, integer, long & short integer
Variables
A variable is an entity that may change. In any program we typically do lots of calculations.
The results of these calculations are stored in computers memory. Like human memory the
computer memory also consists of millions of cells. The calculated values are stored in these
memory cells. To make the retrieval and usage of these values easy these memory cells (also
called memory locations) are given names. These names are called variables. Since the value
stored in each location may change, the names given to these locations are called variable.
Variables Type (i) string, integer, float, long integer, short integer
String: Strings are sequences of characters
Float number: real numbers are also known as floating-point numbers. The numbers 5.5, 8.3,
and -12.6 are all floating point numbers.
Integer: Integer numbers have no fractional part or decimal point. Numbers such as 1, 87,
and -222 are integers. The number 8.3 is not an integer because it contains a decimal point.
Assigning long integer means we wish to allocate extra storage for the integer. If we are going
to use small numbers and wish to reduce storage, we use short integer.

`Table 1.1: Simple Operator


OPERATOR
MEANING
*
Multiply
/
Divide
+
Add
Subtract
%
Modulus

CHAPTER I

También podría gustarte