cp unit i complete

36
UNIT I INTRODUCTION Generation and Classification of Computers Basic Organization of a Computer Number System Binary – Decimal – Conversion – Problems Need for logical analysis and thinking o Algorithm o Pseudo code o Flow Chart LEARNING OBJECTIVES: To learn about the origin of the computer system To enable the student to learn the major components of a computer system To know about different conversions in number system To know the correct and efficient ways of solving problems LEARNING OUTCOMES: Knows about the basics of computers Solve the problems related to number systems( Conversions) Able to think logically and write own Algorithm and Pseudocode for the given problem Able to draw own Flowchart for the given problem 1

Upload: pradhibaselvarani

Post on 18-Jul-2016

225 views

Category:

Documents


2 download

DESCRIPTION

CP Unit I

TRANSCRIPT

Page 1: CP Unit I Complete

UNIT I

INTRODUCTION

Generation and Classification of Computers

Basic Organization of a Computer

Number System

Binary – Decimal – Conversion – Problems

Need for logical analysis and thinking

o Algorithm

o Pseudo code

o Flow Chart

LEARNING OBJECTIVES:

To learn about the origin of the computer system

To enable the student to learn the major components of a computer system

To know about different conversions in number system

To know the correct and efficient ways of solving problems

LEARNING OUTCOMES:

Knows about the basics of computers

Solve the problems related to number systems( Conversions)

Able to think logically and write own Algorithm and Pseudocode for the given problem

Able to draw own Flowchart for the given problem

1

Page 2: CP Unit I Complete

GENERATION AND CLASSIFICATION OF COMPUTERS

GENERATION OF COMPUTERSThe Zeroth Generation

The term Zeroth generation is used to refer to the period of development of computing, which predated the commercial production and sale of computer equipment. The period might be dated as extending from the mid-1800s. In particular, this period witnessed the emergence of the first electronics digital computers on the ABC, since it was the first to fully implement the idea of the stored program and serial execution of instructions. The development of EDVAC set the stage for the evolution of commercial computing and operating system software. The hardware component technology of this period was electronic vacuum tubes. The actual operation of these early computers took place without be benefit of an operating system. Early programs were written in machine language and each contained code for initiating operation of the computer itself. This system was clearly inefficient and depended on the varying competencies of the individual programmer as operators.

The First generation, 1951-1956

The first generation marked the beginning of commercial computing. The first generation was characterized by high-speed vacuum tube as the active component technology. Operation continued without the benefit of an operating system for a time. The mode was called "closed shop" and was characterized by the appearance of hired operators who would select the job to be run, initial program load the system, run the user’s program, and then select another job, and so forth. Programs began to be written in higher level, procedure-oriented languages, and thus the operator’s routine expanded. The operator now selected a job, ran the translation program to assemble or compile the source program, and combined the translated object program along with any existing library programs that the program might need for input to the linking program, loaded and ran the composite linked program, and then handled the next job in a similar fashion. Application programs were run one at a time, and were translated with absolute computer addresses. There was no provision for moving a program to different location in storage for any reason. Similarly, a program bound to specific devices could not be run at all if any of these devices were busy or broken.

At the same time, the development of programming languages was moving away from the basic machine languages; first to assembly language, and later to procedure oriented languages, the most significant being the development of FORTRAN

The Second Generation, 1956-1964

The second generation of computer hardware was most notably characterized by transistors replacing vacuum tubes as the hardware component technology. In addition, some very important changes in hardware and software architectures occurred during this period. For the most part, computer systems remained card and tape-oriented systems. Significant use of random access devices, that is, disks, did not appear until towards the end of the second generation. Program processing was, for the most part, provided by large centralized computers operated under mono-programmed batch processing operating systems.

The most significant innovations addressed the problem of excessive central processor delay due to waiting for input/output operations. Recall that programs were executed by

2

Page 3: CP Unit I Complete

processing the machine instructions in a strictly sequential order. As a result, the CPU, with its high speed electronic component, was often forced to wait for completion of I/O operations which involved mechanical devices (card readers and tape drives) that were order of magnitude slower.

These hardware developments led to enhancements of the operating system. I/O and data channel communication and control became functions of the operating system, both to relieve the application programmer from the difficult details of I/O programming and to protect the integrity of the system to provide improved service to users by segmenting jobs and running shorter jobs first (during "prime time") and relegating longer jobs to lower priority or night time runs. System libraries became more widely available and more comprehensive as new utilities and application software components were available to programmers.

The second generation was a period of intense operating system development. Also it was the period for sequential batch processing. Researchers began to experiment with multi programming and multiprocessing.

The Third Generation, 1964-1979

The third generation officially began in April 1964 with IBM’s announcement of its System/360 family of computers. Hardware technology began to use integrated circuits (ICs) which yielded significant advantages in both speed and economy. Operating System development continued with the introduction and widespread adoption of multiprogramming. This marked first by the appearance of more sophisticated I/O buffering in the form of spooling operating systems. These systems worked by introducing two new systems programs, a system reader to move input jobs from cards to disk, and a system writer to move job output from disk to printer, tape, or cards. The spooling operating system in fact had multiprogramming since more than one program was resident in main storage at the same time. Later this basic idea of multiprogramming was extended to include more than one active user program in memory at time. To accommodate this extension, both the scheduler and the dispatcher were enhanced. In addition, memory management became more sophisticated in order to assure that the program code for each job or at least that part of the code being executed was resident in main storage. Users shared not only the system’ hardware but also its software resources and file system disk space.

