You are on page 1of 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.)

the software running in your DVD player. before they are processed. It also saves the data for the later use. Therefore we need to input the data and instructions into the computers. 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. Other commonly used input devices are the mouse. scanner etc.CHAPTER I Workstations: workstations are capable of large computation. software running your cell phone. Hardware Components & Functions (i) Input Unit: Computers need to receive data and instruction in order to solve any problem. This memory is generally used to hold the program being currently executed in the computer. (i) (ii) (iii) Hardware: hardware means the collection of all the physical components that constitute a computer. Keyboard is the one of the most commonly used input device. your car computer system. Software: software is the collection of all the programs that run on the hardware of the computer. (ii) Computer systems: computer system consists of hardware. the software running in your Internet firewall/router. # Convert it to a form that the computer can understand. Pen drive. software and firmware. 2. etc. the data being received . Some examples include. (a) Primary Storage: Stores and provides very fast. All the input devices perform the following functions. The various storage devices of a computer system are divided into two categories. (ii) Storage Unit: The storage unit of the computer holds data and instructions that are entered through the input unit. The input unit consists of one or more input devices. In a computer that would be the ROM/BIOS. Firmware: firmware is the part of hardware that is permanently programmed. CD/DVD/BLUERAY. It preserves the intermediate and final results before these are sent to the output devices. # Supply the converted data to the computer system for further processing. # Accept the data and instructions from the outside world.

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). The primary memory is temporary in nature. The 64-bit version of Windows handles large amounts of random access memory (RAM) more effectively than a 32-bit system. the smallest unit of information on a machine. (v) Arithmetic Logical Unit (ALU): It is the part of a computer processor (CPU). (iii) Memory Size: All digital computers use the binary system. Some of the commonly used secondary memory devices are Hard disk. =. 0’s and 1’s. In a way. data bases etc. i. <. light. The control unit is generally referred as the central nervous system of the computer that control and synchronizes it’s working. documents. Bit means in short for binary digit. The set of 8 bits is called a byte. the results are transferred to the storage unit by the control unit and then it is send to the output unit for displaying results. (vii) Central Processing Unit: . It also does comparison and takes decision. and coordinates the activities of the other units within it. (iv) Output Unit: The output unit of a computer provides the information and results of a computation to outside world. For example random-access memory (RAM) is the Primary Storage device. subtraction. as it controls what happens inside the processor. handles information. ‘etc. Printers. It controls the flow of data and instructions from the storage unit to ALU. the intermediate and final results of the program. A numeric occupies 2 byte space. but quite expensive at the same time (b) Secondary Storage: Secondary storage is used like an archive. The ALU can perform basic operations such as addition. It stores several programs. division. It is smallsized. monitor are the commonly used output devices. It also controls the flow of results from the ALU to the storage unit. In order to store the data permanently. when the computer is switched off. It controls all other units in the computer. All calculations are performed in the Arithmetic Logic Unit (ALU) of the computer. it is the "brain within the brain". again they get stored in the secondary memory. the data has to be transferred to the secondary memory. multiplication.CHAPTER I from the input unit. Byte is the space occupied in the memory. CD. etc and does logic operations viz. The programs that you run on the computer are first transferred to the primary memory before it is actually run. The data is lost. Therefore most computers have limited primary storage capacity. The control unit instructs the input unit. etc. Whenever calculations are required. (vi) Control Unit: The control unit is the circuitry that controls the flow of information through the processor. where to store the data after receiving it from the user.e. the control unit transfers the data from storage unit to ALU once the computations are done. >. Whenever the results are saved. A character occupies 1 byte space.