The third generation was an exciting time, indeed, for the development of both computer hardware and the accompanying operating system. During this period, the topic of operating systems became, in reality, a major element of the discipline of computing.

The Fourth Generation, 1979 - Present

The fourth generation is characterized by the appearance of the personal computer and the workstation. Miniaturization of electronic circuits and components continued and Large Scale Integration (LSI), the component technology of the third generation, was replaced by Very Large Scale Integration (VLSI), which characterizes the fourth generation. However, improvements in hardware miniaturization and technology have evolved so fast that we now have inexpensive workstation-class computer capable of supporting multiprogramming and time-sharing. Hence the operating systems that supports today’s personal computers and

3

Page 4: CP Unit I Complete

workstations look much like those which were available for the minicomputers of the third generation. Examples are Microsoft’s DOS for IBM-compatible personal computers and UNIX for workstation.

However, many of these desktop computers are now connected as networked or distributed systems. Computers in a networked system each have their operating system augmented with communication capabilities that enable users to remotely log into any system on the network and transfer information among machines that are connected to the network. The machines that make up distributed system operate as a virtual single processor system from the user’s point of view; a central operating system controls and makes transparent the location in the system of the particular processor or processors and file systems that are handling any given program.

CLASSIFICATION OF COMPUTERS

Computers are available in different shape, size and weights. Due to these different shapes and sizes they perform different sorts of jobs from one another. A computer that is used in home differs in size and shape from the computer being used in hospital.

Fig 1. Classifications of Computers

BASED ON HARDWARE DESIGN

Based on hardware design computers are classified into three categories. They are Analog Computers, Digital Computers, and Hybrid Computers.

Analog ComputerA computing machine that operates on data in the form of continuously variable physical

quantities is known as analog computer. These computers do not deal directly with the numbers. They measure continuous physical magnitudes (e.g. temperature, pressure and voltage), which are analogous to the numbers under consideration.

Analog computers are used for scientific and engineering purposes. One of the characteristics of these computers is that they give approximate results since they deal with quantities that vary continuously. The main feature of analog computers is that they are very fast in operation as all the calculations are done in 'parallel mode'. It is very easy to get graphical results directly using analog computer. However, the accuracy of analog computers is less.

4

Page 5: CP Unit I Complete

Digital Computer A computer that operates with information, numerical or otherwise, represented in a digital

form is known as digital computer. Such computers process data (including text, sound, graphics and video) into a digital value (in 0s and 1s).

Digital computers can give the results with more accuracy and at a faster rate. The accuracy of such computers is limited only by the size of their registers and memory. The desktop PC is a classic example of digital computer.Hybrid Computer (Analog + Digital)

 Hybrid computer incorporated the measuring feature of an analog computer and counting feature of a digital computer. For computational purposes, these computers use the analog components and for the storage of intermediate results, digital memories are used. To bind the powers of analog and digital techniques, that is, analog to digital and digital to analog, the hybrid computers comprehensively use converters. Such computers are broadly used in scientific applications, various fields of engineering and industrial control processes.

BASED ON UTILITY Based on utility computers are classified into two categories. They are General-purpose

Computers and Specific-purpose ComputersGeneral-purpose Computers

A general-purpose computer, as the name suggests, is designed to perform a range of tasks. These computers have the ability to store numerous programs. These machines can be used for various applications, ranging from scientific to business-purpose applications. Even though such computers are versatile, they generally lack in speed and efficiency.

The computers used in schools and homes are general-purpose computers.Specific-purpose Computers

These computers are designed to handle a specific problem or to perform a single specific task. A set of instructions for the specific task is built into the machine. Hence, they cannot be used for other applications unless their circuits are redesigned, that is, they lack versatility. However, being designed for specific tasks, they can provide the result very quickly and efficiently.

These computers are used for airline reservations, satellite tracking and air traffic control.

BASED ON SIZE AND CAPACITYBased on size and Capacity computers are classified into four categories. They are Micro

Computers, Mini Computers, Mainframe Computers, and Super Computers.Micro Computers

Micro computer is a small, low cost digital computer, which usually consists of microprocessor, a storage unit, an input channel, and an output channel, all of which may be on one chip inserted into one or several PC boards. It is the smallest of the computer family. They were designed for individual users only, but nowadays they have become powerful tools for many businesses that, when networked together, can serve more than one user.

IBM-PC Pentium 100, IBM-PC Pentium 200, and Apple Macintosh are examples. Micro computers include desktop, laptop and hand-held computers.

Characteristics of Micro Computers They brought revolution in the history of computers. They are cheap and user friendly.

5

Page 6: CP Unit I Complete

They are having limited peripherals attached to them. Their operation can be easily learnt by anyone having logical aptitude. Children enjoy playing games & watching movies in these computers. Most popular micro computer’s processing chip manufacturing company is Intel.

Fig 2. Micro Computer Fig 3. Mini Computer

Mini ComputersA Mini computer is a small digital computer, which normally is able to process and store less

data than a mainframe but more than a micro computer. It is also called as mid-range computer designed to meet the computing needs for several

people simultaneously in a small to medium size business environment. It is a multiprocessing system capable of supporting from 4 to about 200 users simultaneously. It serves as a centralized storehouse for cluster of work stations or as a network server.

Some of the widely used mini computers are PDP 11, IBM (8000 series) and VAX 7500. Characteristics of Mini Computers

They have less memory & storage capacity than mainframe computers. They offer limited range of peripherals. Limited range of software can be used by them. The end users can directly operate it. They are not very sensitive to the external environment and hence are more generalised. They are used for data processing.

Mainframe ComputersMainframe is an ultra-high performance computer made for high-volume, processor-intensive

computing. It is very large and expensive computer capable of supporting hundreds, or even thousands, of users simultaneously. 

Mainframe computers are powerful computers used mainly by large organisations for critical applications, typically bulk data processing such as census, industry and consumer statistics, enterprise resource planning, and financial transaction processing. 

Examples of mainframe computers are IBM’s ES000, VAX 8000 and CDC 6600.

Characteristics of Mainframe Computers They are big computer systems sensitive to temperature, humidity, dust etc. Qualified & trained operators are required to operate them. They have wide range of peripherals attached. They have large storage capacity.

6

Page 7: CP Unit I Complete

They can use wide variety of software. They are not user friendly. They can be used for more mathematical calculations. They are installed in large commercial places or government organizations.

Fig 4. Mainframe Computer Fig 5. Super Computer

Super ComputersSuper computers are the special purpose machines, which are specially designed to maximise

the numbers of FLOPS (Floating point Operation Per Second). It has the highest processing speed at a given time for solving scientific and engineering problems. They can resolve complex mathematical equations in a few hours, which would have taken a scientist with paper and pencil a lifetime, or years, using a hand calculator. It basically consists of number of CPUs that operate in parallel to make it faster.

Examples of super computers are CRAY-3, Cyber 205, and PARAM. Characteristics of Super Computers

They are the fastest, costliest and most powerful computers available today. They are huge computers installed in space centres, nuclear power stations etc. They are used for performing complex mathematical calculations. Only scientists and mathematicians can operate them. They are having huge memories & tremendous processing speed. They are used for weather forecasting, animation graphics etc.

BASED ON MODE OF USEBased on mode of use computers are classified into four categories. They are Palmtop,

Desktop, Personal Computers, Workstations and Client and Server.

PalmtopIt is a small computer that literally fits in your palm. Compared to full-size

computers, palmtops are severely limited, but they are practical for certain functions such as phone books and calendars. Palmtops that use a pen rather than a keyboard for input are often called hand-held computers or PDAs (Personal Digital Assistant).

Because of their small size, most palmtop computers do not include disk drives. However, many contain PCMCIA slots in which you can insert disk drives, modems,  memory, and other devices.

7

Page 8: CP Unit I Complete

DesktopThis type of computer would contain most of the computer components, such as the CPU,

the hard disk, and the RAM, within a single case that would sit horizontally on a desktop. A monitor would then sit on top of the desktop computer case, and an external mouse and keyboard would attach to it.

Desktop models designed to be very small are sometimes referred to as slimline models. In general, a desktop computer describes any traditional computer a home user uses.

Personal ComputersPersonal computers are computers that are meant to be used by individuals in homes or

offices. Their retail prices, size, and capabilities make them practical for use in almost every home and office in developed countries. The operation of these computers relies on a small computer chip known as a microprocessor, which governs the functioning of the computer.

WorkstationsA workstation is a high-end microcomputer designed for technical or scientific applications.

Intended primarily to be used by one person at a time, they are commonly connected to a local area network and run multi-user operating systems.

Clients and ServersClient/server describes the relationship between two computer programs in which one

program, the client, makes a service request from another program, the server, which fulfils the request.

The client/server model has become one of the central ideas of network computing. Most business applications being written today use the client/server model.

BASIC ORGANIZATION OF COMPUTERS

8

Fig 6. Basic Organization of Computers

Page 9: CP Unit I Complete

A computer as shown in Fig 1 performs basically five major operations or functions irrespective of their size and make. These are 1) it accepts data or instructions by way of input, 2) it stores data, 3) it can process data as required by the user, 4) it gives results in the form of output, and 5) it controls all operations inside a computer. We discuss below each of these operations.

1. Input Unit: This is the process of entering data and programs into the computer system. Computer is an

electronic machine like any other machine which takes as inputs raw data and performs some processing giving out processed data. Therefore, the input unit takes data from us to the computer in an organized manner for processing.Typical Input devices are:

Keyboard Mouse Joystick Smart Cards

2. Storage: The process of saving data and instructions permanently is known as storage. Data has to be