Algorithm & program development . It takes all decisions. Processor Manufacturers * American Micro Devices (AMD) * Intel * IBM * Motorola * Cyrix * Texas Instruments 3. 4. Low-level language: Assembly language and machine oriented languages are called low-level language. (v) Debug: In computers. Low-level languages can be converted to machine code without using a compiler or interpreter. and with a very small memory footprint. Software Components & Functions (i) Program: a program is a sequence of instructions written in a programming language that directs a computer in problem solving. (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. and the resulting code runs directly on the processor. (iv) Compilers: compilers are the language system that translates programs written in highlevel language such as C. The CPU is like brain performs the following functions: It performs all calculations. into machine code which the hardware can interpret and execute directly. (a) Operating system: it makes the system facilities available to the application programs and controls their use. java etc. (ii) Software: Software consists of program written to support the basic operations of the system and program written to carry out an application.CHAPTER I    The control unit and ALU of the computer are together known as the Central Processing Unit (CPU). It controls all units of the computer. High-level language: languages that are reasonably machine independent and people oriented are called high-level language. C++. debugging is the process of locating and fixing or bypassing bugs (errors) in computer program code. (b) Language system: language systems are classified as high-level and low-level languages. A program written in a low-level language can be made to run very fast.

Each step of an algorithm must be an unambiguous (Having or exhibiting a single clearly defined meaning) instruction which. division. 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. (ii) Assignment instruction Assignment refers to the copying of data from one memory location to another. 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. remainder and exponentiation and assigning the answer to a variable. Calculate in kg.CHAPTER I Solving a problem on a computer requires a thorough understanding and analysis of the problem and data. Example: the following example shows the algorithm to solve a design problem. in C language does not mean that a and b are the same thing. total amount of steel required to build a pipeline to carry water. when written in a computer language. can be executed by a computer. assignment instruction: to rearrange the data. 2. Output refers to the datra sent out from the computer processor to automatic storage device or to an outside device (printer. after this assignment instruction whatever the memory location a contains. (i) (ii) (iii) (iv) (v) Input/output instruction: to input data into the computer and output answers of it. monitor).e.5 / 3. Once the problem has been analyzed. the detailed design of a solution can be developed. memory location b will also contain the same value. subtraction.25. One of the steps in designing and developing a computerized solution to a problem is to develop an algorithm to solve the problem. unambiguous instructions written in a computer language. For example a = b. The computer can understand instructions of various types. Its meaning is the value contained in the memory location named b is copied into the memory location named a. 6. 3. 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. Concept of programs and Data A program is sequence of executable. multiplication.5 + 6. a = 2. 1. (iii) Arithmetic instruction Arithmetic instruction refers to the basic arithmetic operation of addition. 5. external device). 4. weight 6. (iv) Control instruction . 5.

&N). total = 0. //ASSIGNING VARIABLES int main() { j = 1.h> int N. //ASSIGNMNET INSTRUCTION while (N > j) { total = total + j. MATLAB m-file %this program adds first integer value N = input('\nEnter the value of N: '). the computer might choose between addition or subtraction depending on whether a number is + or not. end %arithmetic instruction %arithmetic instruction %control assignment fprintf('Sum is = %d'. %assignment instruction while N > j %control instruction total = total + j. return 0. scanf("%d".h> //MODULE OF SYSTEM LIBRARY #include <math. //OUTPUT INSTRUCTION //READING THE INPUT DATA & STORING //IT IN MEMORY LOCATION //CONDITIONS OF LOOPING } printf("THE SUM IS=%d\n". %input instruction j = 1. printf("PLEASE ENTER A VALUE="). j = j + 1. if ( x > o) z = x + 5. total.5. //ARITHMATHICAL INSTRUCTION //OUTPUT INSTRUCTION //END OF PROGRAM }________________________________________________________________ . total). int j. j = j + 1. total). else z = x . %output instruction ______________________________________________________________ C program //PROGRAM TO DETERMINE THE SUM OF FIRST INTEGER #include <stdio. For example.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. %assignment instruction total = 0.

used to move data from one memory place to another place in memory. Lines and arrows are used to show the flow of control.CHAPTER I 7. . Statement Input/outputbox: this is a parallelogram symbole with one control into it and one leading out. Stop Process Box: this is a rectangle box with one control line into it and one leading out. Start Input N N>j? False True total = total + 1 j =j + 1 total = total + j Print total Fig: 1. Flowchart A flowchart uses standard symbols to show different operations and order of execution of the steps of the algorithm. used to represent input/output statemnt. computes etc.7 shows the flowchart for adding first integer value.

spelling and punctuation but also converts the source code to object code (machine language). 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. False Decision True Connector: A small circle is used as a connector symbol when two flow lines are to be coming together. 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. The compilers not only checks for errors in grammar. . the compilers are integrated. When the programmer finishes the editing of program in an editor. The resulting object code is linked to the modules (module is part of a program) of the system library. Usually it is necessary to compile the code several times. The first step in testing and debugging a program on the computer is called compilation. The program consists of source code and documentation. the computer program can be written. The errors in a program are called bugs and the process of detecting and removing them is called debugging. testing & execution Once the algorithm and flowchart have been prepared carefully. This is called build.CHAPTER I Input/output Decesion box: a diamond shaped symbole used for the comparison of quantiites for equality. Again there is a possibility of error if all of the modules are not linked properly. In all IDE software. Source code: Source code means data specification and instruction for the computer to interpret. Compilation is done by compiler. 8. Program processing. before it compiles correctly. it has to be submitted to the computer for checking error. compilation. making corrections.

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

CHAPTER I .