fed into the system before the actual processing starts. It is because the processing speed of Central Processing Unit (CPU) is so fast that the data has to be provided to CPU with the same speed. Therefore the data is first stored in the storage unit for faster access and processing. This storage unit or the primary storage of the computer system is designed to do the above functionality. It provides space for storing data and instructions.The storage unit performs the following major functions:

All data and instructions are stored here before and after processing. Intermediate results of processing are also stored here.

3. Processing: The task of performing operations like arithmetic and logical operations is called processing.

The Central Processing Unit (CPU) takes data and instructions from the storage unit and makes all sorts of calculations based on the instructions given and the type of data provided. It is then sent back to the storage unit.4. Output Unit: 

This is the process of producing results from the data for getting useful information. Similarly the output produced by the computer after processing must also be kept somewhere inside the computer before being given to you in human readable form. Again the output is also stored inside the computer for further processing.Types of Output device

Printing: Printer, PlotterSound: SpeakersVisual: Monitor

5. Control: The manner how instructions are executed and the above operations are performed.

Controlling of all operations like input, processing and output are performed by control unit. It takes care of step by step processing of all operations inside the computer.

CENTRAL PROCESSING UNIT (CPU) 9

Page 10: CP Unit I Complete

The ALU and the CU of a computer system are jointly known as the central processing unit. You may call CPU as the brain of any computer system. It is just like brain that takes all major decisions, makes all sorts of calculations and directs different parts of the computer functions by activating and controlling the operations.

1) Arithmetic Logical Unit (ALU)After you enter data through the input device it is stored in the primary storage unit. The

actual processing of the data and instruction are performed by Arithmetic Logical Unit. The major operations performed by the ALU are addition, subtraction, multiplication, division, logic and comparison. Data is transferred to ALU from storage unit when required. After processing the output is returned back to storage unit for further processing or getting stored.

2) Control Units (CU)The next component of computer is the Control Unit, which acts like the supervisor seeing

that things are done in proper fashion. The control unit determines the sequence in which computer programs and instructions are executed. Things like processing of programs stored in the main memory, interpretation of the instructions and issuing of signals for other units of the computer to execute them. It also acts as a switch board operator when several users access the computer simultaneously. Thereby it coordinates the activities of computer’s peripheral equipment as they perform the input and output. Therefore it is the manager of all operations mentioned in the previous section.

MEMORY UNITThe fundamental components of a general-purpose computer are arithmetic and logic unit,

control circuitry, storage space, and input/output devices. If storage was removed, the device we had would be a simple calculator instead of a computer.

We can classify memory into two broad categories: Primary memory and Secondary memory.

Pr i m ar y Memory Primary storage or Internal memory or Main memory, is computer memory that is

accessible to the central processing unit of a computer without the use of computer's input/output channels. It is the main area in a computer in which data is stored for quick access by the computer's processor.

Primary Memory can be further classified into Random Access Memory (RAM) and Read Only memory (ROM)

1)Random Access MemoryRAM is like the computer’s scratch pad. It allows the computer to keep track of what is

currently being processed. It is much faster to read from and write to than the other kinds of storage in a computer like the

hard disk of floppy disk. However, RAM is volatile in nature; the data in RAM stays there only as long as the computer is running. When the computer is turned off, RAM loses all its contents.

2) Read Only memory10

Page 11: CP Unit I Complete

ROM is a type of "built-in" memory that is capable of holding data and having that data read from the chip, but not written to. Unlike Random Access Memory (RAM), ROM is non-volatile which means it keeps its contents regardless if it has power or not. A good example of ROM is EEPROM, which is a programmable ROM used for the computer BIOS.

Secondary Memory

Secondary Memory also known as auxiliary storage, secondary memory or external memory, is used to store a large amount of data at lesser cost per byte than primary memory. It is the slowest and cheapest form of memory. It cannot be processed directly by the CPU. It must first be copied into primary storage (also known as RAM ). It non-volatile and persistent in nature and is not directly accessed by a computer/processor. It allows a user to store data that may be instantly and easily retrieved, transported and used by applications and services.

Secondary memory devices include magnetic disks like hard drives and floppy disks ; optical disks such as CDs and CDROMs ; and magnetic tapes, which were the first forms of secondary memory.

NUMBER SYSTEM

Binary Decimal Octal Hexadecimal0000 00 0 00001 01 1 10010 02 2 20011 03 3 30100 04 4 40101 05 5 50110 06 6 60111 07 7 71000 08 1 0 81001 09 1 1 91010 10 12 A1011 11 13 B1100 12 14 C1101 13 15 D1110 14 16 E

1111 15 17 F

DECIMAL NUMBERS

In the decimal number systems each of the ten digits, 0 through 9, represents a certain quantity. The position of each digit in a decimal number indicates the magnitude of the quantity represented and can be assigned a weight. The weights for whole numbers are positive powers of ten that increases from right to left, beginning with 10º = 1 that is 10³ 10² 10¹ 10º

For fractional numbers, the weights are negative powers of ten that decrease from left to 11

Page 12: CP Unit I Complete

right beginning with 10-1 that is 10² 10¹ 10º. 10-1 10-2 10-3

The value of a decimal number is the sum of digits after each digit has been multiplied by its weights as in following examplesExpress the decimal number 87 as a sum of the values of each digit.

The digit 8 has a weight of 10 which is 10 as indicated by its position. The digit 7 has a weight of 1 which is 10º as indicated by its position.

87 = (8 x 101) + (7 x 100)

Express the decimal number 725.45 as a sum of the values of each digit.

725. 45 = (7 x 10²) + (2 x 10¹) + (5 x 10º) + (4 x 10-1) + (5 x 10-2) = 700 + 20 + 5 + 0.4 + 0.05

BINARY NUMBE R S

The binary system is less complicated than the decimal system because it has only two digits; it is a base- two system. The two binary digits (bits) are 1 and 0. The position of a 1 or 0 in a binary number indicates its weight, or value within the number, just as the position of a decimal digit determines the value of that digit. The weights in a binary number are based on power of two as:

….. 24 2³ 22 21 20. 2-1 2-2 ….With 4 digits position we can count from zero to 15.In general, with n bits we can count up

to a number equal to K - 1. Largest decimal number = K - 1.A binary number is a weighted number. The right-most bit is the least significant bit (LSB) in a binary whole number and has a weight of 2º =1. The weights increase from right to left by a power of two for each bit. The left-most bit is the most significant bit (MSB); its weight depends on the size of the binary number.

BINARY-TO-DECIMAL CONVERSION

The decimal value of any binary number can be found by adding the weights of all bits that are 1 and discarding the weights of all bits that are 0

Example

Let’s convert the binary whole number 101101 to decimal

Weight: 25 24 23 22 21 20

Binary no: 1 0 1 1 0 1

Value 32 0 8 4 0 1

Sum = 45

12

Page 13: CP Unit I Complete

HEXAD E CIMAL NUMBERS

The hexadecimal number system has sixteen digits and is used primarily as a compact way of displaying or writing binary numbers because it is very easy to convert between binary and hexadecimal. Long binary numbers are difficult to read and write because it is easy to drop or transpose a bit. Hexadecimal is widely used in computer and microprocessor applications. The hexadecimal system has a base of sixteen; it is composed of 16 digits and alphabetic characters. The maximum 3-digits hexadecimal number is FFF or decimal 4095 and maximum 4-digit hexadecimal number is FFFF or decimal 65.535.

BINARY-T O -HEXADECIMAL CON V ER S I ON

Simply break the binary number into 4-bit groups, starting at the right-most bit and replace each 4-bit group with the equivalent hexadecimal symbol as in the following example

Convert the binary number to hexadecimal: 1100101001010111Solution:1100 1010 0101 0111C A 5 7 = CA57

HEXADE CIMAL-TO-DECIMAL CONVERSION

One way to find the decimal equivalent of a hexadecimal number is to first convert the hexadecimal number to binary and then convert from binary to decimal.

Convert the hexadecimal number 1C to decimal:

1 C

0001 1100 = 24+ 2³ + 2² = 16 +8+4 = 28

DECIMAL-TO-HEXADECIMAL CONVERSION

Repeated division of a decimal number by 16 will produce the equivalent hexadecimal number, formed by the remainders of the divisions. The first remainder produced is the least significant digit (LSD).Each successive division by 16 yields a remainder that becomes a digit in the equivalent hexadecimal number. When a quotient has a fractional part, the fractional part is multiplied by the divisor to get the remainder.

Convert the decimal number 650 to hexadecimal by repeated division by 16

650 /16 = 40.625 0.625 x 16 = 10 = A (LSD)40 /16 = 2.5 0.5 x 16 = 8 =82/16 = 0.125 0.125 x 16 = 2 = 2 (MSD) The hexadecimal number is 28A

13

Page 14: CP Unit I Complete

OCTAL NUMBERS

Like the hexadecimal system, the octal system provides a convenient way to express binary numbers and codes. However, it is used less frequently than hexadecimal in conjunction with computers and microprocessors to express binary quantities for input and output purposes.

The octal system is composed of eight digits, which are:0, 1, 2, 3, 4, 5, 6, 7

To count above 7, begin another column and start over: 10, 11, 12, 13, 14, 15, 16, 17, 20, 21 and so on. Counting in octal is similar to counting in decimal, except that the digits 8 and 9 are not used.

OCTAL-TO-DECIMAL CONVERSION

Since the octal number system has a base of eight, each successive digit position is an increasing power of eight, beginning in the right-most column with 8º. The evaluation of an octal number in terms of its decimal equivalent is accomplished by multiplying each digit by its weight and summing the products.

Let’s convert octal number 2374 in decimal number.

Weight 8³ 8² 81 80

Octal number 2 3 7 4 2374 = (2 x 8³) + (3 x 8²) + (7 x 81) + (4 x 8º) =1276

DECIMAL-TO-OCTAL CONVERSION

A method of converting a decimal number to an octal number is the repeated division-by-8 method, which is similar to the method used in the conversion of decimal numbers to binary or to hexadecimal.

Let’s convert the decimal number 359 to octal.Each successive division by 8 yields a remainder that becomes a digit in the equivalent octal

number. The first remainder generated is the least significant digit (LSD).

359/8 = 44.875 0.875 x 8 = 7 (LSD)44 /8 = 5.5 0.5 x 8 = 45/8 = 0.625 0.625 x 8 = 5 (MSD)The number is 547.

OCTAL-TO-BINARY CONVERSION

Because each octal digit can be represented by a 3-bit binary number, it is very easy to convert from octal to binary.

Octal Digit 0 1 2 3 4 5 6 7Binary 000 001 010 011 100 101 110 111

14

Page 15: CP Unit I Complete

Let’s convert the octal numbers 25 and 140.

Octal Digit 2 5 1 4 0Binary 010 101 001 100 000

BINARY-TO-OCTAL CONVERSION

Conversion of a binary number to an octal number is the reverse of the octal-to-binary conversion.

Let’s convert the following binary numbers to octal:

1 1 0 1 0 1 1 0 1 1 1 1 0 0 16 5 = 65 5 7 1 = 571

NEED FOR LOGICAL ANALYSIS AND THINKING

A Computer program is basically a set of logical instructions, written in a computer programming language that tells the computer how to accomplish a task. The process of computer program development involves a series of standard steps that realize the solution of a real – world problem into a computer program. The process of program development starts with identifying the problem first. Once a problem is well understood and documented, a series of problem – solving techniques like algorithms, flowcharts and pseudocodes are carried out in arriving at the most efficient solution.

All the activities, which have to be performed by a user in order to solve a problem using computer, are grouped into three phases,

Identifying the purposeo Identifying parameters and constraintso Collecting information

Developing a programo Identifying the logical structureo Writing the computer programo Debugging the program

Executing the program

ALGORITHM

To make a computer  do anything, we have to write a computer program . To write a computer program, we have to tell the computer, step by step, exactly what we want it to do. The computer then "executes" the program, following each step mechanically, to accomplish the end goal.

When we are telling the computer what to do, we also get to choose how it's going to do it. That's where computer algorithms come in. The algorithm is the basic technique used to get the job done.

An Algorithm is a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.

15

Page 16: CP Unit I Complete

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 integers and display 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 an algorithm for performing the desired task. When solving a complex problem, it is possible to have more than one algorithm to provide the required solution. The algorithm that takes less time and requires less memory space is the best one.

Characteristics of an algorithmThe various characteristics that are necessary for a sequence of instruction to qualify as an

algorithm are: The instruction must be in an ordered form. The instruction must be simple and concise. They must not be ambiguous. There must be an instruction (condition) for program termination. The repetitive programming constructs must possess an exit condition. Otherwise, the

program might run infinitely. The algorithm must completely and definitely solve the given problem statements.

Qualities of a good algorithm Typically, an algorithm is considered as good, if : It uses the most efficient logic to solve the given problem statement .(time complexity) It uses minimal system memory for its execution .(space complexity) It is able to generate the most accurate results for a wide range of input set. It is easy to implement in the form of a program. It is designed with standard conventions so that others are able to easily modify it while

adding additional functionality.

Sample AlgorithmAlgorithm to add two integers and display the result

Step 1 – Accept the first integer as input from the user. (Integer 1)

Step 2 – Accept the second integer as input from the user. (Integer 2)

Step 3 – calculate the sum of the two integers. (Integer 3 = integer 1 + integer 2)

Step 4 – Display integer3 as the result.

FLOW CHART

Definitions:A flowchart is a schematic representation of an algorithm or a stepwise process, showing the

steps as boxes of various kinds, and their order by connecting these with arrows. Flowcharts are used in designing or documenting a process or program.

A flow chart, or flow diagram, is a graphical representation of a process or system that details the sequencing of steps required to create output.

16

Page 17: CP Unit I Complete

A flowchart is a picture of the separate steps of a process in sequential order.

ADVANTAGES OF USING FLOWCHARTS

The benefits of flowcharts are as follows:1. Communication: Flowcharts are better way of communicating the logic of a system to all

concerned.2. Effective analysis: With the help of flowchart, problem can be analysed in more effective

way.3. Proper documentation: Program flowcharts serve as a good program documentation,

which is needed for various purposes.4. Efficient Coding: The flowcharts act as a guide or blueprint during the systems analysis

and program development phase.5. Proper Debugging: The flowchart helps in debugging process.6. Efficient Program Maintenance: The maintenance of operating program becomes easy

with the help of flowchart. It helps the programmer to put efforts more efficiently on that part.

LIMITATIONS OF USING FLOWCHARTS

1. Complex logic: Sometimes, the program logic is quite complicated. In that case, flowchart becomes complex and clumsy.

2. Alterations and Modifications: If alterations are required the flowchart may require re-drawing completely.

3. Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart becomes a problem.

4. The essentials of what is done can easily be lost in the technical details of how it is done.

GUIDELINES FOR DRAWING A FLOWCHART17

Flowchart Symbols

Page 18: CP Unit I Complete

Flowcharts are usually drawn using some standard symbols; however, some special symbols can also be developed when required. Some standard symbols, which are frequently required for flowcharting many computer programs.

The following are some guidelines in flowcharting:

a. In drawing a proper flowchart, all necessary requirements should be listed out in logical order.

b. The flowchart should be clear, neat and easy to follow. There should not be any room for ambiguity in understanding the flowchart.

c. The usual direction of the flow of a procedure or system is from left to right or top to bottom.

d. Only one flow line should come out from a process symbol.

or

e. Only one flow line should enter a decision symbol, but two or three flow lines, one for each possible answer, should leave the decision symbol.

f. Only one flow line is used in conjunction with terminal symbol.

g. If the flowchart becomes complex, it is better to use connector symbols to reduce the number of flow lines. Avoid the intersection of flow lines if you want to make it more effective and better way of communication.

h. Ensure that the flowchart has a logical start and finish.

i. It is useful to test the validity of the flowchart by passing through it with a simple test data.

18

>0<0 >0<0

=0

Page 19: CP Unit I Complete

Sample flowchart

Draw a Flowchart for calculating the roots of quadratic equation.

19

Page 20: CP Unit I Complete

PSEUDOCODES

Analysing detailed algorithms before developing a program is very time consuming. Hence, there arises a need of a specification that only focuses on the logic of the program. Pseudocodes serve this purpose by specifying only the logic, which is used by the programmer for developing a computer program.

Pseudocode is not written using specific syntax of a programming language, rather it is written with a combination of generic syntax and normal English language, it helps the programmer understand the basic logic of the programe after which it is the programmer’s choice to write the final code in any programming language.

Sample Pseudocode

A pseudocode to add two numbers and display the result

BEGINDefine: integer num1, num2, result.Input: integer num1.Input: integer num2.Sum: result = num1 + num2Output: display (result).ENDAfter the pseudocodes for a computer program has been written, it is used develop the source code for the computer program. The source code is developed using a programming language, which can be an assembly language or a high-level programming language. After the source code has been written, the programmer detects and eliminates any errors in the program so that the program generates the desired output on execution.

Advantage of pseudocodesSome of the key advantage of using a flowchart in program design is:

Pseudocode is easy to comprehend as it used English phrases for writing program instructions.

Developing program code using pseudocode is easier in comparison to developing the program code from scratch.

Developing program code using pseudocode is also easier in in comparison to developing the program code from flowchart.

The pseucode instructions are easier to modify in comparison to a flowchart. The use of pseudocode works well for large program design.

Disadvantage of pseudocodes

Pseudocodes also have certain limitations, such as:

Since, pseudocode does not use any kind of pictorial representations for program elements; it may at times become difficult to understand the program logic.

There is no standard format for developing a pseudocode. Therefore, it may become a challenge to use the same pseudocode by different programmers.

Pseudocodes are at a disadvantage in comparison to flowchart when it comes to understanding the flow of program control.

20

Page 21: CP Unit I Complete

UNIT I

INTRODUCTIONSAMPLE TWO MARKS QUESTIONS WITH ANSWERS

1. Define computers?A computer is a programmable machine or device that performs pre-defined or programmed

computations or controls operations that are expressible in numerical or logical terms at high speed and with great accuracy.

(Or)Computer is a fast operating electronic device, which automatically accepts and store input data, processes them and produces results under the direction of step by step program.

2. Why computer is known as data processing system? (MAY 2009)Any process that uses a computer program will enter data and summarize, analyze or

otherwise convert data into usable information. The process may be automated and run on a computer. It involves recording, analysing, sorting, summarizing, calculating, disseminating and storing data. Thus Computer is known as data processing system.

3. How will you classify computer systems? (JAN2009)Based on physical size, performance and application areas, we can generally divide

computers into four major categories: Micro computer Mini Computer Mainframe computer and Super Computer

4. Specify the Electronic components used for different computer generations.

Generations

Electronic Components

I Generation Vacuum tubesII Generation

Transistors

III Generation

Integrated Circuits

IV Generation

Microprocessors

V Generation

Artificial Intelligence

5. What are the languages used in computer generations.

Generations Languages usedI Generation Machine Language.II Generation Assemble Language,

21

Page 22: CP Unit I Complete

MnemonicsIII Generation High Level Language,

BASIC, PASCAL, COBOL, FORTRON.

IV Generation 4GLV Generation Artificial Intelligence.

6. What are the components of the computer systems?Basic components of the computer system are Input Unit, Central

Processing Unit, Secondary Storage Unit and Output Unit.

7. What are the functions in the input unit?An input device is a device that is used to input data or information into a computer.

Some examples of input devices include:· Keyboards.· Computer mice.· Light Pen.· Digitizer.· Touchpad.· Trackball.· Image scanner.· Webcam.· Video capture / tuner cards.· Microphones.· MIDI instruments.

8. What is an ALU?Arithmetic logic unit, the part of a computer that performs all arithmetic computations, such

as addition and multiplication, and all logical operations such s comparison operations. The ALU is one component of the CPU (central processing unit).

9. Define Clients and Servers.A client is generally a single-user PC or workstation that provides a highly user-friendly

interface to the end user. It runs client processes, which send service requests to the server. A server is generally a relatively large computer that manages a shared resource and provides

a set of shared user services to the clients. It runs the server process, which services client requests for use of the resource managed by the server. The network may be single LAN or WAN or an internet of networks.

10. What is a CPU?The CPU (central processing unit) is the part of a computer controls the interpretation and

execution of instructions. Generally, the CPU is a single microchip.(Or)

CPU is the computing part of the computer. Also called the "processor," it is made up of the control unit and ALU. Today, the CPUs of almost all computers are contained on a single chip.

11. Define personal computers?A small, relatively inexpensive computer designed for an individual user. In price, personal

computers range anywhere from a few hundred dollars to thousands of dollars.

22

Page 23: CP Unit I Complete

All are based on the microprocessor technology that enables manufacturers to put an entire CPU on one chip.Example:· Businesses use personal computers for word processing, accounting, desktop publishing, and for running spreadsheet and database management applications.· At home, the most popular use for personal computers is for playing games.

12. Define Mainframe computer?Mainframes are computers used mainly by large organizations for critical applications,

typically bulk data processing such as census, industry and consumer statistics, enterpriseresource planning, and financial processing.

The term probably had originated from the early mainframes, as they were housed in enormous, room-sized metal boxes or frames.

13. Define Mini computers?A mini computer is a multi-user or time-sharing system. It is used for medium scale data

processing such as Bank account processing, Payroll processing etc., Mini computer process greater storage capacity and larger memories as compared to micro computer.

14. What is a volatile and non-volatile memory?Volatile memory: also known as volatile storage is computer memory that requires power to

maintain the stored information, unlike non-volatile memory which does not require a maintained power supply. It has been less popularly known as temporary memory.

Non-volatile memory: nonvolatile memory, NVM or non-volatile storage, is computer memory that can retain the stored information even when not powered.Examples of non-volatile memory

· read-only memory· flash memory· most types of magnetic computer storage devices (e.g.hard / floppy disks & magnetic tape)· optical discsEarly computer storage methods such as paper tape and punch cards.Non-volatile memory is for long-term persistent storage. The most widely used form of

primary storage today is a volatile form of random access memory (RAM), meaning that when the computer is shut down, anything contained in RAM is lost.

15. What is a primary memory?The primary memory or the main memory is part of the main computer system. The processor

or the CPU directly stores and retrieves information from it. This memory is accessed by CPU, in random fashion. That means any location of this memory can be accessed by the CPU to either read information from it, or to store information in it.Types of Primary Memory:

· RAM is RWM (Read Write Memory), the CPU can write and read information from Any primary memory location implemented using RAM.· ROM stands for Read Only Memory.

16. What is a secondary memory?

23

Page 24: CP Unit I Complete

The secondary memory is much slower and also less costly. It stores the data permanently unless it is erased.Examples:

Floppy disk storage mediaHard diskCD / DVDPen driveMemory chips etc.

17. What are the positional number systems and what is their base?

Number System BaseDecimal Number System 10Binary Number System 2Octal Number System 8HexaDecimal Number System 16

18. Write the binary and octal equivalent of hexadecimal number 7BD? (APR2009)

Binary Equivalent of 7BD = (0111 1011 1101)2

Octal Equivalent of 7BD = (011 110 111 101) = (3675)8

19. Convert binary number 100110 into its octal equivalent? (JAN2009)Octal equivalent of 100110 = (100 110) = (46)8

20. Differentiate analog and digital computers? (JAN2010)

S No. Analog Computer Digital Computer1 Process measured data Process discrete data2 Analog computers are not precise Digital computers are more precise3 Processing speed is low. Processing speed is high.4 Less accuracy. More accuracy.

21. Find the decimal equivalent of hexadecimal number 4D.C8 (JAN2010)4D.C8 = 4 X 161 + 13 X 162 + 12 X 16-1 + 8 X 16-2

= 64 + 13 +0.75 + 0.03125= (77.78)2

22. Convert hexadecimal number into binary equivalent of EBC (JAN2010)Binary equivalent of EBC = (1110 1011 1100)2

24

Page 25: CP Unit I Complete

SAMPLE BIG QUESTIONS

1. With suitable examples, explain about Number systems. (JAN 2009)2. Explain various generations of computers with features? (FEB 2009/FEB2010)3. Explain the fundamental units of a computer with a block diagram?

(Or) Explain the basic computer organization in detail? (JAN2009\MAY 2009)4. Explain the classification of computers? (MAY 2009\FEB 2009\FEB2010)5. Describe briefly about Secondary storage devices? (MAY 2009)6. Convert the numbers:

(a) Convert the following number to decimal (11011011.100101)2

(b) Convert (231.3)4 to Base of 7(c) Convert the following Decimal numbers to Hexadecimal numbers

(i) (35)10

(ii) (275)10

(iii) (31)10

7. Explain in detail about Input and Output Units. 8. Explain the organization of a computer and describe (Jan 2011)

a. Input unit.b. central processing unit andc. Output unit. (4 + 4 + 4 + 4 = 16)

9. Describe various types of memories used in computer. (16) (Jan 2011)10. With examples illustrate the conversion of Decimal to Binary, Octal and Hexadecimal numbers.

-------------------------------- END OF UNIT I ----------------------------------- 25