LESSON 1 BASIC CONCEPTS

1.1

INTRODUCTION

Let us begin with the word „compute‟. It means „to calculate‟. We all are familiar with calculations in our day to day life. We apply mathematical operations like addition, subtraction, multiplication, etc. and many other formulae for calculations. Simpler calculations take less time. But complex calculations take much longer time. Another factor is accuracy in calculations. So man explored with the idea to develop a machine which can perform this type of arithmetic calculation faster and with full accuracy. This gave birth to a device or machine called „ computer’. The computer we see today is quite different from the one made in the beginning. The number of applications of a computer has increased, the speed and accuracy of calculation has increased. You must appreciate the impact of computers in our day to day life. Reservation of tickets in Air Lines and Railways, payment of telephone and electricity bills, deposits and withdrawals of money from banks, business data processing, medical diagnosis, weather forecasting, etc. are some of the areas where computer has become extremely useful. However, there is one limitation of the computer. Human beings do calculations on their own. But computer is a dumb machine and it has to be given proper instructions to carry out its calculation. This is why we should know how a computer works.

1.2

OBJECTIVES

After going through this lesson you will be in a position to define a computer identify characteristics of computer know the origin and evolution of computer identify capability of computer in terms of speed and accuracy distinguish computer from human beings and calculator identify the role of computer appreciate the evolution of computer through five generations

1

1.3

WHAT IS A COMPUTER?

Computer is an electronic device. As mentioned in the introduction it can do arithmetic calculations faster. But as you will see later it does much more than that. It can be compared to a magic box, which serves different purpose to different people. For a common man computer is simply a calculator, which works automatic and quite fast. For a person who knows much about it, computer is a machine capable of solving problems and manipulating data. It accepts data, processes the data by doing some mathematical and logical operations and gives us the desired output. Therefore, we may define computer as a device that transforms data. Data can be anything like marks obtained by you in various subjects. It can also be name, age, sex, weight, height, etc. of all the students in your class or income, savings, investments, etc., of a country. Computer can be defined in terms of its functions. It can i) accept data ii) store data, iii) process data as desired, and iv) retrieve the stored data as and when required and v) print the result in desired format. You will know more about these functions as you go through the later lessons. 1.4 CHARACTERISTICS OF COMPUTER

Let us identify the major characteristics of computer. These can be discussed under the headings of speed, accuracy, diligence, versatility and memory.

1.4.1 Speed As you know computer can work very fast. It takes only few seconds for calculations that we take hours to complete. Suppose you are asked to calculate the average monthly income of one thousand persons in your neighborhood. For this you have to add income from all sources for all persons on a day to day basis and find out the average for each one of them. How long will it take for you to do this? One day, two days or one week? Do you know your small computer can finish this work in few seconds? The weather forecasting that you see every day on TV is the results of compilation and analysis of huge amount of data on temperature, humidity, pressure, etc. of various places on computers. It takes few minutes for the computer to process this huge amount of data and give the result. You will be surprised to know that computer can perform millions (1,000,000) of instructions and even more per second. Therefore, we determine the speed of computer in terms of microsecond (10-6 part of a second) or nano-second (10-9 part of a second). From this you can imagine how fast your computer performs work.

1.4.2 Accuracy Suppose some one calculates faster but commits a lot of errors in computing. Such result is useless. There is another aspect. Suppose you want to divide 15 by 7. You may work out up to 2 decimal places and say the dividend is 2.14. I may calculate up to 4 decimal places and say that the result is

2

2.1428. Some one else may go up to 9 decimal places and say the result is 2.142857143. Hence, in addition to speed, the computer should have accuracy or correctness in computing. The degree of accuracy of computer is very high and every calculation is performed with the same accuracy. The accuracy level is determined on the basis of design of computer. The errors in computer are due to human and inaccurate data. 1.4.3 Diligence A computer is free from tiredness, lack of concentration, fatigue, etc. It can work for hours without creating any error. If millions of calculations are to be performed, a computer will perform every calculation with the same accuracy. Due to this capability it overpowers human being in routine type of work. 1.4.4 Versatility It means the capacity to perform completely different type of work. You may use your computer to prepare payroll slips. Next moment you may use it for inventory management or to prepare electric bills. 1.4.5 Power of Remembering Computer has the power of storing any amount of information or data. Any information can be stored and recalled as long as you require it, for any numbers of years. It depends entirely upon you how much data you want to store in a computer and when to lose or retrieve these data. 1,4.6 No IQ

Computer is a dumb machine and it cannot do any work without instruction from the user. It performs the instructions at tremendous speed and with accuracy. It is you to decide what you want to do and in what sequence. So a computer cannot take its own decision as you can. 1.4. 7 No Feeling

It does not have feelings or emotion, taste, knowledge and experience. Thus it does not get tired even after long hours of work. It does not distinguish between users. 1.4.8 Storage

The Computer has an in-built memory where it can store a large amount of data. You can also store data in secondary storage devices such as floppies, which can be kept outside your computer and can be carried to other computers.

IN-TEXT QUESTIONS 1 1. 2. What is a computer? Why is it known as data processor? What are the important characteristics of computer?

3

1.5

HISTORY OF COMPUTER

History of computer could be traced back to the effort of man to count large numbers. This process of counting of large numbers generated various systems of numeration like Babylonian system of numeration, Greek system of numeration, Roman system of numeration and Indian system of numeration. Out of these the Indian system of numeration has been accepted universally. It is the basis of modern decimal system of numeration (0, 1, 2, 3, 4, 5, 6, 7, 8, 9). Later you will know how the computer solves all calculations based on decimal system. But you will be surprised to know that the computer does not understand the decimal system and uses binary system of numeration for processing. We will briefly discuss some of the path-breaking inventions in the field of computing devices. 1.5 .1 Calculating Machines

It took over generations for early man to build mechanical devices for counting large numbers. The first calculating device called ABACUS was developed by the Egyptian and Chinese people. The word ABACUS means calculating board. It consisted of sticks in horizontal positions on which were inserted sets of pebbles. A modern form of ABACUS is given in Fig. 1.2. It has a number of horizontal bars each having ten beads. Horizontal bars represent units, tens, hundreds, etc. 1.5.2 Napier’s bones

English mathematician John Napier built a mechanical device for the purpose of multiplication in 1617 A D. The device was known as Napier‟s bones. 1.5.3 Slide Rule

English mathematician Edmund Gunter developed the slide rule. This machine could perform operations like addition, subtraction, multiplication, and division. It was widely used in Europe in 16 th century. 1.5.4 Pascal's Adding and Subtractory Machine

You might have heard the name of Blaise Pascal. He developed a machine at the age of 19 that could add and subtract. The machine consisted of wheels, gears and cylinders. 1.5.5 Leibniz’s Multiplication and Dividing Machine

The German philosopher and mathematician Gottfried Leibniz built around 1673 a mechanical device that could both multiply and divide. 1.5.6 Babbage’s Analytical Engine

It was in the year 1823 that a famous English man Charles Babbage built a mechanical machine to do complex mathematical calculations. It was called difference engine. Later he developed a generalpurpose calculating machine called analytical engine. You should know that Charles Babbage is called the father of computer. 1.5.7 Mechanical and Electrical Calculator

4

In the beginning of 19th century the mechanical calculator was developed to perform all sorts of mathematical calculations. Up to the 1960s it was widely used. Later the rotating part of mechanical calculator was replaced by electric motor. So it was called the electrical calculator. 1.5.8 Modern Electronic Calculator

The electronic calculator used in 1960 s was run with electron tubes, which was quite bulky. Later it was replaced with transistors and as a result the size of calculators became too small. The modern electronic calculator can compute all kinds of mathematical computations and mathematical functions. It can also be used to store some data permanently. Some calculators have inbuilt programs to perform some complicated calculations. IN-TEXT QUESTIONS 2 1. What is the first mathematical device built and when was it built? 2. Who is called the father of Computer Technology.

1.6

COMPUTER GENERATIONS

You know that the evolution of computer started from 16th century and resulted in the form that we see today. The present day computer, however, has also undergone rapid change during the last fifty years. This period, during which the evolution of computer took place, can be divided into five distinct phases known as Generations of Computers. Each phase is distinguished from others on the basis of the type of switching circuits used. 1.6.1 First Generation Computers

First generation computers used Thermion valves. These computers were large in size and writing programs on them was difficult. Some of the computers of this generation were: ENIAC: It was the first electronic computer built in 1946 at University of Pennsylvania, USA by John Eckert and John Mauchy. It was named Electronic Numerical Integrator and Calculator (ENIAC). The ENIAC was 30 50 feet long, weighed 30 tons, contained 18,000 vacuum tubes, 70,000 registers, 10,000 capacitors and required 150,000 watts of electricity. Today your favorite computer is many times as powerful as ENIAC, still size is very small. EDVAC: It stands for Electronic Discrete Variable Automatic Computer and was developed in 1950. The concept of storing data and instructions inside the computer was introduced here. This allowed much faster operation since the computer had rapid access to both data and instructions. The other advantages of storing instruction was that computer could do logical decision internally. Other Important Computers of First Generation EDSAC: It stands for Electronic Delay Storage Automatic Computer and was developed by M.V. Wilkes at Cambridge University in 1949. UNIVAC-1: Ecker and Mauchly produced it in 1951 by Universal Accounting Computer setup.

5

Power consumption was very high. programming language and input and output units were developed.2 Second Generation Computers Around 1955 a device called Transistor replaced the bulky electric tubes in the first generation computer. Manufacturing cost was also very low. 2. memory. 1. Some of the computers of the Second Generation were 1. Some of the computers developed during this period were IBM-360. Higher level language such as BASIC (Beginners All purpose Symbolic Instruction Code) was developed during this period. These computers are called microcomputers. 1. The programming capability was quite low. The operating speed was quite slow. A single IC has many transistors. FORTRAN were developed during this period. 6 . and VAX750. So it is quite obvious that the size of the computer got further reduced. IBM 1401: Its size was small to medium and used for business applications. 1. It is in the second generation that the concept of Central Processing Unit (CPU). These ICs are popularly known as Chips.6. Computers of this generations were small in size. It required large space for installation. It uses large scale Integrated Circuits (LSIC) built on a single silicon chip called microprocessors. They have no filament and require no heating. Later very large scale Integrated Circuits (VLSIC) replaced LSICs. The programming languages such as COBOL. CDC 3600: Its size was large and is used for scientific purposes. Due to the development of microprocessor it is possible to place computer‟s central processing unit (CPU) on single chip.Limitations of First Generation Computer Followings are the major drawbacks of First generation computers. 4. low cost.3 Third Generation Computers The third generation computers were introduced in 1964. Thus the size of the computer got reduced considerably. 1. 3.6. large memory and processing speed is very high. 2. ICL-1900. IBM 1620: Its size was smaller as compared to First Generation computers and mostly used for scientific purpose. 3. Transistors are smaller than electric tubes and have higher operating speed. registers and capacitors built on a single thin slice of silicon. IBM-370. They used Integrated Circuits (ICs).4 Fourth Generation Computers The present day computers that you see today are the fourth generation computers that started around 1975.6.

They are generally used in centralised databases. remote sensing. Its CPU is a microprocessor. They operate at very high speed. Into how many generations the evolution of computer is divided? 2. biomedical research. What is VLSIC? 3. The personal computer (PC) that you see in your school is a Fourth Generation Computer.5 Fifth Generation Computer The computers of 1990s are said to be Fifth Generation computers. Mainframes: These types of computers are generally 32-bit microprocessors.Thus the computer which was occupying a very large room in earlier days can now be placed on a table. They have high processing speed compared to other computers. memory and number of users.6. Although they belong to the fifth generation they can be divided into different categories depending upon the size. One of the ways in which supercomputers are built is by interconnecting hundreds of microprocessors. have very large storage capacity and can handle the work load of many users. The concept of Artificial intelligence has been introduced to allow the computer to take its own decision. efficiency. The most common application of personal computers (PC) is in this category. The personal computer that you see today is in which generation of computer? 7 . The first microcomputers were built of 8-bit microprocessor chips. 1. It is still in a developmental stage. 1. Microcomputer: Microcomputer is at the lowest end of the computer range in terms of speed and storage capacity. 3. They are also used as servers in Local Area Networks (LAN). Supercomputer: They are the fastest and most expensive machines. They are also used as controlling nodes in Wide Area Networks (WAN). Mini Computer: This is designed to support more than one user at a time. This type of computer is generally used for processing large volume of data in an organisation. CRAY XMP and PARAM from India. The speed is extremely high in fifth generation computer. The mini computer is used in multi-user system in which various users can work at the same time. CRAY2. It possesses large storage capacity and operates at a higher speed. An improvement of 8-bit chip is 16-bit and 32-bit chips. ICL and IBM 3000 series. aircraft design and other areas of science and technology. Examples of supercomputers are CRAY YMP. Supercomputers are mainly being used for whether forecasting. IN-TEXT QUESTIONS 3 1. The PC supports a number of input and output devices. 4.7 TYPES OF COMPUTERS Now let us discuss the varieties of computers that we see today. Apart from this it can perform parallel processing. They have also multiprocessing technique. Example of mainframes are DEC. Broadly they can be divided it to the following categories. NEC SX-3. PC-AT . 2. Examples of microcomputer are IBM PC. 1.

diligence. 2. versatility and storage. Charles Babbage IN-TEXT qUESTIONS 3 1. memory and versatility are some of the features associated with a computer. The characteristics of computer are speed. IN-TEXT QUESTIONS 2 1. but on the other hand the processing speed of computer has improved tremendously. There are five generations of computer. Explain various types of computers. Why did the size of computer get reduced in third generation computer? 5. Explain in brief the various generations in computer technology. 3. A computer is an electronic device. Over these generations the physical size of computer has decreased. 1. Write a short note on Fifth Generation of computer. (a) Word processor is Software Package that enables you to create. which is used to accept. Give short notes on the following: (a) Versatility (b) Storage (c) Slide Rule (d) Babbage‟s Analytical Engine 6. 2. Write a short note on Fifth Generation of computer.8 WHAT YOU HAVE LEARNT In this lesson we have discussed about the major characteristics of computer.10 FEEDBACK TO IN-TEXT QUESTIONS IN-TEXT QUESTIONS 1 1.9 TERMINAL QUESTIONS 1. print and save document . It is called as data processor because it is mainly used for processing data for producing meaningful information. 2. retrieve and process the data. The speed. It has taken centuries of human effort to see the computer in its present form today. 1. We also discussed about the varieties of computers available today. What makes it different from Fourth generation computer? 4. store. But the computer that we see today has not developed over night. 2.1. 8 . 3. Why is computer known as data processor? 2. 1. What makes it different from Fourth Generation computer? 4. Why did the size of computer get reduced in Third Generation computer? State True or False 1. accuracy. 1823. Explain in brief the various generations in computer technology? 3.11 Five generations Very Large Scale Integrated Circuits Fourth Generation TERMINAL QUESTIONS 1. edit. accuracy. Distinguish between Microcomputer and Mainframe computer. Analytical engine.

9 . (a) While working in Ms-Word you have to work with (i) Mouse only (ii) Keyboard only (iii) Both mouse and keyboard (b) In Ms.Choose the best answer. 1. (d) Word has the facility of Macros. (c) Changing the size of the margins cannot reformat complete document or part of the text. (e) Word does not allow the user to mix the graphical pictures with text. (iii) Move the mouse pointer on the screen.(b) WordStar is a popular Word processor. (ii) Take the mouse pointer to START button and click the right mouse button.Word every command is available in (i) Print (ii) Letter (iii) Icons (c) You can go inside Ms-Word by the following way (i) Take the mouse pointer to START button on the task bar and click the left mouse button.

Therefore the data is first stored in the storage unit for faster access and processing.1 INTRODUCTION In the previous lesson we discussed about the evolution of computer. 2. 3) it can process data as required by the user. and 5) it controls all operations inside a computer. The storage unit performs the following major functions: All data and instructions are stored here before and after processing. As you know from the previous lesson the internal architecture of computer may differ from system to system. but the basic organisation remains the same for all computer systems. Input: This is the process of entering data and programs in to the computer system. 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.LESSON 2 COMPUTER ORGANISATION 2. 2. We discuss below each of these operations. It provides space for storing data and instructions. Therefore. Data has to be fed into the system before the actual processing starts. 4) it gives results in the form of output. These are 1) it accepts data or instructions by way of input. byte and a word define computer memory differentiate between primary memory and secondary memory differentiate between primary storage and secondary storage units differentiate between input devices and output devices 2.1 performs basically five major operations or functions irrespective of their size and make. You should know that computer is an electronic machine like any other machine which takes as inputs raw data and performs some processing giving out processed data. 2. 1. Storage: The process of saving data and instructions permanently is known as storage. You will know how different parts of a computer are organised and how various operations are performed between different parts to do a specific task. Control Unit and Central Processing Unit differentiate between bit .3 BASIC COMPUTER OPERATIONS A computer as shown in Fig. the input unit takes data from us to the computer in an organized manner for processing. In this lesson we will provide you with an overview of the basic design of a computer. 2) it stores data. 10 . This storage unit or the primary storage of the computer system is designed to do the above functionality.2 OBJECTIVES At the end of the lesson you will be able to: understand basic organisation of computer system understand the meaning of Arithmetic Logical Unit.

1 Arithmetic Logical Unit (ALU) After you enter data through the input device it is stored in the primary storage unit. The major operations performed by the ALU are addition. multiplication.2 Control Unit (CU) The next component of computer is the Control Unit. The actual processing of the data and instruction are performed by Arithmetic Logical Unit. division. Personal Computer Configuration 11 . It is just like brain that takes all major decisions. They are 1) arithmetic logical unit. 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. You may call CPU as the brain of any computer system. Output: This is the process of producing results from the data for getting useful information. which acts like the supervisor seeing that things are done in proper fashion.4.4 FUNCTIONAL UNITS In order to carry out the operations mentioned in the previous section the computer allocates the task between its various functional units. Control: The manner how instructions are executed and the above operations are performed. subtraction. 2. It is then sent back to the storage unit. It takes care of step by step processing of all operations in side the computer. After processing the output is returned back to storage unit for further processing or getting stored. 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. 4.4. 5. 2) control unit. Thereby it coordinates the activities of computer‟s peripheral equipment as they perform the input and output.3 Central Processing Unit (CPU) The ALU and the CU of a computer system are jointly known as the central processing unit. 3. 2. interpretation of the instructions and issuing of signals for other units of the computer to execute them. 2. It also acts as a switch board operator when several users access the computer simultaneously. processing and output are performed by control unit. Data is transferred to ALU from storage unit when required. logic and comparison. The control unit determines the sequence in which computer programs and instructions are executed. Again the output is also stored inside the computer for further processing. Therefore it is the manager of all operations mentioned in the previous section.Intermediate results of processing are also stored here. makes all sorts of calculations and directs different parts of the computer functions by activating and controlling the operations. Things like processing of programs stored in the main memory. The computer system is divided into three separate units for its operation. Controlling of all operations like input. 2..4. and 3) central processing unit.

Secondary memory such as floppy disks. What are the five basic operations performed by the computer? Define ALU. Motherboard 6. magnetic disk. 3. Central Processing Unit (CPU) 2.. Input Devices All these components are inter-connected for the personal computer to work. Computer memory is used to store two things: i) instructions to execute a program and ii) data. CU and CPU. 12 .5 MEMORY SYSTEM IN A COMPUTER There are two kinds of computer memory: primary and secondary. Data bus 4. These are 1. RAM is an example of primary memory. Choose the correct answer: (a) The task of performing arithmetic and logical operations is called (i) ALU (ii) editing (iii) storage (iv) output (b) The ALU and CU jointly known as (i) RAM (ii) ROM (iii) CPU (iv) none of the above (c) The process of producing results from the data for getting useful information (i) output (ii)input (iii) processing (iv) storage 2. Output Devices 8. You can store and retrieve data much faster with primary memory compared to secondary memory. IN-TEXT QUESTIONS 1 1. is located outside the computer. the data that have to be processed are stored in the primary memory. Hard disk 7. As soon as the computer is switched off the contents of the primary memory is lost. etc. Primary memory is more expensive than secondary memory. When the computer is doing any job. Computer Memory (RAM and ROM) 3.Now let us identify the physical components that make the computer work. Ports 5. We will discuss about secondary memory later on. 2. Because of this the size of primary memory is less than that of secondary memory. This data may come from an input device like keyboard or from a secondary storage device like a floppy disk. Primary memory is accessible directly by the processing unit.

If a switch is ON it is considered 1 and if it is OFF it is 0. The Primary or internal storage section is made up of several small storage locations (ICs) called cells. You have already been introduced with decimal number system. In computer‟s memory both programs and data are stored in the binary form. Each cell has a unique number assigned to it called the address of the cell and it is used to identify the cells. which can be made ON. So the capacity is defined in terms of byte or words..As program or the set of instructions is kept in primary memory.. Capacity of Primary Memory You know that each cell of memory contains one character or 1 byte of data. Each of these cells can store a fixed number of bits called word length. For example. These are called bits. when you book ticket from railway reservation counter. The address starts at 0 and goes up to (N-1). Therefore it is the computer that takes information or data in decimal form from you. calculate fare. the computer is able to follow instantly the set of instructions. These circuits are called Random Access Memory (RAM). which stands for one binary piece of information. A bit is an acronym for binary digit. for example. The programme containing these steps is kept in memory of the computer and is followed for each request. convert it in to binary form. Thus 64 kilobyte (KB) memory is capable of storing 64 1024 = 32. Every number in binary system can be converted to decimal system and vice versa. (One byte is equal to 8 bits). that is the numbers 1 to 9 and 0. Is it not absurd if the computer gives outputs as 0‟s & 1‟s only? But you do not have to worry about. The binary system has only two values 0 and 1. 1010 meaning decimal 10. You should know that the memory is like a large cabinet containing as many drawers as there are addresses on memory.768 bytes. the steps followed are quite different from what we see on the monitor or screen. This can be either 0 or 1.. or OFF. process it producing output in binary form and again convert the output to decimal form. In your personal computer you 13 . check the availability of seats. Each of RAM‟s locations stores one byte of information. You will know more about RAM later. So the computer takes input in the form of 0 and 1 and gives output in the form 0 and 1 only. As human beings we all understand decimal system but the computer can only understand binary system.10. (1 kilobyte is 1024 bytes). the computer has to follow the same steps: take the request. A memory size ranges from few kilobytes in small systems to several thousand kilobytes in large mainframe and super computer. A number of switches in different states will give you a message like this: 110101. wait for money to be paid. The primary memory as you know in the computer is in the form of IC‟s (Integrated Cir cuits). But inside the computer. It is because a large number of integrated circuits inside the computer can be considered as switches. store the reservation and get the ticket printed out. Each drawer contains a word and the address is written on outside of the drawer.

It is also called read/write memory. Information stored in EPROM exposing the chip for some time ultraviolet light and it erases chip is reprogrammed using a special programming facility. Therefore the performance of CPU decreases due to the slow speed of main memory. which do not loose their content on failure of power supply. Read Only Memory (ROM): There is another memory in computer. 4. ROM is non-volatile memory. 8 MB and even 16 MB (MB = Million bytes). It takes same time to any address of the memory as the first address. The following terms related to memory of a computer are discussed below: 1. It disappears from RAM as soon as the power to the computer is switched off. Again it is the ICs inside the PC that form the ROM. are known as volatile memories . 4 MB. The storage of program and data in the ROM is permanent. You know that it is not possible to modify or erase programs stored in ROM. It is called CACHE memory. Therefore programs or instructions written in PROM or ROM cannot be erased or changed. The memories. The basic input/output program is stored in the ROM that examines and initializes various equipment attached to the PC when the switch is made ON. When the EPROM is in use information can only be read. The ROM can only be read by the CPU but it cannot be changed.will find memory capacity in the range of 64 KB. are known as non-volatile memories.So now we can say that RAM is volatile memory. 14 . The memories. It is also very expensive to have bigger size of cache memory and its size is normally kept small. but it is possible for you to store your program in PROM chip. which is called Programmable Read Only Memory (PROM). Random Access Memory (RAM): The primary storage is referred to as random access memory (RAM) because it is possible to randomly select and use any location of the memory directly store and retrieve data. 2. EPROM chip can be programmed time and again by erasing the information stored earlier in it. which is called Read Only Memory (ROM). PROM There is another type of primary memory in computer. CACHE memories are accessed much faster than conventional RAM. Once the programmes are written it cannot be changed and remain intact even if power is switched off. So each memory makes main memory to be faster and larger than it really is. EPROM: This stands for Erasable Programmable Read Only Memory. The storage of data and instructions inside the primary storage is temporary. The ROM stores some standard processing programs supplied by the manufacturers to operate the personal computer. 3. It is used to store programs or data currently being executed or temporary data frequently used by the CPU. To decrease the mismatch in operating speed. which over come the problem of PROM & ROM. 5. which loose their content on failure of power supply. Cache Memory: The speed of CPU is extremely high compared to the access time of main memory. a small memory chip is attached between CPU and Main memory whose access time is very close to the processing speed of CPU.

The cost of storing data in tapes is inexpensive. 2. These high-speed storage devices are very expensive and hence the cost per bit of storage is also very high. Often it is necessary to store hundreds of millions of bytes of data for the CPU to process. They are not part of the main memory but they store data or information temporarily and pass it on as directed by the control unit. Tapes consist of magnetic materials that store data permanently. So the computer uses a number of special memory units called registers. Registers: The CPU processes data and instructions with high speed. This memory is called auxiliary memory or secondary storage. Magnetic Tape: Magnetic tapes are used for large computers like mainframe computers where large volume of data is stored for a longer time. (b) The computer takes inputs in the form of 0 and 1. (c) The storage of program and data in the RAM is permanent. Distinguish between bit and byte. Most widely used secondary storage devices are magnetic tapes and magnetic disk. 2. In PC also you can use tapes in the form of cassettes.5 mm to 25 mm wide plastic film-type and 15 . However. It can be 12. Define volatile and non-volatile memory. the operating speed is slower than that of the primary storage. there is also movement of data between various units of computer. (d) PROM is secondary memory.6 SECONDARY STORAGE You are now clear that the operating speed of primary memory or main memory should be as fast as possible to cope up with the CPU speed. (e) The memories which do not loose their content on failure of power supply are known as nonvolatile memories. Again the storage capacity of the main memory is also very limited. In this type of memory the cost per bit of storage is low. 3. IN-TEXT QUESTIONS 2 1. Write True or False: (a) There are two kinds of computer memory primary and secondary. It is necessary to transfer the processed data with high speed. 1. Huge volume of data are stored here on permanent basis and transferred to the primary storage as and when required. Therefore additional memory is required in all the computer systems.6.

Fast: Copying of data is easier and fast. Advantages of Magnetic Tape: Compact: A 10-inch diameter reel of tape is 2400 feet long and is able to hold 800. Information is recorded on tracks of a disk surface in the form of tiny magnetic spots. Each disk consists of a number of invisible concentric circles called tracks.25 inch or 3. The maximum capacity of such tape is 180 million characters.5 inch floppy it is 1. Data is stored on both the surface of the disk. Long term Storage and Re-usability: Magnetic tapes can be used for long term storage and a tape can be used repeatedly with out loss of data.25-inch floppy is 1.2 mega bytes whereas for 3. Economical: The cost of storing characters is very less as compared to other storage devices.500 meter to 1200 meter long which is coated with magnetic material.44 mega bytes. The presence of a magnetic spot represents one bit and its absence represents zero bit. 4. 2. But if you want to write a new data. The information stored in a disk can be read many times without affecting the stored data. Optical disks can be divided into the following categories: 16 .5 inch in diameter. Magnetic disks are most popular for direct access storage device. Optical Disk: With every new application and software there is greater demand for memory capacity. Floppy Disk: It is similar to magnetic disk discussed above. It is cheaper than any other storage devices and is portable. which is circular like a disk and coated with magnetic material. It is the necessity to store large volume of data that has led to the development of optical disk storage medium. 1600 or 6250 characters in each inch of its length. They are 5. The capacity of a 5. They come in single or double density and recorded on one or both surface of the diskette. Magnetic Disk: You might have seen the gramophone record. Magnetic disks used in computer are made on the same principle. The deck is connected to the central processor and information is fed into or read from the tape through the processor. The floppy is a low cost device particularly suitable for personal computer system. 3. It rotates with very high speed inside the computer drive. Thus data are stored much more compactly on tape. So the reading operation is non-destructive. then the existing data is erased from the disk and new data is recorded. It similar to cassette tape recorder.

The layout of keyboard is just like the traditional typewriter of the type QWERTY. Write Once.This is the standard input device attached to all computers.1. This also applies a laser beam to write and re-write the data. 2. A good input device should provide timely.7 INPUT OUTPUT DEVICES A computer is only useful when it is able to communicate with the external environment. precisely defined point on the disk's surface and magnetises it. accurate and useful data to the main memory of the computer for processing followings are the most useful input devices. Here data can be recorded from keyboard. Erasable Optical Disk: These are optical disks where data can be written. 1. gives output through other devices called output devices.1 Input Devices Input devices are necessary to convert our information or data in to a form which can be understood by the computer. CD-ROM is written during the process of manufacturing by high power laser beam. They are also known as peripheral devices because they surround the CPU and make a communication between computer and the outer world. Similarly computer after processing. storage cost is very low and access time is relatively fast. Once the data is written it can never be erased without physically damaging the disk. It also contains some extra command 17 . 2. To write a data bit on to the erasable optical disk the MO drive's laser beam heats a tiny.7. Read Many (WORM) : The inconvenience that we can not write any thing in to a CD-ROM is avoided in WORM. say less than 30 seconds. We will discuss various types of I/O devices that are used for different types of applications. Here the storage density is very high. The advantage of WORM is that it can store vast amount of data amounting to gigabytes (109 bytes). Any document in a WORM can be accessed very fast. These disks may be used as alternatives to traditional disks. Erasable optical disks are based on a technology known as magnetic optical (MO). video scanner. Each disk is approximately 4 1/2 inches in diameter and can hold over 600 MB of data. OCR equipment and other devices. A WORM allows the user to write data permanently on to the disk. Compact Disk/ Read Only Memory (CD-ROM): CD-ROM disks are made of reflective metals. These devices are called Input devices. erased and rewritten. For a particular application one form of device is more desirable compared to others. 2. 3. As the CD-ROM can be read only we cannot write or make changes into the data contained in it. Keyboard: . When you work with the computer you feed your data and instructions through some devices to the computer.

Scanner is an optical device that can input any graphical matter and display it back. You put it inside the scanner of the computer. The common optical scanner devices are Magnetic Ink Character Recognition (MICR). The computer can recognise the electrical signals corresponding to the correct key combination and processing is done accordingly. A typical keyboard used in a computer is shown in Fig. Mouse: . 2. A monitor has its own box which is separated from the main computer system and is connected to the computer by cable. Visual Display Unit: The most popular input/output device is the Visual Display Unit (VDU).6. Magnetic Ink Character Recognition (MICR): . You have to press correct combination of keys to input data. 2.This is widely used by banks to process large volumes of cheques and drafts.2 Output Devices 1. 2. It rolls on a small ball and has two or three buttons on the top. Whichever pattern is matched is called a character read. Optical Character Recognition (OCR): . A Keyboard is used to input data and Monitor is used to display the input data and to receive massages from the computer. 3.This technique unites the direct reading of any printed character. Suppose you have a set of hand written characters on a piece of paper. Scanner: The keyboard can input only text through keys provided in it. Optical Mark Reader (OMR): This technique is used when students have appeared in objective type tests and they had to mark their answer by darkening a square or circular space by pencil. It is easier and faster to move through a mouse. 18 . The cursor moves very fast with mouse giving you more freedom to work in any direction. If we want to input a picture the keyboard cannot do that. Patterns that cannot be identified are rejected. When you roll the mouse across a flat surface the screen censors the mouse in the direction of mouse movement.7. Optical Mark Reader (OMR) and Optical Character Reader (OCR). As they enter the reading unit the cheques pass through the magnetic field which causes the read head to recognise the character of the cheques.7 that is used with your personal computer. In some systems it is compact with the system unit. Cheques are put inside the MICR. It contains a total of 101 to 104 keys. OCRs are expensive though better the MICR.keys and function keys. These answer sheets are directly fed to a computer for grading where OMR is used. 2. This pattern is compared with a site of patterns stored inside the computer. It is also called the monitor.Mouse is an input device shown in Fig. It can be color or monochrome.

3. Dot-matrix printers are of this type. Printer: It is an important output device which can be used to get a printed copy of the processed text or result on paper. (b) The magnetic tapes and magnetic disk are primary memories. stores it. We have discussed the devices used for these two types of storage and their usefulness. Depending on their speed and approach of printing. There are different types of printers that are designed for different types of applications. These are input. It can be divided into two types: hard copy terminals and soft copy terminals. 3. This type of printers can produce color printing and elaborate graphics. Terminals: It is a very popular interactive input-output unit. The storage unit of a computer is divided into two parts: primary storage and secondary storage. output and control. printers are classified as impact and non-impact printers. processes it as the user requires and provides the output in a desired format. Terminals are also classified as dumb terminals or intelligent terminals depending upon the work situation. Define soft copy and hard copy terminals. 2. Write True or False: (a) Secondary memory is called Auxiliary memory.8 WHAT YOU HAVE LEARNT In this lesson we discussed five basic operations that a computer performs. Laser printers and Ink-jet printers are of this type. Impact printers use the familiar typewriter approach of hammering a typeface against the paper and inked ribbon. Non-impact printers do not hit or impact a ribbon to print. They use electro-static chemicals and ink-jet technologies.8 IN-TEXT QUESTIONS 3 1. processing. 2. 19 . A hard copy terminal provides a printout on paper whereas soft copy terminals provide visual copy on monitor. storage. A computer accepts data as input.2. A terminal when connected to a CPU sends instructions directly to the computer. Fig. (c) A CD-ROM is read only memory. (e) Printer is an important output device. (d) Mouse is an output device. 2. Distinguish between impact and non-impact printers.

A byte is equal to 8 bits. 2. 2. What is cache memory? How is it different from primary memory? Write short notes on (a) Control Unit (b) Random Access Memory (RAM) FEEDBACK TO IN-TEXT QUESTIONS IN-TEXT QUESTIONS 1 1. processing. which do not loose their content on failure of power supply.2. A bit is an acronym for binary digit. The five basic operations that a computer performs are input. (a) T (b) T (c) F (d) F (e) T IN-TEXT QUESTIONS 3 1. 3. Also distinguish between PROM and EPROM. Non-impact printers do not hit or impact a ribbon to print. (a) i (b) iii (c) i IN-TEXT QUESTIONS 2 1. output and control. 2. A hard copy terminal provides a printout on paper whereas soft copy terminals provide visual copy on monitor. 5. The memories. 6. storage.10 What is input device? How does it differ from output device? Differentiate between RAM and ROM. 3. ALU: Arithmetic Logic Unit CU: Control Unit CPU: Central Processing Unit 3. They use electro-static chemicals and ink-jet technologies. are known as non-volatile memories.9 1. 3. The memories which are erased if there is a power failure are known as volatile memories. Impact printers use the familiar typewriter approach of hammering a typeface against the paper and inked ribbon. which stands for one binary piece of information. (a) T (b) F (c) T (d) F (e) T 20 . TERMINAL QUESTIONS What are the five basic operations performed by any computer system? Draw a block diagram to illustrate the basic organization of computer system and explain the function of various units. RAM is an example of volatile memory. 4. 2. 2. This can be either 0 or 1. ROM is non-volatile memory.

namely.1 INTRODUCTION In the previous lesson we discussed about the different parts and configurations of computer. Software guides the computer at every step where to start and stop during a particular job. how they are to be used. 3. Another important point you should know that producing software is difficult and expensive. software. Software refers to the set of computer programs. So it is necessary to provide sequence of instructions so that your work can be done. printer.LESSON 3 LANGUAGE/SOFTWARE 3. procedures that describe the programs. It includes all mechanical. In this lesson we will discuss about the other part. namely. The process of software development is called programming. This set of instructions is called a computer program.2 OBJECTIVES After going through this lesson you will be able to explain the concept of software distinguish between different types of software differentiate application software from system software define a language differentiate between different types of language distinguish between compiler and interpreter 3. 21 . You should keep in mind that software and hardware are complementary to each other. floppy and hard disk. It has been mentioned that programs or instructions have to be fed to the computer to do specific task. Hardware is the machine itself and its various individual equipment.3 WHAT IS SOFTWARE? As you know computer cannot do anything without instructions from the user. We can divide the computer components into two major areas. We can say that it is the collection of programs. Both have to work together to produce meaningful result. hardware and software. electronic circuit. electronic and magnetic devices such as monitor. which increase the capabilities of the hardware. In order to do any specific job you have to give a sequence of instructions to the computer.

4 SOFTWARE TYPES Computer software is normally classified into two broad categories. System software are general programs designed for performing tasks such as controlling all operations required to move data into and out of the computer. For example. In later modules you will learn about MS WORD. accounting. We will discuss in detail about DOS and WINDOWS in the next module. Development of system software is a complex task and it requires extensive knowledge of computer technology.3. 22 . card reader. Out of these UNIX is a multi-user operating system whereas DOS and WINDOWS are PC-based. analysis of numerous data in research. Therefore system software may be defined as a set of one or more programs designed to control the operation of computer system. Lotus 1-2-3 and dBASE III Plus. Remember that it is not possible to run application software without system software. Also system software are essential for the development of applications software. It communicates with printers. All these are application softwares. billing system. System Software: You know that an instruction is a set of programs that has to be fed to the computer for operation of computer system as a whole. tapes etc. monitor the use of various hardware like memory. UNIX and WINDOWS are some of the widely used system software. payroll is an application software for an organization to produce pay slips as an output. producing statistical report. This set of program can be called system software. We will discuss about languages in next section. Computer manufactures build and supply this system software with the computer system. System Software allows application packages to be run on the computer with less time and effort. Due to its complexity it is not developed in house. When you switch on the computer the programs written in ROM is executed which activates different units of your computer and makes it ready for you to work on it. weather forecasting. Another example of application software is programming language. Application software is useful for word processing. disk. CPU etc. DOS. Among the programming languages COBOL (Common Business Oriented Language) is more suitable for business application whereas FORTRAN (Formula Translation) is useful for scientific application. Application Software System software Application Software: Application Software is a set of programs to carry out operations for a specific application. etc.

3. But how you will communicate with your computer. COBOL etc. Your computer will not understand any of these natural languages for transfer of data and instruction. (c) UNIX is a multi-user operating system. Oriya etc. What are program. IN-TEXT QUESTIONS 1 1. BASIC. So there are programming languages specially developed so that you could pass your data and instructions to the computer to do specific job. 3. Write True or False (a) The set of instructions given to the computer is called programming. Low Level languages are further divided in to Machine language and Assembly language. Low level languages are machine oriented and require extensive knowledge of computer hardware and its configuration.5 WHAT IS LANGUAGE? You are aware with the term language. As an example. These are the languages used to communicate among various categories of persons. 3. 23 .5. So instructions or programs are written in a particular language based on the type of job. Hindi. (b) Application Software is a set of programs to carry out operations for a specific application. software and you as a user of computer system. These are programming languages. Some of the basic natural languages that we are familiar with are English.So without system software it is impossible to operate your computer. You must have heard names like FORTRAN.5.1 Programming Languages There are two major types of programming languages. 3. It is a system of communication between you and me. 3.2 Low Level Languages The term low level means closeness to the way in which the machine has been built. The following picture is shown in Fig. These are Low Level Languages and High Level Languages. On the other hand COBOL is used for business applications.1 relation between hardware. for scientific application FORTRAN and C languages are used. programming and software? Differentiate between system software and application software. 2.

For example. Advantage The only advantage is that program of machine language run very fast because no translation program is required for the CPU. 3. It is efficient for the computer but very inefficient for programmers. The programmer has to remember a lot of codes to write a program which results in program errors. It is considered to the first generation language. 2. Therefore some combination of letters can be used to substitute for number of machine codes. It is considered to be a second-generation language. (b) Assembly Language It is the first step to improve the programming structure. 24 . When this sequence of codes is fed to the computer. We also call it machine code and it is written as strings of 1's (one) and 0‟s (zero). It is difficult to debug the program. The programmer has to know details of hardware to write program. The set of symbols and letters forms the Assembly Language and a translator program is required to translate the Assembly Language to machine language.(a) Machine Language Machine Language is the only language that is directly understood by the computer. Advantages: 1. It does not needs any translator program. The symbolic programming of Assembly Language is easier to understand and saves a lot of time and effort of the programmer. 2. It is also difficult to debug the program written in this language. Disadvantages 1. it recognizes the codes and converts it in to electrical signals needed to run it. This translator program is called `Assembler'. It is very difficult to program in machine language. It is easier to correct errors and modify program instructions. a program instruction may look like this: 1011000111101 It is not an easy language for you to learn because of its difficult to understand. You should know that computer can handle numbers and letter.

You should know that any higher level language has to be converted to machine language for the computer to understand. Higher level languages are simple languages that use English and mathematical symbols like +. 3. What is the difference between FORTRAN and COBOL? Differentiate between machine language and Assembly language. For example COBOL (Common Business Oriented Language) is mostly suitable for business oriented language where there is very little processing and huge output.6 HIGH LEVEL LANGUAGES You know that assembly language and machine level language require deep knowledge of computer hardware where as in higher language you have to know only the instructions in English words and logic of the problem irrespective of the type of computer you are using. Assembly Language has the same efficiency of execution as the machine level language. 2. Disadvantages: 1. / etc. %. Because this is one-to-one translator between assembly language program and its corresponding machine language program. A program written for one computer might not run in other computers with different hardware configuration. 25 . (c) Assembly language is second generation language. One of the major disadvantages is that assembly language is machine dependent. IN-TEXT QUESTIONS 2 1. for its program construction. (b) Machine language is the only language that is indirectly understood by the computer. Write True or False (a) Low level language and High level language are two major types of programming languages. -.3. 3. There are mathematical oriented languages like FORTRAN (Formula Translation) and BASIC (Beginners All-purpose Symbolic Instruction Code) where very large processing is required. Higher level languages are problem-oriented languages because the instructions are suitable for solving a particular problem.

It takes one statement of higher level languages. Thus compiler is a program translator like assembler but more sophisticated. After this program is converted to machine languages by the compiler it is called object program.1 Compiler It is a program translator that translates the instruction of a higher level language to machine language. It means programs compiled for one type of machine will not run in another type. It differs 26 . It is because that they are similar to the languages used by us in our day to day life.6. Higher Level Language ---------------------------------Program (Compile) Program Machine Language Fig. 3. translate it into machine language and immediately execute it. 3.6.2 A compiler can translate only those source programs.2 Interpreter An interpreter is another type of program translator used for translating higher level language into machine language. 3. Advantages of High Level Languages Higher level languages have a major advantage over machine and assembly languages that higher level languages are easy to learn and use. written in COBOL language. which have been written. Machine independence is achieved by using one higher level language in different machines. For example FORTRAN compiler will not compile source code Object program generated by compiler is machine dependent. For example. in that language for which the compiler is meant for.Thus a problem oriented language designed in such a way that its instruction may be written more like the language of the problem. The programs written by the programmer in higher level language is called source program. Translation and execution are carried out for each statement. It scans the entire program first and then translates it into machine code. It is called compiler because it compiles machine language instructions for every program instructions of higher level language. Therefore every type of machine must have its personal compiler for a particular language. businessmen use business term and scientists use scientific terms in their respective languages.

4. card reader. etc. disk. What is the difference between interpreter and compiler? 2.8 1. 3. (b) Object program generated by compiler is machine independent. 27 . Application software is a set of programs written for specific purpose. The advantage of interpreter compared to compiler is its fast response to changes in source program. It is designed for performing tasks such as controlling all operations required to move data into and out of the computer. BASIC and FORTRAN. etc. Examples of application softwares are MS WORD. IN-TEXT QUESTIONS 3 1. Give some examples of high level language. tapes. What is machine language? Why is it required? What are advantages and disadvantages of machine language . Write True or False (a) High level languages are problem-oriented language. which translate the entire source program into machine code and does involve in its execution. What is assembly language? What are its advantages over machine languages? What is the difference between source program and object program? What is higher level languages? Why are higher level languages are easier to use. and monitors the use of various components like memory. System software controls the hardware part of the computer. Interpreters are easy to write and do not require large memory in computer. 5. Lotus 1-2-3. Thus compiled machine language program runs much faster than an interpreted program. 3. 3. DOS. COBOL. namely.7 WHAT YOU HAVE LEARNT In this lesson we discussed about two types of software. It communicates with printer. We have discussed about levels of computer language. The disadvantage of interpreter is that it is time consuming method because each time a statement in a program is executed then it is first translated. It eliminates the need for a separate compilation after changes to each program. UNIX and WINDOWS are three important system softwares. (c) The disadvantage of interpreter is that it is time consuming.from compiler. 6 7 8 TERMINAL QUESTIONS What is software and hardware? What is computer Language? Name the three different categories of computer languages. system software and application software. 2. 3. . CPU.

2. FORTRAN (Formula Translation) and BASIC (Beginners All-purpose Symbolic Instruction Code) are some of the high level languages. 3. 2. System software is a set of programs written for performing tasks such as controlling all operations required to move data into and out of the computer. It is written in binary form that is 0 and 1. Programming is the process of software development. The set of symbols and letters forms the Assembly Language. Machine Languages are the only language that is directly understood by the computer.9 10 3. 2. (a) True (b) False (c) True IN-TEXT QUESTIONS 3 1. 3.9 What is compiler? Why is it required? What is interpreter? How does it differ from compiler? FEEDBACK TO IN-TEXT QUESTIONS IN-TEXT QUESTIONS 1 1. Software is a set of computer programs and procedures that describe the programs. (a) False b) T rue (c) True IN-TEXT QUESTIONS 2 1. Program is a set of instructions given to the computer by the user. Both compiler and interpreter are program translators used for translating higher level language into machine language. While compiler scans the entire program first and then translates it into machine code. (a) True (b) False (c) True 28 . an Interpreter translates the program line by line. FORTRAN is used for scientific applications whereas COBOL is used for business applications. 3. Application Software is a set of programs to carry out operations for a specific application.

Thus data transmission is the movement of information using some standard methods.2 OBJECTIVES After going through this lesson you will be in a position to: explain the concept of data communication understand the use of computer network identify different components of computer network identify different types of network explain communication protocols understand what is internet and email and its uses in modern communication appreciate the use of satellite communication. Basic Elements of a Communication System The following are the basic requirements for working of a communication system. For communication of information and messages we use telephone and postal communication systems.LESSON 4 COMMUNICATION AND COMPUTER NETWORK 4.3 DATA COMMUNICATION We all are acquainted with some sorts of communication in our day to day life. 29 . Now a user sitting at one place can communicate computers of any remote sites through communication channel. he can send the letters to all the clients within minutes. First he has to use his PC and Word Processing package to prepare his letter. Thus irrespective of geographical areas. The modern form of communication like e-mail and Internet is possible only because of computer networking. if PCs are connected through communication channel. 4.1 INTRODUCTION Today computer is available in many offices and homes and therefore there is a need to share data and programs among various computers with the advancement of data communication facilities. 4. Similarly data and information from one computer system can be transmitted to other systems across geographical areas. The aim of this chapter is to introduce you the various aspects of computer network. Suppose a manager has to write several letters to various clients. These methods include electrical signals carried along a conductor. If the PC is connected to all the client's PCs through networking. The communication between computers has increased and it thus it has extended the power of computer beyond the computer room. computer files and any other program can be transmitted to other computer systems within seconds. optical signals along an optical fibers and electromagnetic areas. the data and information.

Simplex: In simplex mode the communication can take place in one direction. Hence the flow control regulates the process of sending data between fast sender and slow receiver. Thus a half-duplex line can alternately send and receive data. The data communication software instructs computer systems and devices as to how exactly data is to be transferred from one place to another. 4.3. Full-duplex: In full duplex the communication channel is used in both directions at the same 30 .directional. It ensures that data are transmitted without any error. A receiver (sink) which receives the message. Hence it is rarely used for data communication. The receiver receives the signal from the transmitting device. They are Data: A collection of facts in raw forms that become information after processing. 2. Data Routing: It is the process of finding the most efficient route between source and destination before sending the data. A medium that carries the message.1 Communication Protocols You may be wondering how do the computers send and receive data across communication links. Half-duplex: In half-duplex mode the communication channel is used in both directions. The data transmission software or protocols perform the following functions for the efficient and error free transmission of data.3. Signals: Electric or electromagnetic encoding of data. Signaling: Propagation of signals across a communication medium. 3. It is this software that enables us to communicate with other systems. In this mode the flow of information is Uni. 3. 4. Error Control: Error detecting and recovering is the one of the main function of communication software. but only in one direction at a time.1. Transmission: Communication of data achieved by the processing of signals. A sender (source) which creates the message to be transmitted. Flow control: All machines are not equally efficient in terms of speed.2 Data Transmission Modes There are three ways for transmitting data from one point to another 1. In data communication four basic terms are frequently used. 2. Data sequencing : A long message to be transmitted is broken into smaller packets of fixed size for error free data transmission. The answer is data communication software. The procedure of data transformation in the form of software is commonly called protocol.

So one should know the fundamental difference between analog and digital signals. Example of this mode of transmission is the telephone line. And the reverse process.time.1 4. In analog signal the transmission power varies over a continuous range with respect to sound. 4.2 31 .3 Digital and Analog Transmission Data is transmitted from one point to another point by means of electrical signals that may be in digital and analog form. The device. that is the conversion of analog signal to its digital form.3. So the technique by which a digital signal is converted to analog form is known as modulation. A Simplex A to B only A Half-Duplex A to B or B to A B B A Full-Duplex A to B and B to A B Fig. A digital signal is a sequence of voltage represented in binary form. Analog signal is measured in Volts and its frequency in Hertz (Hz). When digital data are to be sent over an analog form the digital signal must be converted to analog form. is known as demodulation. Use of full-duplex line improves the efficiency as the line turn-around time required in halfduplex arrangement is eliminated. which converts digital signal into analog. is known as modem. 4. and the reverse. light and radio waves. Time Analog Signal Digital Signal Fig. Examples are computer and computer related equipment. On the other hand a digital signal may assume only discrete set of values within a given range.

microwave signal is transmitted from a transmitter on earth to the satellite at space. In order to overcome the problem of line of sight and power amplification of weak signal. However. A communication satellite is a microwave relay station placed in outer space. They are usually made up of copper and the pair of wires is twisted together. On the other hand. Hence there is irregular gaps between characters. Following are the major communication devices used to day. 2. In asynchronous transmission data is transmitted character by character as you go on typing on a keyboard. the saved data is transmitted block by block. They are used for long distance telephone lines and local area network for their noise immunity and faster data transfer.3. as you do not have to save the data before sending. They consist of a central copper wire surrounded by an insulation over which copper mesh is placed. repeaters are used at intervals of 25 to 30 kilometers between the transmitting and receiving end. Coaxial Cables: Coaxial cable is groups of specially wrapped and insulted wires that are able to transfer data at higher rate. The main advantage of satellite communication is that it is a single microwave relay station visible from any point of a very large area. in the synchronous mode. it is cheaper to implement. Each block can contain many characters. Data transmission speed is normally 9600 bits per second in a distance of 100 meter. They are mostly used to link big metropolitan cities. INSAT-1B is such a satellite that can be accessible from anywhere in India. In microwave the data transmission rate is 16 giga bits per second.4 Asynchronous and Synchronous Transmission Data transmission through a medium can be either asynchronous or synchronous. IN-TEXT QUESTIONS 1 1. Communication Satellite: The problem of line-sight and repeaters are overcome by using satellites which are the most widely used data transmission media in modern days. Synchronous transmission is well suited for remote communication between a computer and related devices like card reader and printers. Microwave: Microwave system uses very high frequency radio signals to transmit data through space. What is communication protocol? What is the difference between asynchronous and synchronous transmission? 32 . In satellite communication. The satellite amplifies the weak signal and transmits it back to the receiver. The transmitter and receiver of a microwave system should be in line-of-sight because the radio signal cannot bend. Wire Pairs: Wire pairs are commonly used in local telephone communication and for short distance digital data communication. With microwave very long distance transmission is not possible.4.

software and hardware. i. which is quite expensive. (d) Analog signal is measured in Volts and its frequency in Hertz (e) The technique by which a digital signal is converted to analog form is known as modulation. Local Area Network (LAN) 2. State whether True or False (a) The basic requirements for working of a communication system are sender medium and receiver. which access shared network resources. 4. (c) In full duplex the communication channel is used in both directions at the same time. People working in LAN get more capabilities in data processing. In computer network two or more computers are linked together with a medium and data communication devices for the purpose of communicating data and sharing resources. The transmission medium is normally coaxial cables.1 Local Area Network Networks used to interconnect computers in a single room.. LAN transmits data with a speed of several megabits per second (106 bits per second). (b) Electric or Electromagnetic encoding of data is called Transmission. are known as workstations or nodes.4. In the network the individual computers.e. The computer that provides resources to other computers on a network is known as server.3. Because of this information exchange most of the business and government organisations are using LAN. Major Characteristics of LAN every computer has the potential to communicate with any other computers of the network high degree of interconnection between computers easy physical connection of computers in a network inexpensive medium of data transmission high data transmission rate 33 . rooms within a building or buildings on one site are called Local Area Network (LAN). Wide Area Network (WAN) 4. LAN links computers.4 COMPUTER NETWORK A computer network is an interconnection of various computer systems located at different places. Computer Networks may be classified on the basis of geographical area in two broad categories. 1. work processing and other information exchange compared to stand-alone computers. in the same area for the purpose of sharing information. Usually LAN links computers within a limited geographical area because they must be connected by a cable.

Addition of new computer to network is easy. for a large company the head quarters might be at Delhi and regional branches at Bombay. microwaves and satellite links. For example. Centralised Information: In modern computerised environment you will find that big organisations go for centralised data storage. national or global area. High rate of data transmission is possible. Bangalore and Calcutta. 3.3 Characteristics of WAN Followings are the major characteristics of WAN. 1.Advantages The reliability of network is high because the failure of one computer in the network does not effect the functioning for other computers. Computer conferencing is another use of WAN where users communicate with each other through their computer system. Use of LAN Followings are the major areas where LAN is normally used File transfers and Access Word and text processing Electronic message handling Remote database access Personal computing Digital voice transmission and storage 4. Madras. Communication Facility: For a big company spanning over different parts of the country the employees can save long distance phone calls and it overcomes the time lag in overseas communications. This means if the organisation is spread over many 34 . For example.4. Therefore the transmission medium used are normally telephone lines. The distance between computers connected to WAN is larger. suppose you are sitting at Madras and want to see some data of a computer located at Delhi.4. Remote Data Entry: Remote data entry is possible in WAN. the entire network system breaks down. It means sitting at any location you can enter data. Peripheral devices like magnetic disk and printer can be shared by other computers. you can do it through WAN. update data and query other information of any computer attached to the WAN but located in other cities. Disadvantages If the communication line fails. Here regional centers are connected to head quarters through WAN.2 Wide Area Network The term Wide Area Network (WAN) is used to describe a computer network spanning a regional. 2. 4.

Aparnet: The Aparnet is another example of WAN. 35 . they keep their important business data in a single place. Department.4.cities. either telephone lines or satellite links. As the data are generated at different sites. The transmission speed in LAN varies from 0. bus topology and ring topology. S. 2. This Network connects more than 40 universities and institutions throughout USA and Europe. The speed of data transmission is much higher in LAN than in WAN. This network uses coaxial cables for data transmission. It was developed at Advanced Research Projects Agency of U. WAN permits collection of this data from different sites and save at a single site. 4. But WAN covers great distance and operate nationwide or even worldwide.1 to 100 megabits per second. In WAN there is no physical connection. They are star topology. According to the physical arrangements of workstations and nature of work. there are three major types of network topology. Cost of data transmission in LAN is less because the transmission medium is owned by a single organisation. In LAN. Difference between LAN and WAN LAN is restricted to limited geographical area of few kilometers. It is because in LAN the distance covered is negligible.4 Examples of WAN 1. 4. In case of WAN the cost of data transmission is very high because the transmission medium used are hired.5 NETWORK TOPOLOGY The term topology in the context of communication network refers to the way the computers or workstations in the network are linked together. In case of WAN the speed ranges from 1800 to 9600 bits per second (bps). Ethernet: Ethernet developed by Xerox Corporation is a famous example of WAN. Communication is done through telephone lines and satellite links. Few data transmission errors occur in LAN compared to WAN. Special integrated circuit chips called controllers are used to connect equipment to the cable. the computer terminals and peripheral devices are connected with wires and coaxial cables.

There is bi-directional communication between various nodes.3: Star Topology 4.3). The central node controls all the activities of the nodes.4: Bus Topology 36 . Any communication between stations on a star LAN must pass through the central node. The disadvantage of bus topology is that any break in the bus is difficult to identify. 4. nodes      bus     Fig. Transmission from any station travels the length of the bus in both directions and can be received by all workstations.2 Bus Topology In bus topology all workstations are connected to a single communication line called bus. In this type of network topology there is no central node as in star topology. 4.5. Fig.4. 4.1 Star topology In star topology a number of workstations (or nodes) are directly linked to a central node (see.5. The advantage of the bus topology is that It is quite easy to set up. The advantages of the star topology are: It offers flexibility of adding or deleting of workstations from the network. The major disadvantage of star topology is that failure of the central node disables communication throughout the whole network. Breakdown of one station does not affect any other device on the network. If one station of the topology fails it does not affect the entire system. NODE   CENTRAL NODE    Fig.

If one station of the topology fails it does not affect the entire system. What are the different types of network topology? State True or False (a) Networks used to interconnect computers in a single room. (d) In star topology a number of workstations (or nodes) are directly linked to a central node. 3.3 Ring Topology In ring topology each station is attached nearby stations on a point to point basis so that the entire system is in the form of a ring.5. (e) The advantage of the bus topology is that. rooms within a building or buildings on one site are called Wide Area Network (WAN).   NODES     Fig. (b) The term Wide Area Network (WAN) is used to describe a computer network spanning a regional. You can gather 37 . If your computer is connected to the Internet. you can connect to millions of computers. (c) The speed of data transmission is much higher in WAN than in LAN. 4.6 INTERNET The Internet is a network of networks. The disadvantage of ring network is that the breakdown of any one station on the ring can disable the entire system. Thus the data packets circulate along the ring in either clockwise or anti-clockwise direction.4. 4. Computer users on the Internet can contact one another anywhere in the world. Millions of computers all over the world are connected through the Internet. The advantage of this topology is that any signal transmitted on the network passes through all the LAN stations. 2. national or global area. Differentiate between LAN and WAN.5: Ring Topology IN-TEXT QUESTIONS 2 1. In this topology data is transmitted in one direction only.

etc. medicine. health. science. Every university in the country wanted to become a part of ARPANET. What is e-mail? 38 . In Internet a huge resource of information is accessible to people across the world. Origin of Internet In 1969 Department of Defence (DOD) of USA started a network called ARPANET (Advanced Research Projects Administration Network) with one computer at California and three at Utah. history. You can also download programs and software packages from anywhere in the world. What is Internet? 2. APARNET quickly grew to encompass the entire American continent and became a huge success. By 1990 many computers were looking up to NSFNET giving birth to Internet. This is a voluntary membership organisation whose purpose is to promote global information exchange. E-mail E-mail stands for electronic mail. How Internet functions Internet is not a governmental organisation.information and distribute your data. news. Later on other universities and R & D institutions were allowed to connect to the Network. it is now indispensable to every organisation. Mails are regularly used today where with the help of postage stamp we can transfer mails anywhere in the world. So the network was broken into two smaller parts MILNET for managing military sites and ARPANET (smaller) for managing nonmilitary sites. other computers were also allowed to be linked up with any computer of NSFNET. NSFNET (National Science Foundation Network) was created. Therefore the mailing system is excessively fast and is being used widely for mail transfer. IN-TEXT QUESTIONS 3 1. Due to the tremendous information resources the Internet can provide. and geography to business. The ultimate authority of the Internet is the Internet Society. Around 1980. With electronic mail the service is similar. Information in every field starting from education. But here data are transmitted through Internet and therefore within minutes the message reaches the destination may it be anywhere in the world. Internet has more than one million computers attached to it. This is one of the most widely used features of Internet. can be retrieved through Internet. With the advancement of modern communication facilities. It is very much similar to the telephone connection where you can talk with any person anywhere in the world.

They are star topology. We discussed about the physical arrangements of computer and peripherals in network topology. 2. In LAN the computer terminals and peripheral devices are connected with wires and coaxial cables whereas in WAN communication is done through telephone lines and satellite links. science. The procedure of data transformation in the form of software is commonly called protocol. the saved data is transmitted block by block. Computers can communicate with one another through computer networking.8 TERMINAL QUESTIONS What is computer Network? What are its main objectives? Differentiate between analog and digital transmission of data. 2. In asynchronous transmission data is transmitted character by character as you go on typing on a keyboard. 4. (a) True (b) False (c) True (d) True (e) True IN-TEXT QUESTIONS 2 1. 39 . 3.3. On the other hand. The speed of data transmission is much higher in LAN than in WAN. The Internet is a network of networks.7 WHAT YOU HAVE LEARNT In this lesson we discussed the importance and modes of communication through computers. The data communication software instructs computer systems and devices as to how exactly data is to be transferred from one place to another. bus topology and ring topology. There are two types of computer network: LAN and WAN. Also we discussed about Internet and e-mail. There are three types of network topology: star topology. 4. 3. How does Internet function? 4. bus topology and ring topology. 2. in the synchronous mode. Explain in brief different communication media. Information in every field starting from education. LAN is restricted to limited geographical area whereas WAN covers great distance. 3. (a) False (b) True (c) False (d) True (e) True IN-TEXT QUESTIONS 3 1. 4.9 FEEDBACK TO IN-TEXT QUESTIONS IN-TEXT QUESTIONS 1 1. What is the difference between simplex and full-duplex transmission? 1. There are three major types of network topology.

and geography to business. history. news. This is a voluntary membership organisation whose purpose is to promote global information exchange. Through e-mail we can transfer data anywhere in the world within seconds. etc. can be retrieved through Internet. 2. E-mail stands for electronic mail. The ultimate authority of the Internet is the Internet Society. 40 . Internet is not a governmental organisation. medicine.health. 3.

it has to be simple. The advantages of BASIC can be summed up as follows: BASIC is easy to learn and fun to practice. It may be called a `People's language'. use some elementary BASIC commands in small programs. Therefore. it is meant for those who are about to start learning programming. It is the most popular conversational programming language. relational and logical operators. science.e. It is becoming more popular as an interactive language. This language is quite simple to understand and has been adopted by most of the microcomputers. In fact. The other three letters i. 24.2 OBJECTIVES At the end of this lesson. It is suitable for both mathematical and business problems. The all purposeness is also derived from the fact that very large segments of games and computer courseware are written in BASIC.3.means the instructions may not be exactly in English but expressed in symbols. 24. Now we shall discuss various features of this language.LESSON 24 ELEMENTS OF BASIC STRUCTURE 24. a program developed in a micro can run on bigger system with minor modifications. mathematics and graphics. you should be able to know how to construct constants. Obviously. BASIC has some of the powers of more advanced languages. 41 .1 INTRODUCTION In this lesson. It is available almost in every computer from micro to mainframe. The second alphabet A stands for all-purpose. you will be introduced to a programming language called BASIC. Although. BASIC has all the qualities.1 Why BASIC? B in BASIC stands for Beginners. It has been specially designed for use in `time-sharing' environment but can also be used as a standard language in a `batch-processing' environment. with new enhancements. it is the beginner's language. It means BASIC can be used for a variety of applications involving business. learn the structure and essential elements of BASIC. easy and readily available.3 BASIC AS A PROGRAMMING LANGUAGE Basic is quite simple language and easy to understand. variables in BASIC language and expression using mathematical. its use by no means is restricted to basic computer education or elementary applications. To qualify as a beginner's language. Various versions of BASIC have been developed by computer manufacturers for their computers. 24. SIC stand for Symbolic Instruction Code -.

was already established as the major data processing language. and Modification of programs is quite easy. however.2 onwards.Program development cycle is quick.4 STRUCTURE OF BASIC The general structure of standard BASIC language is best understood by a practical program.e. BASIC found a most convenient vehicle for its proliferation. A statement cannot exceed 80 characters i. BASIC's popularity and acceptance by the user community compelled all the major computer manufacturers to come out with their individual version of BASIC. debugging is simple. FORTRAN on the other hand. The ease and simplicity of BASIC made it the standard programming language for the microcomputer world. It is a positive integer. 42 . COBOL. (MS-DOS 3. It became a widely used language for small commercial and scientific applications. Because of its simplicity. a more enhanced BASIC version. When the microcomputer or PCs were introduced. were not very simple to learn.3. GWBASIC forms the part of the operating system. Most of the versions of the currently available BASIC include the features of the ANSI standard. BASIC had the same impact on the world of programming languages as the PC had on the larger computer systems. There were extensive rules on syntax and structure of the programs. BASIC was born at Dartmouth College. Both these languages.) American National Standards Institute (ANSI) in 1978 came out with a standardised version of BASIC language. BASIC gained immediate popularity. one line on the terminal. Even your MSDOS operating system comes with a BASIC interpreter called BASICA. in fact.. 24. These are: Each statement of instruction must appear on a separate line. USA in 1964. The following small program prints the words WELCOME TO NATIONAL OPEN SCHOOL on the screen: 10 20 30 REM: This is my first program PRINT "WELCOME TO NATIONAL OPEN SCHOOL" END Keeping this program in view. No two statements can have the same numbers. 24. The statement must be in the ascending order. let us go over the rules on the structure of the language. The classical languages like COBOL or FORTRAN were already developed. A statement must start with a statement number. i. became the principal programming language for scientific applications.2 History of BASIC Conceived by John Kemeny and Thomas Kurtz. It had a rather humble beginning.e.

as the keyword. At times to enhance the presence of a REM statement you may place a blank line above or below a statement. 24. These are the rules. you came across their important BASIC commands or keywords. 24. may be placed after REM. but it may also help you in understanding your own programs. You can place a blank line by a PRINT statement. This makes it more visible in lengthy programs. you came across in the program. In fact. These are REM. it is recommended that you get used to judicious and copious use of REM statements.e. has provision for more than one statement in the same line and the use of keywords also need not follow a line number. it may mean display on the terminal or write on a disk file also. information on the program.5. The output may be meant for the terminal (as in this case) or it may be directed to a disk file. The PRINT will be discussed in greater details in subsequent lessons. But if you strictly follow the rules of standard BASIC.1 REM The REM is the short form for REMARKS. There is no restriction on blank lines within a program. print does not necessarily mean a print out on a paper. you want to convey to the reader of the program. It is meant for the reader of the program to understand the contents. At the time of execution. BASICA or GWBASIC. PRINT and END. as an output instruction. particularly if those are old or lengthy. Whatever. The Microsoft BASIC i. We will briefly discuss REM and END here. You may use blank space to increase the readability of the program. when the interpreter comes across the first three alphabets. There is no limit on the number of REM statements in a program. it knows that the content of the line following REM is not meant for execution and is to be ignored. REM is used purely to enhance the documentation aspect of a program.Each statement number is followed by a BASIC command or keyword. If we want to insert a blank line after the REM statement of the program. that in BASIC. is to remember. the program will still remain valid in Microsoft or any other BASIC.5 ELEMENTARY BASIC STATEMENTS In the program. It may not only help the reader. we may write the program as: 10 20 30 40 REM : This is my first program PRINT PRINT "WELCOME TO NATIONAL OPEN SCHOOL" END 43 . as applicable to standard or "Dartmouth BASIC" as it is called. What is important. however. Now let us learn about some of the keywords. logic and other such aspects. you may take PRINT. purpose. Presently for the purpose of understanding.

$ .2. In addition these. it is not compulsory. 9 and may include a decimal point. In such cases.15E4 are valid numeric constants. its length cannot exceed two digits.1. The notation E is used to represent exponential form. However.6. 24. 9 and Special characters: + .* / ( ) . represent 6.2. B. + 57. in fact.15E4.1. : = > < " ^ The symbol ^ (caret) is used to denote exponentiation operator.15 104. The number 6.24. blank space denoted by the symbol b is also regarded as a character. BASIC allows the following constants: Numeric constant String constant Numeric constant is one that is formed by a sequence of digits 0. it must be the last line. Z Digits: 0. In other BASIC like Microsoft BASIC. It is also important to keep in mind that BASIC does not distinguish between an integer and a fraction. 0. Any statement after the END is irrelevant to the interpreter. ---. C. 24. .6 THE CHARACTER SET BASIC has the character set consisting of the following elements: (a) (b) (c) Alphabets: A. Whenever END is used. Having been familiarised with a small BASIC program. the program terminates at the last or highest line number. The number after E is the exponent which can be positive or negative. Commands are not allowed in a numeric constant 44 .2 and 6. let us now see the elements other than the keywords. A numeric constant known as number may be as integer or a real number.5. ----. the symbol * (asterisk) is used to denote multiplication and the other symbols have their usual meanings.2 END The END statement was mandatory in the older BASIC version to indicate the end of a program. ----. 383. comprising this language.7 CONSTANTS AND VARIABLES A quantity in a computer program which does not change its value during the execution of the program is called a constant and the quantity which may change its values during the execution of the program is called a variable. .

PKG$. Indicate the errors: (a) (b) (c) (d) (e) 4. String constants are used to represent non-numeric quantities such as names. variables are also of two types.The limit on the number of digits that can be used varies from computer to computer.163. A string constant consists of a sequence of characters.40 =60 SUM "10" 3. "SUM = Rs 75". For example A.75. ABC. BOOK1$. represent numeric variables. Which of the following BASIC strings are correct? (a) (b) (c) (d) (e) January 26. a numeric constant can have up to a maximum of eight digits. etc. 1997 Sixty-two 5121942 100 . A2. For example. dollar ($) should be the last character. +-7567 3. Normally.64E 1.05E 6125 - 2. A string variable is represented by an alphabet followed by dollar ($) sign. In BASIC. They are Numeric variable String variable Numeric variable can assume numeric value and is represented by an alphabet or an alphabet followed by another alphabet or a digit. addresses. This may contain blank space as a character but it should not include the quotation mark. For example. It should be kept in mind that while constructing the string variable.5 6. are valid string variables. A6 etc. IN-TEXT QUESTION 1 1.. "PANKAJ GOEL". etc. It must be enclosed by a quotation mark. The following numbers (constants) are not written correctly. "162" are a few valid string constants. A1$. C. Write the following as ordinary numbers: 45 .

C+-D. For example. the natural hierarchy of operations will apply. Note that within a particular hierarchical group. they must be used in pairs. P+P$ is wrong.2 E -2 24. Let us take an example where we give BASIC equivalents of a few algebraic expressions Algebraic Expression BASIC Equivalent 2A+B 2*A+B 46 . etc are not permitted. When brackets are used.5E . then multiplication/division and the addition/subtraction operations are the last to be carried out. /(division) and ^ (exponentiation).e. For example.. Denominator of an expression should not be zero. the order of execution is as per this hierarchy.8 ARITHMETIC EXPRESSIONS A BASIC system can handle arithmetic expressions involving the five arithmetic operators + (addition). In addition to this hierarchy of operations.865696 E + 6 .(subtraction). in a particular arithmetic expression. Normal hierarchy of operations can be altered by use of parentheses.e. every left bracket must be matched with a right bracket.1.3E + 2 5. all exponentiation operations are performed first.5 . i. the following rules must be kept in mind in arithmetic expression: Two operations must not appear together. . Within a given pair of parentheses. the operations are executed form left to right. String constants and string variables should not be used in arithmetic expressions. *(multiplication). i.(a) (b) (c) (d) (e) 1. The operations within the innermost parentheses are performed first and then the second innermost and so on. A/-C.23E6 1. The hierarchy of operations is as follows: (i) (ii) (iii) Exponentiation Multiplication and division Addition and subtraction Thus.

. we may be interested to check the number of repetitive calculations performed or to find out whether the denominator of an arithmetic expression has become zero or if a particular quantity is negative. For example. . TRUE or FALSE... Expressions written to compare two quantities using certain relational operators are known as relational expressions... the relational expression A > B will be true if A is greater than B.. namely. These expressions take only one of the two values.9 RELATIONAL OR LOGICAL EXPRESSIONS A relational expression is formed by using any of the following relational operators: Relational Operator = > < <= >= <> Meaning Equal to Greater than Less than Less than or equal to Greater than or equal to Not equal to In the execution of programs... and so on. . otherwise FALSE. The general form of a relational expression is as follows: Constant or Variable or Expression Relational operator Constant or Variable or Expression When expressions are used on either side of the relational operators...... For instance... This test result is used to change the sequence of execution of statements in a program. the expressions will be evaluated first and then the results of expressions compared.A B .. it is sometimes desired to compare two numerical quantities (or sometimes string quantities) and take decisions on achieving certain conditions. This means that relational operators come last in the hierarchy of operators...... .... 47 ..( A B) /(C C D A(B+C) B2-4AC A*(B+C) B^2-4*A*C D) 24......

the expression A > 50 AND B > 150 is TRUE when A is more than 50 and at the same time B is more than 150. The common logical operators are: AND OR NOT Conjunction Disjunction Logical Negation For example.10 LOGICAL OPERATORS Like relational operators.Logical expressions are used in IF---THEN Statements to determine the course of action of a running program. X and Y are relational expressions. also supports logical operators to perform logical operation on numerical values. Logical operators return results as indicated in the following tables. BASIC. AND Operator X T T F F Y T F T F X AND Y T F F F OR Operator X T T F F Y T F T F X OR Y T T T F NOT Operator X T NOT X F 48 . Logical operators are used to connect two or more relations and return a TRUE or FALSE value to be used in a decision. T indicates a TRUE and F indicates a FALSE. 24.

e. These built-in library functions are used to simplify some useful common functions like calculation of square root. Most of the programming languages are offered with a number of sub-routines called sub-routine library or library functions. governing the use of a function. From this example. BASIC's library is rich with mathematical functions.. Using a library function the operation can be performed as 10 LET B = SQR(A) Of course. (b) The function argument is the information you supply to the function to act upon it. it appears that there is hardly any benefit in using the library function. SQR.F T 24. In simple mathematics. Thus in BASIC it can be written as: 10 LET B = A^0. a library is essentially a collection of useful programs. But imagine. suppose you want to calculate the square root of a numeric variable A. In the context of computer languages.) followed by the function argument placed within the parenthesis. For example. (a) Each function is assessed by the function name (LOG. 49 .5 The value of B will be the square root of A. it has to be a numeric constant or variable. square root of A. Listed below are some examples of mathematical functions in BASIC. we may deduce the rules. These programs are used by the programmers to simplify their task of program development. log of a number or cosine of an angle.11 LIBRARY FUNCTIONS IN BASIC The word `library' stands for collection. can be written as A½. The programmer does not have to know the details of the sub-routine. For mathematical factions. i. These programs are often referred as subroutines. from the example. The programming algorithm to calculate these is not so simple. if problem is little more complicated like calculation of the sine value of an angle or logarithm of a number. etc. To find the logarithm of by using LOG function you write 10 LET Y = LOG (X). The variable Y will store the LOG value of X.

It should be noted that a library function program would produce the result faster than a BASIC program that has been written to perform the same task. LOG etc. This is due to the fact that library functions are optimised for the particular BASIC interpreter provided by the supplier. (d) You cannot have a blank space between function name (SIN. Evaluate the following BASIC expressions: (a) (b) 3 * 4/2 ^ 3 + 1 2 * (3+4) / (5-3) * 7 2. IN-TEXT QUESTION 2 1.Function SIN Sine Name Purpose Calculate the Sine value of an angle (in radians) SIN(X) Example SIN(44/7) LOG LOG Calculate the natural LOG(X) logarithm of a number LOG(100) SQR Square root Calculate the square root of a number SQR(A) SQR(100) (c) The function name is to be written exactly as given. No deviation is permitted. calculation of square root by the SQR function will be faster than writing in the form of a program.) and the beginning of the opening parenthesis enclosing the argument. For example. Write the BASIC expression corresponding to each of the following algebraic expression: (a) (b) (c) (d) (x+y) 4 2x2 + 5x + 6 x/y + y/z (x-y)4 / (x+y)4 50 .

1. be emphasized that even if you stick to the rules of standard BASIC. it still remains completely valid for GWBASIC or BASICA and can be run without any problem. an enhanced version of standard BASIC. Differentiate between (a) Numeric and String constant (b) Arithmetical and Relational Expression 4. The purpose is to prepare you with the basic rules of the language. Define BASIC language along with its features. 5. 3. The rules described here pertain to standard BASIC. The knowledge of these is essential for writing programs. It must however. The GWBASIC or BASICA.12 WHAT YOU HAVE LEARNT This lesson is an introductory chapter on BASIC language. 1.24.14 FEEDBACK TO IN-TEXT QUESTIONS 51 . Write down the hierarchy of operations in Arithmetic Expression.13 TERMINAL QUESTIONS 1. Define history of BASIC language briefly. Describe briefly the structure of BASIC language. which is going to be your practical vehicle for learning this language however. incorporating many additional features to add power to the language. 2.

3. (a) (b) (c) (d) (e) 1230000 0. (a) (b) (c) (d) (e) Commas are not allowed Two arithmetic operators +. (a) (b) (c) (d) (e) correct correct correct correct Incorrect because quotation marks are not allowed in strings.012 IN-TEXT QUESTION 2 1. (a) (b) 2. (a) (b) (c) (d) (x+y) ^4 2*x ^ 2 + 5*x + 6 (x/y) + (y/z) (x-y) ^4 / (x+y) ^4 52 .0.000015 -300 5865696 .for the sign cannot be used simultaneously Exponent cannot contain a decimal point E must the followed by some integer number Negative sign should not be in the last 2. .IN-TEXT QUESTION 1 1.5 49 2.

Inc. These flowcharts play a vital role in the programming of a problem and are quite helpful in understanding the logic of complicated and lengthy problems. the advantages and limitations of flowchart 25. Hence. The program flowchart can be likened to the blueprint of a building. Some standard symbols. which are frequently required for flowcharting many computer programs are shown in Fig. it becomes easy to write the program in any high level language. In this lesson. Once the flowchart is drawn.4 GUIDELINES FOR DRAWING A FLOWCHART Flowcharts are usually drawn using some standard symbols.2 OBJECTIVES At the end of this lesson. a programmer prefers to draw a flowchart prior to writing a computer program. 25. As in the case of the drawing of a blueprint. the flowchart is drawn according to defined rules and using standard flowchart symbols prescribed by the American National Standard Institute. Similarly. we shall concern ourselves with the program flowchart.LESSON 25 FLOWCHARTING 25. some special symbols can also be developed when required.1 Start or end of the program Computational steps or processing function of a program 53 . As we know a designer draws a blueprint before starting construction on a building. the operations performed within the system and the sequence in which they are performed. which describes what operations (and in what sequence) are required to solve a given problem.3 MEANING OF A FLOWCHART A flowchart is a diagrammatic representation that illustrates the sequence of operations to be performed to get the solution of a problem. Often we see how flowcharts are helpful in explaining the program to others. you will be able to understand: the meaning of flowchart the basic parts of the flowchart such as flowchart symbols and the flow lines connecting these symbols.1 INTRODUCTION The flowchart is a means of visually presenting the flow of data through an information processing systems. it is correct to say that a flowchart is a must for the better documentation of a complex program. Flowcharts facilitate communication between programmers and business people. 25. however. 25. Flowcharts are generally drawn in the early stages of formulating computer solutions.

or (e) Only one flow line should enter a decision symbol. all necessary requirements should be listed out in logical order.Input or output operation Decision making and branching Connector or joining of two parts of program Magnetic Tape Magnetic Disk Off-page connector Flow line Annotation Display Fig. should leave the decision symbol. (c) The usual direction of the flow of a procedure or system is from left to right or top to bottom. 54 . (d) Only one flow line should come out from a process symbol. but two or three flow lines.1 Flowchart Symbols The following are some guidelines in flowcharting: (a) In drawing a proper flowchart. one for each possible answer. (b) The flowchart should be clear. neat and easy to follow. 25. There should not be any room for ambiguity in understanding the flowchart.

Effective analysis: With the help of flowchart. 3. As necessary. which is needed for various purposes. Communication: Flowcharts are better way of communicating the logic of a system to all concerned. 25. you can use the annotation symbol to describe data or computational steps more clearly. It is useful to test the validity of the flowchart by passing through it with a simple test data. 4. This is top secret data (h) If the flowchart becomes complex. Proper Debugging: The flowchart helps in debugging process. Avoid the intersection of flow lines if you want to make it more effective and better way of communication. Efficient Program Maintenance: The maintenance of operating program becomes easy with the help of flowchart. (g) Write within standard symbols briefly.Yes <0 >0 No =0 (f) Only one flow line is used in conjunction with terminal symbol. Efficient Coding: The flowcharts act as a guide or blueprint during the systems analysis and program development phase. it is better to use connector symbols to reduce the number of flow lines. Proper documentation: Program flowcharts serve as a good program documentation. 6.5 ADVANTAGES OF USING FLOWCHARTS The benefits of flowcharts are as follows: 1. problem can be analysed in more effective way. It helps the programmer to put efforts more efficiently on that part 55 . 5. (i) (j) Ensure that the flowchart has a logical start and finish. 2.

56 . Answer: The required flowchart is given in Fig. flowchart becomes complex and clumsy. (v) __________ are used to join remote portions of a flowchart (vi) ____________ connectors are used when a flowchart ends on one page and begins again on other page (vii) A ________ symbol in used at the beginning and end of a flowchart. one must adhere to prescribed symbols provided by the __________ . (x) The programmed uses a ____________ to aid him in drawing flowchart symbols. reproduction of flowchart becomes a problem. The essentials of what is done can easily be lost in the technical details of how it is done. 2. 25. Alterations and Modifications: If alterations are required the flowchart may require re-drawing completely. (ii) A program flowchart is generally read from _____________ to ________________ (iii) Flowcharting symbols are connected together by means of ___________________ (iv) A decision symbol may be used in determining the ____________ or ___________ of two data items. Fill in the blank. Example 1 Draw a flowchart to find the sum of first 50 natural numbers. Complex logic: Sometimes.6 LIMITATIONS OF USING FLOWCHARTS 1. Reproduction: As the flowchart symbols cannot be typed. (ix) To construct a flowchart. 4.2. the program logic is quite complicated. This will help in student in program development process at a later stage.25.. (i) A program flowchart indicates the_________ to be per formed and the __________ in which they occur. (viii) The flowchart is one of the best ways of ________ a program. 25. 3. IN-TEXT QUESTIONS 1 1. In that case.7 FEW EXAMPLES ON FLOWCHARTING Now we shall present few examples on flowcharting for proper understanding of this technique.

START

SUM = 0

N=0

N=N+1

SUM = SUM + N NO IS N=50? YES PRINT SUM

END

Fig. 25.2 Sum of first 50 natural numbers

Fig 2.2 Flowchart for computing the sum of first 50 natural numbers.

57

Example 2 Draw a flowchart to find the largest of three numbers A,B, and C. Answer: The required flowchart is shown in Fig 25.3

START

READ A, B, C

YES

IS B>C?

NO

IS YES A>B? NO NO

IS YES A>C?

PRINT B

PRINT C

PRINT C

PRINT A

END

Fig 25.3 Flowchart for finding out the largest of three numbers

58

Example 3 Draw a flowchart for computing factorial N (N!) Where N! = 1 2 3 …… N .

The required flowchart has been shown in fig 25.4 Answer:

START

READ N

M=1 F=1

F=F*M NO M=M+1 IS M=N? YES PRINT F

END

Fig 25.4

Flowchart for computing factorial N

59

Example 4 A company‟s salesmen are selling toothpaste and tooth powder. The company having 50 salesmen gives 10% commission on the sale of toothpaste and 20% commission on tooth powder. Draw a flowchart to compute and print the total sale and the total commission for each salesman.

Answer: The required flowchart is shown in Fig 25.5 Note: S = Salesman number P1 = Amount of sales of paste P2 = Amount of sales of powder K = Counter for the number of salesman

Fig 25.5: Flowchart for Computing Commission on Different Items

60

Example 5 Modify the flowchart in Example 4 to print the following heading. Salesman No Total Sale Total commission

Under these heading, write the values of these variables for the 50 salesmen. At the end, the totals of the entire sale and the entire commission should also be printed out.

Answer: The required flowchart is shown in Fig 25.6

Note: TS = Total sales TC = Total commission

61

2. This will help the students in learning this technique easily. Define Flowcharting. 25. Draw a flowchart to find the sum of given N numbers. Draw a flowchart to read a number N and print all its divisors. sequence (ii) Top.10 FEEDBACK TO IN-TEXT QUESTIONS IN-TEXT QUESTIONS 1 1. What are name and the use of the following symbols? (a) (b) (c) (d) (e) 2.6 Flowchart for writing proper heading and its contents IN-TEXT QUESTION 2 1.8 WHAT YOU HAVE LEARNT In this lesson. inequality (v) connectors (vi) Off -page (vii) Terminal (viii) documenting (ix) ANSI (American National Standards Institute) (x) Flowcharting template IN-TEXT QUESTIONS 2 62 . we have discussed the advantages and limitation of flowcharting.Fig: 25. ( i ) Operations. Draw a flowchart to arrange the given data in an ascending order. 4.9 TERMINAL QUESTIONS 1. Draw a flowchart to computer the sum of squares of integers from 1 to 50 5. 25. 25. down (iii) Flow lines (iv) Equality. We have also shown some examples of flowcharting. Draw a flowchart for computing the sum of the digits of any given number 3.

Flowcharting is a technique of showing logical flow of data in pictorial form and integration of programming steps for solving a given problem. (b) Terminal To indicate start or end of a program (c) Decision marking To make logical construction to check some condition.1. 63 . Symbol (a) Name input/output Use To represent input of data for processing or output of processed information. (d) Process To represent an operation or a set of operation (e) Connector To link one part of flowchart to another 2.

3 INPUT-OUTPUT STATEMENTS It should be always kept in mind that computer cannot do anything by itself. develop BASIC programs using the various basic commands offered by the language 26. a user has to provide correct data and a series of processing instructions in proper order. learn the use of LOOPING and CONTROL statements. We also saw how these constants. They are LET. we should ask the computer to produce the results in a proper format that can be understood by the common man. To achieve the required output in the desired format. In this section.LESSON 26 INPUT/OUTPUT AND PROGRAM CONTROL STATEMENTS 26. we will discuss various input/output statements provided in BASIC language.2 LET Statements Syntax: Line number LET (variable name)=(Constants or Variables or expression) 64 . 26. 26. INPUT and READDATA.3. PRINT.1 Getting Data into Memory As stated earlier. PRINT USING etc. BASIC offers three such kinds of input statements. These statements are basically used to assign values to various variables. we should give some values to the computer. completes the required computation work. For a computer program to be executed using a computer.1 INTRODUCTION In the previous lesson. you should be able to: understand clearly the use of INPUT/OUTPUT statements such as LET. variables and the arithmetic operations may be combined to form expressions and statements. Once the computer. we studied about the constants. one of the basic features of a programming language is the input/output facility offered by it. INPUT. Now we shall learn how the complete program in BASIC language can be written using the basic principles we have learnt so far. Besides these we shall also discuss the use of repetitive and branching statements used in BASIC language. READ-DATA. It will act according to the instructions supplied to it by the user. the variables and the arithmetic operation used in the BASIC language. 26.3. The INPUT/OUTPUT statements of the BASIC language achieve these two important functions.2 OBJECTIVES At the end of this lesson.

Example of LET statement 10 20 30 40 50 60 70 80 LET X =5.32 ---> This is numeric constant LET A = 6+9/3. In the memory the line number 15 gives an instruction by which A will be the address or name of a cell/location where the value 10 will be stored. Memory location A Execution of line 15 Execution of line 25 Execution of line 35 10 10 15 Memory location B Not known 5 5 65 . assigned the value 10 and B is the variable name assigned the value 5.2--> This is an arithmetic expression LET Y = X+A --> This is also an arithmetic expression LET I = 2 -->numeric constant LET I =I+Y -->I and Y are variable names LET A$ = "NEW DELHI”--> String variable LET F$ = "99983" -->String variable LET A = B--> numeric variable These are all valid LET statements. Similarly B will be name or address of a cell/location where 5 will be stored. which is. Line number 35 instructs that the values in the address A and B be added and the resulting value be kept at the cell/location whose address is A. The value of the variable on the left hand side of the equal to sign is assigned the value given in the right hand side of the equal to sign EXAMPLE 15 25 35 LET A =10 LET B =5 LET A = A+B The example shows A is the variable name.

In such cases READ statements are found useful.. In case of an input statement. So in the next line number 35. 66 .3. By a LET statement we can assign one value for each variable and if we have to get 10 values for 10 variables we have to use 10 statements with LET.F$. READ statement will always have a DATA statement along with it. 26. List.N$ 20 INPUT Y1.F$. If there is a large amount of data to be processed..4 READ-DATA Statement The LET and INPUT statement have certain limitations.e. because in this program we have not given any value to the variable name B on line number 15..C2. Since variable A has been already given the value 10 that continue to stay in A until we assign a different value to A which replaces the earlier value.. it is inconvenient to key in the entire data during the execution of the program. the data is provided at the prompt at execution time. Location A Line number 15 Line number 25 Line number 35 10 10 10 Location B Not known 5 5 Location C Not known Not known 15 26. Syntax Line number READ Variable.B. It's value is given in the next line number 25. A+B the values of A and B given before are added and put in the location A Now the latest value of A is 15 and that of B will remain as 5. i. EXAMPLE 12 INPUT A.NB Whenever computer reads a line with the keyword INPUT it displays a sign? on the VDU and waits for the data.List.3. Also if a value is assigned through a LET statement its value can be changed only by replacing that assignment statement by another assignment statement.. We have to give the values of the variable at this prompt through the keyboard. 15 and put it in a third location C.X 16 INPUT A$.Note here that after execution of line 15 it has been shown “Not known” in location B.3 INPUT Statement Syntax Line number INPUT Variable. Let us suppose that line 35 has been replaced as 35 LET C = A + B Here computer will add the values of A and B.

M. after 8. -101 DATA -691.51.e..9.81 DATA 8.C4.Y DATA 122 DATA-35. In the next READ statement in line number 9 we have four more variables A.K it will collect from the DATA statements the values for these variables in the same order..5 END DATA BLOCK 67 . X2=8. Since all the values in the DATA here are exhausted.e.9.10. i.B3.. It is a normal practice to keep all DATA statements together at the end of the program before END statement.30. When the READ statement are executed a pointer moves along with data block starting from the first element: EXAMPLE 1 7 12 19 24 26 28 30 40 READ X1.3.K READ A.-5. C4=30. i.. Example of a READ. K=15. A DATA statement can be anywhere in the program but must be before the END statement..B3. Z1 READ N.DATA Statement 1 5 9 22 30 REM PROGRAM EXPLAINING READ. Z1=13. These values will follow in the same order and one-to-one correspondence after the earlier READ variables values...Z1.92 END When the machine encounters the line number 5 with the READ statement followed by the variables X2.DATA STATEMENT READ X2.e.Z1. K READ A READ X.5 DATA BLOCK The BASIC organises the contents of all the DATA statements into a data block. A=16. Y1. L DATA 8.Line number DATA Constant.13.Y. another i. Y=9. L=92. i. C4. A one-to-one correspondence exists in READ-DATA statement. READ statement cannot be used until another DATA statement is included or more DATA is included in the above DATA list in line number 22. List. third.L..e.Y. B3=51.15.. L.16.49..13.. 26.15. so that in case you want to alter any data at the end it will be easy.

.300 READ A$.A. C 30 .300 END (c) 10 20 30 40 50 60 DATA "RAMA"."DELHI".C 68 .C ------ 40 .200.B$ READ A. (a) 10 20 DATA "RAMA". B.B$ READ A..60 70 100 DATA "RAMA"."DELHI" DATA 100..100.200.B..Value 122 -35 49 -101 -691 81 8 10 -5 5 Pointer <--<--<--<--<--<--<--<--<--<--- Variable X1 Y1 Z1 N M L K A X Y Now look at the following some examples where all the programs do exactly the same work.."DELHI" DATA 100 DATA 200 DATA 300 READ A$..40 ----- -------------80 END (b) 10 20 30 READ A$.B.B$..

. 10 RESTORE The RESTORE statements may be used anywhere in the program.C are assigned the values 100.. If the number of values in DATA is less.300 ------------100 END In all these cases A$ is assigned the value RAMA and B$ the value DELHI.B. 26.6 Restore Statement The RESTORE statement beings the pointer to the first value of the DATA statement regardless of the current position of the pointer.e.------------100 END (d) 10 20 30 40 50 READ A$ READ B$. The following example will clearly illustrates the use of RESTORE statement 10 READ X.200. Although normally we keep all the DATA statements at the end of the program just before END statement. It may be more.A.3.C DATA "RAMA" DATA "DELHI" DATA 100.DATA statement we should follow the following There could be any number of READ and DATA statements.. The type of variables (i.All the numeric variables A. at least the same number of values should be there in the DATA statement. Syntax Line number RESTORE For example. then there will be an error message OUT OF DATA given by the computer.. of course.Y 69 .B. before the END statement. DATA statement can occur anywhere in the program but before END statement. So we note that for READ. numeric. string) in the READ statements containing many variables.300 respectively.200. As many variables are read by READ statement.

N$ END When the statement number 10 is executed. the pointer is brought back to the first data value of data statement as shown below: 10 ( Pointer) 12 -7 3.2 "PANKAJ" (Pointer) (Position of pointer before execution of RESTORE statement) When the statement 30 RESTORE is executed.. the execution of the statement number 40 against the value to A.2 PANKAJ The RESTORE statement can be used in the following forms also: Statement number RESTORE * and Statement number RESTORE $ If the key word RESTORE is followed by asterisk (*).C. then only numeric pointer is reset as shown in the previous example.D.D and N$ will be as shown below: A B C D N$ 10 12 -7 3. However.12. "PANKAJ" RESTORE READ A.-7. The simultaneous use of both asterisk (*) and dollar sign ($) is not allowed.3. 70 . then only string pointer is reset to the first string data. the position of the pointer at this stage is shown below: 10 12 -7 3.2.C.20 30 40 50 DATA 10.B.B. if the key word RESTORE is followed by a dollar sign ($).2 "PANKAJ" Now. the variables X and Y are assigned the values of 10 and 12.

The values DINESH and UPMA are being ignored. the string pointer is reset to the first string data namely DINESH.8.12.B.B$ ------------DATA 5. The execution of the statement 30 would assign the values 10 and 12 to the variables P and Q and then the pointer moves back-ward to assign the values DINESH and UPMA to the variables A$ and B$ 26. 10 20 30 40 50 60 70 80 90 READ A. the execution of RESTORE$ can also shown by taking similar example.A$. The execution of statement 40.N$ and M$ are same as in the previous example. restores the numeric pointer to the first numeric value in the DATA statement i.10.Q.e. 71 . A..B. "UPMA". Consider another example 10 20 30 40 50 READ A.Q.A$ and B$.A$..For example.M$ ------------RESTORE * READ P. However."RAJESH". if a BASIC program contains the following statements.B$ DATA 5.B.4 PRINT STATEMENT The PRINT statement of BASIC provides limited methods of controlling the alignment and spacing of printout in terminals.12."SANJU" END When the statement 10 is executed. The execution of the statement 50. The general from of the PRINT statement is Line number PRINT (Variable) separator (variable) separator or item. Similarly.. RAJESH and SANJU respectively to the variable P.UPMA". assigns the value 5. 10.."RAJESH"."DINESH".N$.8.. when statement 20 is executed. to the value 5.8. The values assigned to the variable A.N$.M$ RESTORE $ READ P.B are assigned values 5 and 8 whereas the variables N$ and M$ are assigned the values DINESH and UPMA respectively. "DINESH".Q.SANJU" END Here the statement RESTORE$ is used.

##".1 The Semicolon (.56 33 Zone 3 SIZE 36 49 Zone 4 REMARK 34 65 Zone 5 85 The number of columns in each zone may be checked from the literature of manual for the given computer.C.) Control Program 10 20 30 LET S =1175.3 Print Using Statement The PRINT USING statement is included in most versions of microcomputer BASIC.The separation may be comma (. which a numeric field containing a decimal point with not more than two digits on each side. Format String A.4.) 26."SIZE". 26. the items are close to each other. 5 0 R U P E E S Using semicolon in a print statement. This PRINT USING statement can specify both string and numeric data.-15. 26.4. It allows printed output to be formatted. " RUPEES" END The output of the program 1 will be as T O T A L S A L A R Y = 1 1 7 5 . giving the appearance of each data item. REMARK" PRINT 65. The most commonly used are given below: 100 Line number PRINT USING PRINT USING "##.4. Numeric Variables The format string "##. and as a result more items can be printed in one line.50 PRINT "TOTAL SALARY =". There are several different ways to format. ##".B."TEMP".36.) or semicolon (.) Control 100 110 PRINT "NUM".2 The Comma (. What will be the output of the following program? 72 .34 These two lines will be printed as follows 1 Zone 1 NUM 65 17 Zone 2 TEMP -15.S.56.

32 LET B = -5.4. N$ gives output FROG b b (< is for left justified). N$ If N$ ="UNITED" Then the above PRINT USING statement will give output as: UNITED Observe. ##".32 -5. there are six alphabets and we have used six exclamation sign (!).A. Each exclamation sign (!) is used to represent each character of a string. Example If N$ = "FROG" then (a) 100 PRINT USING "!!!!". Space characters (b b ) are used to fill left space.C. Syntax: 73 .38 LET C =40 PRINT USING "##. Note: Some computers use # for presenting a character. Note: b is used as space character.00 If string values are used instead of numeric values. END OUTPUT 17.">" sign gives characters b b in the left side as the PRINT USING with > gives right justified.N$ gives output as bbFROG (b) 100 PRINT USING ">!!!!!!".N$ gives output as (> character is used for the right justification of a string. 26.10 20 30 40 50 LET A =17. the format string for PRINT USING will be as follows: 100 PRINT USING "!!!!!!" . TAB (n) moves the printer head to the nth column and printout of any data starts from that column.) Since "!!!!!!" has six character representations and FROG has only four characters. With the same explanation 100 PRINT USING “<!!!!!!”. The use of a COMMA and a SEMICOLON to space out the output is not so flexible as the TAB function. Left justified space filled to right.38 40.B.4 TAB FUNCTION The TAB (abbreviation of TABULATION) function is a very important function because it enables the user to exercise exact control over the print positions.

the printer head moves to the Nth column and printing of the value of X starts from that column (b) In case N is a variable. For example. producing tables and to plot graphs etc. TAB (10). The other few BASIC statements and their explanations are given in this section. "DINESH". "RAJESH" Consider another example. so TAB (20) is ignored and the output is same as if TAB (20) was not present. (in Lesson 1).DATA etc in this Lesson itself. TAB(20).3". 5 X = 12 10 K = 5. not having the internal value.5 We PROGRAM CONTROL STATEMENTS # # THEIR SYNTAX AND USE have already seen a few BASIC statement like REM. it is rounded and the printer head moves according to this value. a variable or an expression having positive value and X shows output data The execution of TAB function is explained below:(a) If N is an integer. We will discuss them in details using different program. The use of TAB function is an elegant method to prepare patterns. "15. where TAB function is ignored 20 PRINT "10. Then TAB (20) instructs the computer to write RAJESH from column 20. For example.3 20 PRINT TAB(k) . The above statement is equivalent to 10 PRINT TAB (25).6 will be printer from column 16 onwards. consider the statement 10 PRINT TAB (25). if N is an expression then first of all. if necessary. X (c) On the other hand. 26. "DINESH". Since the printer head is already beyond the column 20 and backward movement is not allowed.READ. 74 .and LET.INPUT. The value 15. the expression is evaluated and rounded. The backward movement of the printer head is not allowed.Line number PRINT TAB (N). The printer head move based on the value of this expression. X Where N is a positive number.6" The comma preceding the function TAB (10) Positions the printer head to the column 16 so that the function TAB (10) becomes redundant as printer head cannot move backward and hence it is ignored. "RAJESH" Here TAB (25) instructs the computer to start printing DINESH from column number 25 onwards.

1 Unconditional Go To Statement GOTO statement is used to transfer control from a statement. S2 does not follow S1 immediately in sequence.50 then our program will add few more jump statements. few more GO TO statements. Y LET X =A*X LET Y =B*Y PRINT X. Y =B*Y then prints X.40.3.B. say S1 to another statement.B. Syntax: Line number GO TO n n is the line number of the statement where control will be transferred.Y GO TO 30 DATA 6.X. say S2.Y.Y GO TO 60 LET X = X*X+A LET =Y*Y +B PRINT X.3.e. in line number 10.X.26.5 END This shows after reading the values of A. i.50 are never executed.Y in line number 80 and ends the program.4.5. Program 1 10 20 30 40 50 60 70 80 90 100 READ A. Program 2 10 20 30 40 50 55 60 70 80 85 90 READ A. Consider the following program 2.40.X. generally. the control jumps to line number 60 and calculate X =A*X. Line number 30.Y GO TO 60 LET X =X*X+A LET Y =Y*Y+B PRINT X.5 75 . If we want to execute 30.Y GO TO 100 LET X =A*X LET Y =B*Y PRINT X.Y DATA 6.4.B.

. 2. (b) READ statement cannot be used without a . 26. THEN The IF.THEN is a decision making statement. State the difference between READ and INPUT statement? 3..2.. the value of a variable on the ... hand side of the equal to sign..5...... depending upon the decision... statement........ EXAMPLE 2 Evaluate the expression Y =X2 for X =1. What is the use of RESTORE statement? 5..THEN statement will be executed... Program 1 10 20 30 LET X = 1 LET Y = X*X PRINT Y 76 . If the relation expression is true then n will be executed otherwise the statement following this IF..... Y =Y*Y+B (value) and line number 80 prints X = A*X and Y =B*Y IN-TEXT QUESTION1 1. Define briefly the use of TAB function. So line number 30 and 40 prints X =X*X +A (value). it can change the order of execution..100 END Thus by introducing line number 55 and 85 all the statements are executed....2 The Branching Statement IF.. Fill in the blanks (a) In the LET statement. but must be before the ... It helps the computer to check whether a relation is TRUE or FALSE. (c) DATA statement can occur anywhere in the program... Syntax: Line number IF (relational expression) THEN n where n is a line number or an instruction itself..3.... statement.. hand side of the equal to sign is assigned to the variable given in the ..... What is the use of PRINT USING statement? 4.

Computer goes round and round and never reaches END To stop the infinite loop we can add a condition. say if X is greater than or equal to 31 (X >=31) then the program ends otherwise it keeps on printing the value of expression Y = X 2 for X =1. Program 2 10 20 30 40 50 60 70 LET X = 1 LET Y = X*X PRINT Y LET X = X+1 IF X> = 31 THEN 70 GO TO 20 END Thus we see that IF-THEN is one of the powerful statements which can stop or get the computer out of an infinite loop.75 PRINT CHARGE END Here in line number 20. i. Thus we have an infinite loop which is never ending.40 50 60 LET X = X+1 GO TO 20 END In this process we see each time the line number 50 is executed the control is transferred to line number 20 unconditionally.00. Program 1 10 20 30 40 50 INPUT "KILOMETER"...3” : END LET CHARGE =3+ (K-2) *. The minimum fare charged is Rs. After 2 kms.3. EXAMPLE 3 Problem 1 Write a program to find out the auto fare depending on the Kilometers traveled.e.2.30. K IF K < = 2 THEN PRINT "RS.. 3 and (: END) 77 . the charges are 75 rp per kilometer. This minimum fare remains for 2 kms or less of travel.. if K is less than or equal to 2 (i. K<=2) then it will print Rs. 3.e.

A IF A>= 17 THEN 30 ELSE 50 PRINT “WELCOME FOR BOARD EXAMINATION” GO TO 60 PRINT “YOU ARE NOT ELIGIBLE FOR BOARD EXAM. Y$ IF Y$ = “Y” THEN 10 END The line number 10 will cause the message in screen AGE? We input the age through the keyboard.. say 18. Otherwise if K is not less than or equal to 2 then line number 30. It helps in making comparisons and testing whether a condition is true or not. 26.. IF is always followed by a valid BASIC condition or expression. In line number 70 if input is Y then control goes to line number 10. Otherwise if input is N then 78 ..ELSE statement is a decision making statement as it decides the path of the program..ELSE.3 The Branching Statement IF.40 then 50 will be executed.. We are asked to write a program for this problem..” INPUT “WANT TO INPUT AGAIN (Y/N)”. Since A=18>17 line number 30 is executed. Program 1 10 20 30 40 50 60 70 80 INPUT “AGE”.ELSE Another important statement is IF .. Syntax: Line number IF (condition or relational expression) THEN (line number or Instruction) ELSE (line number or Instruction) The IF..THEN. in continuation to the line number 20 next statement is END.5.THEN. Line number 20 tests whether A>17 or not..THEN. Line number 30 prints WELCOME FOR BOARD Line number 40 causes the control to pass to line number 60. EXAMPLE 4 Problem 1 Ages of different students appearing in the Board examination are taken.means END... If the condition is found true then the line number or Instruction after THEN is performed otherwise line number or instruction after ELSE is performed. Line number 60 causes the message WANT TO INPUT AGAIN (Y/N)? We input either Y or N. otherwise he can appear in the Board examination.. If the age is below 17 the student is not eligible.

we give another age. Problem 2 10 20 30 40 50 60 70 80 90 100 INPUT A. the line number 50 will print A is THE LARGEST VALUE and then GO TO 80 will be executed as the next statement to line number 50. In this way a large number of students age can be tested.30.e.e. If expression at 20 is found true.40 comparisons are made among the values of A. END. If both the relational expression preceding and following AND are true then the line number following THEN will be executed otherwise if one of the relational expression. If it is found false the control passes to statement 30 and the expression at that statement is checked. Line number 50 will print YOU ARE NOT ELIGIBLE FOR BOARD EXAM. When we want to stop we should input N in line 60 for Y$. A>B or A>C is true then the line number following ELSE will be executed. Then line number 60 as before will be executed.B. This part of the program can also be written as follows: 50 55 60 65 PRINT "A IS THE LARGEST NUMBER" GO TO 80 PRINT "B IS THE LARGEST NUMBER" GO TO 80 79 . AND is a logical operator which combines A>B and A>C.control goes to the line number 80 i. and C. Same procedure follows for the next two IF statements also.B. 13) is not greater than 17.C IF A>B AND A>C THEN 50 ELSE 30 IF B>A AND B>C THEN 60 ELSE 40 IF C>A AND C>B THEN 70 PRINT "A IS THE LARGEST NUMBER": GO TO 80 PRINT "B IS THE LARGEST NUMBER": GO TO 80 PRINT "C IS THE LARGEST NUMBER" INPUT "WANT TO INPUT AGAIN (Y/N)" . Y$ IF Y$ = "Y" THEN 10 END In line number 20. Now if in line number 70 we input Y then control will pass again line number 10. therefore ELSE part will be executed and control will go to line number 50. say 13 In line number 20 value of A (i.

ELSE with OR is: IF (Condition 1 or Relational expression) OR (condition 2 or Relational expression) THEN (Instruction 1) ELSE (Instruction 2) This means if either of the conditions (or relational expression) followed or preceded by OR is true then the instruction 1 is executed..THEN. M and N are numeric constants where M gives the initial or starting value of the loop and N gives the final value.. THEN. Thus one loop can be started with FOR-TO and ended with NEXT.NEXT We have already seen that a loop can be built in BASIC by using the IF-THEN and GOTO statements. 26.J can be numeric variable names.. Syntax: for IF…..55.Thus line number 50 and 60 in earlier program of problem 2 is equivalent to line numbers 50. When it is known in advance how many times the loop must be repeated the statement FORTO.... M.4 The Looping Statement FOR-TO. J followed by keyboard STEP gives the increment in M till N is reached. The increment can be negative also..60. IF (Condition 1 or Relational expression) AND (Condition 2 or Relational expression) THEN (Instruction 1) ELSE (Instruction 2) Like AND another logical operator is OR.N.5.NEXT is the most effective statement. A loop is built up by FOR-TO and ended by NEXT.e. In such cases their numeric values should be assigned before the starting of the loop. Syntax: For IF.ELSE with AND is given as. They key word NEXT should have the same control variable I followed by it. Syntax: Line number FOR I = M TO N STEP J Loop - Line number NEXT I The numeric variable name following FOR is called the control variable or loop variable.. before coming to FOR-TO statement.. i. 80 . If neither of them is true then instruction 2 is executed.65 in the above program statement.

NEXT loop.Inside one FOR-TO . Now the value of S becomes 4 and once again the inner loop is executed 4 times resulting in printing of 4 (*) stars in second row.. NEXT X PRINT NEXT S END This program contains two loops: the outer loop is from the line number 10 to 60 and inner loop from line numbers 20 to 40.3.NEXT is inside another FOR-TO. But once a FORTO. it should remain completely inside the former loop... After that it will come to end.NEXT loop there can be more FOR-TO... This process will continue till the value of S becomes 1.. the increment is assumed to be 1.4_ _ _ _ 100. EXAMPLE 5 Problem 1 Suppose we want to print the output in the following format: ***** **** *** ** * Program 1 10 20 30 40 50 60 70 FOR S=5 TO 1 STEP-1 FOR X=1 TO S PRINT "*" .NEXT loops are called Nested loops. the control goes back to line number 10. Problem 2 Suppose we want to sum to following series: 1. initially S is assigned a value 5. 81 . The statement at line number 50 will transfer the printer control to the beginning of the next line. In line number 10.. Since the value of S is greater than 1. control is transferred to line number 20.. When line 60 is encountered.NEXT. which causes the inner loop to execute 5 times resulting into printing of 5 stars (*) in one row...2. Such FOR-TO. In the absence of the STEP clause.

if 3 then n3 and so on.. N ON N GOTO 30..60 PRINT A+B : END PRINT A-B : END PRINT A*B : END 82 .. are the statement numbers or line number where the control will be transferred..GOTO can have more than two transfer points. divide and multiply two numbers A and B.. subtract.n3. Program 5 10 20 30 40 50 INPUT A. 4-DIV". Syntax: line number ON (Numeric variable or expression) GOTO n1. If the integer value is less than or more than number of line numbers present in the list then an "OUT OF RANGE" error message will be given by the computer.n2..5 The Multiple Branching Statement ON... thus providing multiple branching facility. 3-MUL..n2.THEN allows two transfer points. If ON is followed by numeric variable name and if the value of numeric variable is 1 control is transferred to n1.5. GOTO The GOTO statement allows only one transfer point.50..Program 2 10 20 30 40 50 60 LET S=0 FOR I=1 TO 100 LET S=S+I NEXT I PRINT " SUM OF SERIES =" . If ON is followed by an expression by an expression then it is evaluated and truncated to an integer value...40. EXAMPLE 6 Problem Write a program to add. Control is transferred in the same manner as discussed above.B INPUT " 1-ADD. S END 26. The expression is a valid BASIC expression and n1. IF. 2-SUB..n3. if 2 then n2. the ON.

write the values taken by the control variable (a) 10 (b) 20 (c) 30 (d) 40 (e) 50 FOR FOR FOR FOR FOR L= M= N= K= I= 3 TO 12 1 TO 50 100 TO 0 5 TO 5 10 TO 6 STEP -1 STEP 2 STEP 10 STEP -20 3.N will take 2 or 3 or 4 accordingly. In the following FOR statements. control is transferred to 50. multiplication and division will be displayed respectively. 2-SUB. in line number 40. control is transferred to 40.2 to the variable A (b) To assign the string PENTIUM-SYSTEM TO the variable B$ (c) To assign the value of the variable C to the variable D (d) To increase the value of the variable E by 1 (e) To assign the value equal to three times the value of the variable P to the variable Q 2. "GOEL" 83 .60 PRINT A/B : END When line 5 is executed.60 printing of the result of subtraction. Write a LET statement for each of the following: (a) To assign the value 5. there will be question mark (?) then you have to input the values of A and B through keyboard. control is transferred to 60 On execution of line number 30 addition of A and B will be displayed on the screen and program will come to an end. If we input through keyboard 1 then N takes the value 1. Similarly. IN-TEXT QUESTIONS 2 1. Line number 10 will cause a message on the screen 1-ADD.50. 4DIV and then display of question mark (?) for N. "GOEL" PRINT "PANKAJ" . If the value of N is 1 2 3 4 control is transferred to 30. 3-MUL.If we enter 2 or 3 or 4. 10 20 Give the output of the following short program PRINT "PANKAJ" .

.. The example programs given in this lesson should be run on a computer so that the concept is clear before going to the next lesson. D END 26.. 26. Left DATA END 2. THEN statement and an IF. What does an unconditional GOTO statement do? 2. 3. (a) (b) (c) Right. ELSE statement? 3. data is read from the keyboard at the time of execution of the program.. What is the difference between an IF. A “B = B”. THEN. 26. Print using statement allows printed output to be formatted corresponding to the given specification. “D=”.... In READ statement.7 TERMINAL QUESTION 1. B “C=”. Write a program in BASIC using For-Next loop to get the following output: 1 2 3 4 **** ********** ***** ** 5 ******* 5. Give the output of the following short program 10 20 30 40 50 60 LET LET LET LET A = 40 B = 50 C = 60 D = A+B+C PRINT “A= A”. which are very essential for writing small programs in BASIC. 84 .8 Write a program in BASIC to print out the largest number out of 10 given numbers. "GOEL" 4.6 WHAT YOU HAVE LEARNT This lesson gives us the introductory features of BASIC language. data is provided in the program itself through a DATA statement. How is the multiple branching facility provided in BASIC? 4. Some additional statements and functions of BASIC will be discussed in Lesson 4. C.30 PRINT "PANKAJ". In case of an INPUT statement. FEEDBACK TO IN-TEXT QUESTION IN-TEXT QUESTIONS 1 1.

21.7.40.80. sub-programs and some of the functions of BASIC.31. subroutine and various functions provided to help the programmer. 27. (c) Values taken by N are : 100. 5.6.2 (b) 20 LET B$="PENTIUM-SYSTEM" (c) 30 LET D = C (d) 40 LET E = E+1 (f) 50 LET Q =3*P 3 (a) Values taken by L are : 3. TAB function enables the user to exercise exact control over the print positions. We have also included various sample programs. regardless of the current position of the pointer. PANKAJ GOEL PANKAJ GOEL PANKAJ GOEL 5.9. A= 40 B= 50 C= 60 D =150 LESSON 27 HANDLING OF ARRAYS.11.4.20.11 (b) Values taken by M are : 1. you have gone through the programming technique and various INPUT/OUTPUT and control statements in BASIC.0 (d) Value taken by K is : 5 (e) Values taken by I are : 10.8. 4.5. We shall be discussing all these features in this lesson. which will help you further in writing more complex programs in BASIC language.9.1 INTRODUCTION In the previous lesson.7.2 OBJECTIVES This lesson will explain you about handling of lists. FUNCTIONS AND SUB-ROUTINE 27.41. 60. IN-TEXT QUESTIONS 2 1. But the features that make this programming language more useful are use of subscripted variables. The restore statement brings the pointer to the first value of the DATA statement. (a) 10 LET A = 5. subroutine. tables. At the end of this lesson. you should be able to: 85 .

We will discuss onedimensional arrays (lists) and two-dimensional arrays (tables).91.3 HANDLING LISTS AND TABLES (ARRAYS) IN BASIC In all our programs so far.12. In the memory it is stored as. we will discuss the concept of an array: a collection of variables. Each item of data in an array does not have a unique variable name.use functions and subroutines in BASIC language write complex programs in BASIC language learn how to set up and use arrays in BASIC programs 27. a single variable (one storage location in internal memory) has been associated with each variable name.) which represent the marks of five students Solution: We can use an array name M(I) which is also called the subscripted variable and I is the subscript which varies from 1 to 5. all of which are referenced by the same name. In this lesson. 86 . The smallest component of an array is called an element of the array.12.7 END Let us go back to the above example.42. M(I) Cells Quantities M(1) M(2) M(3) M(4) M(5) 10 12 42 91 7 Problem1: Write a program to read the above data into the memory. concentrating on the former.7.42.91. on the other hand. Program 1 10 20 30 40 50 60 DIM M(5) FOR I = 1 TO 5 READ M(I) NEXT I DATA 10. Example 1: suppose we want to represent five numbers (10. M is the name of array and M(1) is an element of the array M. a group of similar data is given one name.

38. Solution Since they are similar items.91. If we want to know the price for the biscuit of type 4. So the array is now BIS(I). price we have a single subscript.e. 52. 45.6 87 . BIS(1).e. Since we know only one specification i.53. Since there are 10 prices for 10 types of biscuits I varies from 1 to 10 i. We will do it by using an array. Program 2 10 20 30 \40 50 60 70 80 90 100 110 120 130 DIM BIS(10) REM PRICES FOR 10 TYPES OF BISCUITS ARE TO BE READ REM THE 10 PRICES HAS TO BE PRINTED ALSO FOR I = 1 TO 10 READ BIS(I) NEXT I PRINT “THE PRICES OF TEN DIFFERENT BISCUITS” FOR I =1 TO10 PRINT BIS(I) NEXT I DATA 60.75 DATA 29. 32. This M(I).M(2).5.45. 19.6.BIS(10). 38. is an example of a one-dimensional array.75. where under the array name M the five different elements M(1).M is an array of 5 numbers 10. 32. Let us study a practical example of one-dimensional array. we give them a single name BISCUIT or in short BIS.5 32. 29. M(5). M(4).5. BIS(2)…….5. 52.7.6.12. 49.5. Example 2: We have an item biscuit in a shop.49. are given one subscript I. 43. We have prices for 10 different biscuits as 60.53. 19.42. We write a program to print these different values or we want to know the price of any type of the above biscuits.6. we will print BIS(4) which will give us the required price.43. with a single subscript I.6 END OUTPUT Line number 70 will print THE PRICES OF TEN DIFFERENT BISCUITS Line number 90 due to line number 80 and 100 will print 60 45. M(3). say I.

ENCLOSED BETWEEN QUOTATION MARKS REM. If we want an array of strings instead of numeric value.40.5 52 49 53.90.e. the data should be in the order they are placed.. “MARUTI”.. “AMBASSADOR” DATA “FIAT”.. Though DATA is given in two lines 120 to 130. ARRAY NAME TO STORE STRINGS IS REM.100. This informs the machine that we are giving an array with single subscript having 10 elements. explains the program.75 29 43 38.110.80. 88 . GIVEN AN STRING VARIABLE NAME C$ DATA “FORD”. see the following example: Example 3 To store the names of six motor cars in any array (table) such as: FORD MARUTI AMBASSADOR FIAT STANDARD VAUXHAL L We can write a program as follows: Program 3 10 20 30 40 50 60 70 80 90 100 110 120 130 140 REM DECLARE THE NAME AND SIZE OF THE TABLE DIM C$(6) REM… USE THE READ/DATA TECHNIQUE REM TO STORE STRINGS FOR J = 1TO 6 READ C$(J) NEXT J REM.6 The line number 10 DIM BIS(10) is compulsory. “STANDARD”. remarks) given in the line number 30. NOTE THE STRINGS USED AS DATA ARE REM.. So.19. 10 cells in the memory location will be kept for the variable name BIS. “VAUXHALL” END The REM (i.

-6. By using this statement in line number 10 of the program 1 above. -6. 2.3. 0. -2. certain information about them must be supplied to the computer before it is used.7. -1.9 WE give this set of values the name.1. The program for adding all the 10 numbers.C$(1) = “FORD” C$(2) = “MARUTI” C$(3) = “AMBASSADOR” C$(4) = “FIAT” C$(5) = “STANDARD” C$(6) = “VAUXHAULL” Example 4 Let the 10 data values are given as 4. 0.3.1 The DIM Statement When subscripted variables are used in a program. .3.9 PRINT SUM END 27.2. -6. These are: (a) (b) Which variables are subscripted? What is the maximum size for each subscript? DIM is the short form of DIMENSION. then VAR (1) has the value 4 I = 5. Syntax for the DIM statement is 89 . Program 4 10 12 15 20 30 40 50 60 70 80 REM ADDING 10 NUMBERS IN A ONE DIMENSIONAL TABLE DIM VAR (10) LET SUM = 0 FOR I = 1 TO 10 READ VAR (I) LET SUM = SUM +VAR (I) NEXT I DATA 4.3. . 3 -1. 5.7. and so on.1 I = 8 then VAR (8) has the value 0.7. then VAR (5) has the value -6. 2. the array whose name is M has been allotted 5 cells in the memory location. 7. say VAR (I) where I is the subscript. If I = 1. 5.1.6.

e.e.80. If we write 10 DIM A(100). when line number 70 is executed AVERAGE = 313/5 =62. Now print the roll number and average marks secured by him.e. control then goes to line number 60 and back to 30.49. TOT = 60+52 = 112 and so on. If we want to do this process for a large number of students say 10 we have to give more data in DATA statement. i.e. i. Problem 5 Suppose we want to read the roll number of a student and his marks obtained in five subjects in the board examination. So line number 30 to 60 is executed five times. i. that is 60 and adds to the variable TOT which is initially zero. then 100 locations are reserved for the array name A and 10 locations for the array name X.6. DIM should be the first statement in the program barring REM statement. i. 52.e. AVERAGE DATA 60. Line number 80 will print the ROLLNO which is entered in line number 20 and the average AVERAGE as 62. 45 more data values and put another loop to repeat the process for ten students. the first mark from line number 90. 2nd marks from DATA.Line number DIM array name (unsigned integer) The unsigned integer specifies the size of the array variable. X(10). In line number 50 TOT = 60 + M(2). Now I becomes 2 and line number 40 reads M(2). So for I = 1 line 50 gives TOT = 0 +60 = 60. Program 5 10 20 25 30 40 50 60 70 80 90 100 DIM M(5) INPUT ROLLNO LET TOT = 0 FOR I = 1 TO 5 READ M(I) LET TOT = TOT + M(I) NEXT I LET AVERAGE = TOT/5 PRINT ROLLNO. i. initially the control variable I becomes 1 and line number 40 reads M(I).72 END On the execution of line number 30.6.52. Program 5(a) 90 . Thus finally in the variable name TOT we have TOT = 60+52+49+80+72=313. So.

75 DATA 88.80.72. (a) The accumulator is the variable ___________ (b) The control variable is _______________ 91 .48.52.60.61.10 15 20 25 30 40 50 60 70 80 85 90 100 110 120 130 140 DIM M (5) FOR J = 1 TO 10 INPUT ROLLNO LET TOT =0 FOR I = 1 TO 5 READ M (I) LET TOT = TOT + M(I) NEXT I LET AVERAGE = TOT/5 PRINT ROLLNO.81.98.49.80.69. AVERAGE NEXT J DATA 60.54.72.86.52.92. Given the following code: 10 20 30 40 50 LET S =0 FOR I = 1 TO N STEP 2 LET S = S+2*I-1 NEXT I END You are required to complete each statement.65 DATA _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ DATA _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ DATA _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ END IN-TEXT QUESTIONS 1 1.

which has rows and columns both in it. S contains the sum of the first N _________ Integers.(c) After execution.2 Double-Subscripts or two-dimensional arrays A subscripted variable name in BASIC can have up to three subscripts. Where.3.J) where I indicates row and J indicates column.. The use of two subscripts has very wide applications. especially manipulation of tables or any such things. NEXT I PRINT I END (b) 10 20 30 40 50 FOR I = 1TO 10 IF I = 5 THEN 40 PRINT I + 1 NEXT I END 27. TABLE (I. 2.J) = 2 4 1 8 3 10 5 7 92 . What is the output of each of the following program segments? (a) 10 20 30 40 50 FOR I = 7 TO 10 STEP 2 PRINT I. Correct the errors in each of the following program segments: (a) 10 20 30 40 50 FOR K = 1 TO 5 FOR J = 1 TO K PRINT K + J NEXT K NEXT J (b) 10 20 30 40 50 LET S = 0 FOR I = 1 TO 10 LET S = S + I PRINT S NEXT K 3. Example: Represent subscripted variable or two-dimensional array having name TABLE(I.

3) TABLE(3.2) TABLE(1.10.2) TABLE(3. If we want to read the data column-wise program will be as follows.4) FOR I = 1 TO 3 FOR J = 1 TO 4 READ TABLE (I.3) TABLE(2.1) TABLE(1.8.1) TABLE(3.17.4) FOR J =1 TO 4 FOR I =1 TO 3 93 .J) as given above Program 6 10 15 20 30 35 40 50 70 80 DIM TABLE (3. i.5.J) PRINT TABLE (I. I = 1 TO 3 and 4 columns.J) NEXT J NEXT I DATA 2.3) TABLE(1.1) TABLE(2. the table is read row-wise. i.4) 1 ---------> 3 --------> 5 ----------> 7 TABLE(3.3 7 13 17 Thus we see TABLE (I. Problem 6 We want to read and print the values of TABLE (I.3.4) 2 ---------> 4 --------> 8 ----------> 10 TABLE(2.7.e. J being in the inner loop changes more frequently from 1 to 4 for every value of I.J) has 3 rows.1.7.3.2) TABLE(2. J = 1 TO 4. Program 7 10 20 30 DIM TABLE (3.e.4) 3 ---------> 7 --------> 13 ----------> 17 As the subscript J corresponding to the column is in the inner FOR loop. which is in the outer loop.4.13. END See how it reads the data TABLE(1.

3. 10. 17 END More applications relating to subscripted variables will be shown in the last section. Now. "DINESH" "RAJESH" DATA "PANKAJ". 7. 13. SHOWN IN DIAGRAM READ N$ (M.. You will see how string data is stored in a two-dimensional array. 5. 8. 4. 7. Example The following are data values (names). We have shown you to store numeric data in a table (array) with row and column subscripts.. which are to be stored in the table form with rows and columns. J) NEXT I NEXT J DATA 2. P) NEXT P NEXT M DATA "HARIOM"..40 50 60 70 80 READ TABLE (I. 3. USE A READ/DATA STATEMENT TO STORE DATA AS REM .4) REM SET UP AN OUTER LOOP TO CONTROL THE ROW SUBSCRIPT FOR M = 1 TO 2 REM…. "BIMLA" 94 .SET UP AN INNER LOOP TO CONTROL THE COLUMN SUBSCRIPT FOR P = 1 TO 4 REM . 1. HARIOM BIMLA DINESH UPMA RAJESH SANJU PANKAJ ANAMIKA The program is as follows: Program 7 10 20 30 40 50 60 70 80 90 100 110 120 130 REM DECLARE THE NAME AND SIZE OF THE TABLE DIM N$ (2.

1) ? (b) Which elements of FAX contain the numbers 30 and 20 ? 3. Write a BASIC program to arrange the following numbers in an ascending order: -71. Determine whether each of the following statements is true or false. A two-dimensional array FAX has two rows and four columns 5 25 10 30 15 35 20 40 (a) What are the values of FAX (1. (c) One and two-dimensional arrays cannot be declared in the same DIM statement.J) = I+J+1 NEXT J NEXT I PRINT A(1. 14. "ANAMIKA" END IN-TEXT QUESTIONS 2 1. 5 95 . What is displayed when the following program segment is executed? 10 20 30 40 50 60 70 80 DIM A (2. A(2. 0. (b) All elements of an array must be of either string type or numeric type. -20.2) END 4 Write a BASIC program that determines and prints the smallest and largest elements of a twodimensional array columns. "SANJU". (a) Array of string data and array of numeric data can be declared in the same DIM statement. A(2.3) FOR I = 1 TO 2 FOR J = 1TO3 LET A(I.2).140 150 DATA "UPMA". (assuming that it.3) and FAX (2.1). has been already inputted) with four rows and five 5. 2.

for the expression y(x) =ax2 + bx + c Program 1 10 20 30 40 50 60 DEF FNY (X) = A*X*X + B*X + C INPUT A. B. which appears as a variable in the expression on the right. The value of x is supplied in line number 30 and values of A. say for x = 1. If the calculation can be defined by a single statement then we use the function statement DEF FN. FNY(X) NEXT X END On execution of the program line number 30 TO 50 will give the value of y(1) through y(5) for the respective value of x.4. Problem 2 Let us consider the program to calculate y = 1.3.5. C FOR X = 1 TO 5 PRINT X. which are similar to the Library functions. It may so happen that a particular calculation or a set of calculations occurs more than once in the program.5x + 3 for x<= 2 y = 2x + 5 for x>2 Program 2 100 105 110 120 130 DEF FNY(X) INPUT X IF X < = 2 THEN 140 LET FNY = 2*X + 5 GO TO 150 96 . the programmer would like to write his or her own functions.1 Defining a function---the DEF statement To avoid repeated programming of the same set of calculations. Problem 1 Suppose we want to write a program to calculate y for various values of x.4 FUNCTION AND SUBROUTINE 27. calculated at line number 10. Syntax: line number DEF FNV (a) = expression Where “V” is the one-letter name of the function and "a" is the argument. B and C are input at line 20.4.27.2.

Then line number 35 will bring the program to END.V.V.5*X + 3 FNEND PRINT X. The DEF statement must have DEF FN and variable name with one character and arguments included in the parenthesis. you enter O for U.V.V. which must appear in the right side after the equal to (=) sign.Y) =(U/V + X/Y)/2 INPUT U. Now the program given below will evaluate the formula for different set of values for U.X.Y. you can enter another set of values for U. Now.X.Y) = (U/V + X/Y)/2 INPUT U.X.V. Solution 10 20 30 40 DEF FNZ(U.V. The FNEND statement in line number 150 indicates the end of the function. v.X.V.Y PRINT FNZ(U.X.Y) IF U = O THEN 50 GO TO 20 END Line number 40 sends the control back to INPUT. On execution of line 170 a call to the function FNY(X) is made causing the execution of line number 100 to 150 with the input value of X.Y 10 20 30 35 40 50 DEF FNZ (U. Arguments can be more than one also.X.140 150 170 180 LET FNY = 1. x.Y) END This is for one set of values for U.Y PRINT FNZ(U. The argument is a variable. Example 2 97 .V.X.X. (For example. When you want to stop.Y. FNY(X) END Here DEF FNY (X) statement in line number 100 is used without being equated to expression. see problem 1) Example 1 Evaluate the algebraic formula z =(u/v + x/y)/2 for different set of values of u.X.V. in case of DEF FN statement is equated to an expression. The line numbers 160 to 180 consist the main program. y.

In the main program the subroutines are called at different places using GOSUB statement. RETURN statement Syntax: line number RETURN The RETURN statement in the subroutine transfers the control back to the main program to the line immediately following the corresponding GOSUB statement.Define a function for subprogram for the algebraic formula p = log(t2 -a) for t2 > a log(t2) for t2 = < a Solution 30 40 50 60 70 80 90 100 110 DEF FNP(T.A IF T * T < = A THEN 80 LET FNP =LOG (T ^ 2 -A) GO TO 90 LET FNP = LOG (T ^ 2) FNEND PRINT T. Subroutines are placed at the end of the main programs in order to repeat a process. GOSUB Statement Syntax: line number GOSUB n Where n is the line number of the 1st statement in the subroutine. A FNP (T. 98 . 27.A) END In line number 40. which requires to be repeated very frequently in the program.4. A subroutine consists of set of program statements that may be used repeatedly at different places throughout the main program. Note: Please consult the machine manual for DEFFN statement before running the programs in the machine. The program control has to exit from the main program to enter a subroutine and after the process is completed it comes back to the main program using RETURN statement. RETURN is the last statement in the subroutine.A can be input by READ/DATA or by using LET statements twice.A) INPUT T. the values of T.2 Defining a subroutine -The GOSUB and RETURN statements A subroutine is a collection of statements belonging to a process.

GOSUB unconditionally transfers the program from the main to the subroutine. B INPUT "CHOICE". C$ IF C$ = "ADD" THEN GOSUB 80 : GOTO 65 IF C$ = "SUB" THEN GOSUB 120 : GOTO 65 IF C$ = "MUL" THEN GOSUB 170 : GOTO 65 IF C$ = "DIV" THEN GOSUB 210 PRINT C END REM "SUBROUTINE FOR ADDITION" LET C = A + B RETURN REM "SUBROUTINE FOR SUBTRACTION" LET C =A-B RETURN REM "SUBROUTINE FOR MULTIPLICATION" LET C = A*B RETURN REM "SUBROUTINE FOR DIVISION" LET C = A/B RETURN 99 . Properties of GOSUB One subroutine can follow another subroutine but each subroutine should be complete within itself. Problem 1 Write a program to add. GOSUB can also transfer the program conditionally by using it with IF-THEN ELSE Syntax: Line number IF (Logical expression) THEN COSUB (line number) ELSE GOSUB (line number) A subroutine can be called by the main program a number of times. subtract.GOSUB and RETURN are always used together in the program not independently. 10 20 30 40 50 60 65 70 80 90 91 120 130 150 170 180 200 210 220 240 INPUT A. But the returning point will be different in each time. GOSUB takes the control from the main program to the subroutine and return brings back the control from the subroutine to the main program. multiply and divide any two numbers.

4-DIV".3…. B INPUT "CHOICE" C$ IF C$ = "ADD" THEN GOSUB 50 END PRINT A+B RETURN So whatever will be the input of C$ in line number 20.) Program 2 10 20 30 40 50 60 70 80 INPUT A. GOSUB will go to these subroutines as it is written for C$ = "ADD" similar subroutines will follow for "SUB". 60. 2.B INPUT "1-ADD. Syntax is given as: Line no ON Numeric variable Or Numeric expression GOSUB (Line number of sub-routine 1. 70. "MUL". 80 END (To make the program repeat we should add GOTO 10) PRINT A+B : RETURN PRINT A-B : RETURN PRINT A*B : RETURN PRINT A/B : RETURN Note: To make the program repeat. 3-MUL. N ON N GOSUB 50. sub. 2-SUB. "DIV" ON GOSUB statement is similar to ON GOTO. we should add GOTO 10 at line 35 IN-TEXT QUESTIONS 3 100 .Short form of Problem 1 for addition 10 20 30 40 50 60 INPUT A. sub .

MID$ 27.1 INT Functions It takes a numeric value as its argument and returns its value after truncating the decimal part.5. STR$. MOD.2) X= 15. LOCATE.6 Y= INT(X) Statement 10 will return Y = 13 and Statement 30 will return Y = 15. 101 . For example. (a) What is a subscripted variable? (b) What is the function of a DIM statement? (c) Define a subroutine? (d) What does a RETURN statement do? 2. LEN.5 EXAMPLES AND PROGRAMS SHOWING USAGE OF SOME BASIC FUNCTIONS: INT. 10 20 30 Y= INT(13. What is displayed when each of the following program segments is run? (a) 10 20 30 40 400 410 500 510 GOSUB GOSUB PRINT "ONE" END PRINT "TWO" RETURN PRINT "THREE" RETURN 400 500 (b) 10 20 30 40 50 DEF FNA (W) = 2*W+1 PRINT FNA (2) LET x = 3 PRINT SQR (FNA (x+1)) END 27. RND. VAL. The value returned is always smaller than the number provided as the argument.1. RIGHT$.

25.B LET C = A/B IF INT(C)= C THEN PRINT “ HIGHER NUMBER=“. Thus line number 80 gives Y1=Y2 and so the control is transferred to 110. A END This shows the use of the INT function. To find the higher number between them: Program 1 10 20 30 40 50 INPUT "HIGHER NO". 27. A INPUT "SMALLER NO ". Program 2 10 15 20 30 50 60 70 80 90 100 110 120 REM ** PROGRAM TO FIND WHETHER THE YEAR IS A LEAP YEAR OR REM NOT ** PRINT "ENTER THE YEAR" PRINT INPUT YEAR LET Y1 =INT(YEAR/4) LET Y2 =YEAR/4 IF Y1 =Y2 THEN 110 PRINT YEAR "IS NOT A LEAP YEAR" GO TO 120 PRINT YEAR. Thus in line number 80 Y1 is not equal to Y2. we compute Y1 as 497. (B) Suppose we input year as 1989. we compute Y1 as 497 and also line number 70 gives Y2 as 497. therefore control passes to 90. then line number 60. In line number 70. Example 2 Write a program to find whether any year of the current century is a leap year or not.2 MOD FUNCTION Program 3 10 20 INPUT C. The line number 60.5. we get Y2 as 497.Example 1 Two numbers A and B are given. D LET X= C MOD D 102 . "IS A LEAP YEAR" END (A) Suppose we input year as 1988.

prints a "*'in the Rth row an Cth column. Example 10 20 30 40 LET C$ = "BEAUTIFUL" LET C = LEN (C$) PRINT C END Output is 9 (as there are 9 characters in the word BEAUTIFUL. in line number 10.20 C is assigned the integer value of RND*80 plus 1 and R is assigned the value RND*25 plus I respectively. Example 10 LET X$= "12345" 103 . 9 MOD 2 will give 1. 27. For example. STR$ function LEN is used to count the number of character in a string. LOCATE function RND generates random numbers between 0 and 1.4 THE LEN. C : PRINT "*" GO TO 10 END RND*80 and RND*25 generates random numbers between 0 to80 and 0 to25 respectively.30 40 PRINT X END The MOD function determines the remainder on dividing a number by another. Program 4 10 20 30 40 50 LET C= INT (RND*80)+1 LET R= INT( RND*25)+1 LOCATE R. It takes a string as an argument and counts every character including a blank.C followed by PRINT "*".5. Thus.3 THE RND. The LOCATE clause followed by R. This string X$ should consist of all digits. Note that the function LEN returns a numeric constant. VAL(X$) function returns a numeric constant equivalent to the value of the number represented by the string X$. VAL. 27.5.

i.20 30 40 LET Y = VAL(X$) PRINT Y END Output of this program.X) returns the rightmost X characters from the string Y$ 104 .5.6) PRINT D$ END Output will be INFORM. 4) END The output will be MATH Example 2 10 20 30 40 LET C$ ="INFORMATICS" LET D$ = LEFTS(C$.Y) Returns the left most Y characters from the string X$ Example 1 10 20 30 LET X$ = "MATHEMATICS" PRINT LEFT$ (X$. The numeric value of Y is converted to string in line number 20. which operate on string variables and help in string processing. on execution. Example 10 20 30 40 “7384” 27. STR$(Y) This is the reverse operation of VAL. X$ = Left String LEFT$ (X$. The value of Y here is converted into a string literal. LET Y =7384 LET X$=STR$(Y) PRINT X$ END The output will be “7384”. will be 12345. Right string RIGHT$(Y$.e. Y can be a numeric constant. variable or expression.5 String Processing in BASIC Following are the few functions.

4. 3) 105 . (a) (b) (i) What is the use of an INT function? What would be the value of X in the following program segments? C$ = "AVAILABLE" X = LEN(C$) (ii) C$ = "899" X = VAL(C$) 2.5) END Output will be BLANK.4) PRINT B$ END Output will be AGED. IN-TEXT QUESTIONS 4 1. Middle String MID$(X$. Example 5 10 20 30 LET X$ = "MANHATTAN" PRINT MID$(X$. find the values of following functions: (a) (b) LEFT$(A$.Example 3 10 20 30 LET X$ = "PORTBLANK" PRINT RIGHT$(X$. Example 4 10 20 30 40 LET A$ = "MANAGED" LET B$ = RIGHT$ (A$.2) MID$(A$.Y) Returns a sub string of X$ starting at the character position X from the left and containing Y characters.3) END Output will be HAT. If A$ = "TO ERR IS HUMAN" B$ = "TO FORGIVE DIVINE".X. 2.

X. Program 1 5 10 15 20 30 40 50 60 Output GREAT LET L$ = “ ” LET C$ = "TAERG" L = LEN(C$) FOR X = L TO 1 STEP -1 LET L$ = L$ +MID$(C$.6 EXAMPLE PROGRAMS Problem 1 Write a program to invert TAERG to GREAT. 3) + MID$ (B$.(c) RIGHT$ (B$. 4) (d) (e) A$ +" " +B$ MID$ (A$.2) 27.5. Given Program 2 10 20 30 40 50 60 70 LET F$ = "GRAPE" LET B$ = "FRUIT" LET C$ = F$ +B$ PRINT C$ LET A$ = B$ +F$ PRINT A$ END Line 40 prints GRAPEFRUIT Line 60 prints FRUITGRAPE 106 .4.1) NEXT X PRINT L$ END Problem 2 Write a program to give the word GRAPEFRUIT and FRUITGRAPE when GRAPE and are separately.

Q LET S = Q*P(C) PRINT "PRODUCT CODE". Program 3 10 20 30 40 50 60 70 80 90 100 110 DIM P (5) FOR C = 1 TO 5 READ P(C) NEXT C DATA 20. C IF C<1 OR C>5 THEN END INPUT "QUANTITY SOLD". Write a program to arrange them in descending order.16. Program 4 10 REM PROGRAM TO ARRANGE THE GIVEN NUMBERS IN DESCENDING ORDER 15 20 50 DIM X (25) INPUT "HOW MANY NUMBERS ARE THERE". COST OF SALE" . Write a program to calculate and print the cost of sale along with product code and quantity sold. C . "QUANTITY SOLD ". S GO TO 60 Line number 70 contains END. Terminate the procedure when the product code is out of range.Problem 3 The prices of different articles are stored in a one-dimensional table. there product code is also given as: Price in Rs.N FOR I = 1 TO N 107 . Problem 4 A set of given numbers are there.14 INPUT "PRODUCT CODE". Product Code 20 1 15 2 16 3 18 4 14 5 Let us assume that product code and quantity sold for an article is inputted through keyboard. Q.15.18.

Problem 6 Write a program to print the Prime Numbers between any two numbers A (say 1) and B (say 100).4. A.3). 1).LEFT$(A$.1) 30 END Line number 20 can be put in two consecutive PRINT statement also.1)+ RIGHT$(A$.60 65 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 READ X (I) NEXT I PRINT "ORIGINAL ORDER IS:" FOR I = 1 TO N PRINT X(I) . Program 6 10 20 30 INPUT “TWO NUMBERS”. MID$(A$.B FOR N= A TO B STEP 1 IF N MOD 2= 0 OR N<= 1 THEN GO TO 80 108 . NEXT I PRINT "NUMBERS IN DECREASING ORDER" FOR I = 1 TO N-1 FOR J= 1 TO N-1 IF A (J)>=A (J+1) THEN 180 TEMP= A (J) A (J)= A (J+1) A (J+1) =TEMP NEXT J NEXT I FOR I = 1 TO N PRINT A (I). 2)+MID$(A$.2)+MID$(A$.3.4. NEXT I END Problem 5 From the word "MAIDAMS" write the message "MADAM IS MAD" Program 5 10 20 LET A$ = "MAIDAMS' PRINT LEFT$(A$.

40 50 60 70 80 90 FOR X=3 TO SQR(N) STEP 2 IF N MOD X =0 THEN 80 NEXT X PRINT N.125……………1000 1. 27.10………………100 (c) 1.7 WHAT YOU HAVE LEARNT In this lesson we have discussed various statements relating to decision making. Use of subroutine. 9 ………………100 (b) 2.4. 27.9. Write a BASIC program to run up the following series 2. “IS THE PRIME NO” NEXT N END Explanation In the line number 30.27.3.N MOD X means remainder of N/X. These commands play very important role in writing programs.8 TERMINAL QUESTIONS (a) 1. I*J 60 PRINT I+J. N MOD 2 is same as MOD(N. What will be the output of the following programs? (a) 10 FOR I = 1 TO 3 20 FOR J = 1 TO 5 30 PRINT I. similarly in line number 50.5.4. looping and branching.8.7. I-J 70 PRINT 100 NEXT J 110 NEXT I 120 END (b) 10 FOR I = 1 TO 5 109 . J . The illustrations given in this lesson will help you for a better grasp of BASIC programming.64.6.25………………100 (d) 1.2) it gives the remainder of N/2.16. J. Usage of some BASIC functions has been clearly defined for the benefit of the students. sub-programs and arrays has been explained clearly by taking number of examples. I+J 40 IF J = 3 THEN 100 50 PRINT I.8.

(a) 7 9 11 (b) 2 3 4 5 7 8 9 10 11 IN-TEXT QUESTIONS 2 110 . (a) (b) (c) 2.9. Write a program to invert LOOHCS to SCHOOL. 40 FOR J = 1 TO K 50 PRINT “ “.3. 60 NEXT J 70 PRINT 80 NEXT I 90 DATA 5. 5. Write a program to write your own address 10 times on the screen.20 READ K 30 PRINT I . 4.9 FEEDBACK TO IN-TEXT QUESTIONS IN-TEXT QUESTIONS 1 1.K. 27. Write a program to write PANKAJ KUMAR GOEL as P.6 100 END 3. GOEL.2. (a) S I Positive odd 40 50 (b ) 50 NEXT J NEXT K NEXT I 3.

2) = 30.1) = 25 FAX(2.4) = 20 3. (a) (b) FAX(1.J) NEXT J NEXT I PRINT "SMALLEST VALUE =".1) LET LARGE = X(1.J) < SMALL THEN LET SMALL = X(I. 4 4 5 4.1. LARGE END 5 10 20 30 40 50 60 70 80 90 120 130 140 150 160 180 190 DIM A(5) REM READ NUMBER OF DATA VALUE READ N REM READ DATA VALUE INTO ARRAY A FOR I =1 TO N READ A(I) NEXT I REM NOW SORTING STARTS FOR M = 1 TO N-1 IF A (M+1) > = A(M) THEN 18 0 REM INTERCHANGE OF DATA VALUES LET P = A(M) LET A (M) = A (M+1) LET A(M+1) = P NEXT M REM PRINT THE SORTED ARRAY 111 .1) FOR I = 1 TO 4 FOR J = 1 TO 5 IF X(I. (a) (b) (c) True True False 2. FAX(1.) = 15. 10 20 30 40 50 60 70 80 90 100 110 LET SMALL = X(1. FAX(2. SMALL PRINT "LARGEST VALUE =".3.J) IF X(I.J) > LARGE THEN LET LARGE = X(I.

to the statement immediately following the subroutine call. (a) A list of quantities can be given one variable name using a subscript. (b) (c) It defines the number of memory locations required for the array name.e. 14. (b) (i) 9 (ii) 899 (As numeric value) 2 (a) (b) (c) (e) TO OE TO ERR IS HUMAN TO FORGIVE DIVINE ERROR LESSON 28 PROCESSING FILES IN BASIC 112 . 5 END IN-TEXT QUESTIONS 3 1. -20. a variable is called a subscripted variable. which requires to be repeated very frequently in a program. -71.(i. 0. NEXT K DATA 5. (a) TWO THREE ONE (b) 5 3 Such IN-TEXT QUESTIONS 4 1 (a) It takes numeric value as its argument and returns its value after truncating its decimal part.200 210 220 230 240 FOR K = 1 TO N PRINT A (K). It is placed at the end of the program and may be referred to at different places in the main program using GOSUB statement. It is a collection of statements. (d) RETURN transfers the control back to the main program. GOSUB statement) 2.

Name. A date file forms an essential framework of a data processing system. files are categorised as: Sequential access files Direct (Random) access files Sequential Access Files These files may be created on a magnetic tape or disk. Address. we will discuss the methods that are currently used in most of the IBM compatible systems. A file can be described as a collection of records where a record consists of number of data values. Data from these files is read sequentially. which are either produced by a computer as per the instructions of a program or given to the computer as a data. It is a collection of data organised in a specific format and for a specific purpose. Each partition is a data item and is referred to as a field.. For example. 113 . etc. In this lesson. But it is difficult to handle large volume of data with the help of these statements.1 INTRODUCTION We have so far discussed programs where data is supplied either through READ. 28.. A number of BASIC Programs can use this file as input. The above limitations can be overcome by placing the data into a separate storage area called a data file. In the sequential file we cannot change the existing entry or insert a new entry. yet it has a serious disadvantage. CCA. which is kept somewhere in external memory.28. Sex.2 OBJECTIVES On completion of this lesson. Though sequential access file is easy to handle. File handling methods differ widely from system to system. A typical data processing system many consist of many files. Basic pay. Designation. data stored in one program cannot be shared by other programs.3 TYPES OF FILES Depending on the way in which the data is stored and accessed. DA. you should be able to: understand various types of files know how to handle sequential files know how to handle random access files discuss various examples/ programs relating to these two type of files. starting at the beginning. 28.DATA statements or through INPUT statements. Many records in a file contain detailed information about some aspect of the system. a "pay file" may contain one record for each employee containing all the particulars such as Employee Code. item after item. Moreover. HRA.

1 and 28. 28. we should copy the entire content to another file making the changes on the way and then copy the correct data back in to the original file. Another disadvantage is that we cannot simply locate or go back to read a particular data item.1 Sequential File on a Tape Consider an inventory file shown in Table 28. Fig.1 Inventory file 114 .2 show how data is stored on magnetic tapes and disk respectively.1 Part name AAAA BBBB CCCC Part number 101 102 103 Price 8.00 Quantity 100 200 300 Table 28.00 10.00 12. 28. Fig. A disk consists of a number of concentric circles known as tracks. The data items are stored on these tracks sequentially.To do this.

00 100 BBBB 102 10.00 200 CCCC 103 12.Fig. 28. the data file would look like a long column of values as shown below: AAAA 101 8.2 Sequential File on a Disk Details of each part are stored in one record. When we complete all the parts.00 300 Programs are written to read these data values one after another. Random Access Files 115 .

Extension is longer than three characters. Thus.4 HANDLING OF SEQUENTIAL FILES Using data files would require the incorporation of statements in your program to perform the following functions: Giving a name to the file Opening the file Writing to or reading from the file Closing the file 28.4. 3. It is of the form: Device name: File name The device name tells the system which device to look for the file and the file name tells which file to look for on that device. Random access files allow more flexible access than the sequential files. File Name 1. 2. The device name should be followed by a colon as indicated. When you use longer file name. 116 . MKS The device names A and B indicate the disk drive one and two respectively File names can have a maximum of eight characters.1 Naming a file A file is identified by its file specifications. A period is inserted after the eighth character and extra characters (up to three) are used as the extension. Gives an error. You can read or write any record directly in a random file without searching through all the records that precede it. However. Name is longer than eight characters. one of the following conditions may occur. Result Extra characters are truncated. the files stored on disks may have a file name extension in the following form.Random access files are created on disks to allow us to read or write from the files in random order.EXT The extension consists of a period and followed by three letters. Examples are: A: MEAN B: STUDENT. NAME. reading and writing of data is faster. 28. Name is longer than eight characters and extension is included.

If a file. "file name"] Mode is a string constant and takes one of the following three forms O for sequential output file I for sequential input file R for random input/output file It should be noted that the mode is enclosed in quotation marks.KUM. Examples of opening sequential files for input and output operations are: 10 OPEN "I" # 1..For example. A file number may be a number. which does not exist.4. It is a unique number associated with the actual physical file. #file number. SURENDERKUMAR becomes SURENDER. This should conform to the specifications of the file when it was created. File name specifies the particular file to be used. is opened.2 Opening a file It is necessary to establish a line of communication between a program and a file that is to be used before data can be read from or written to that file.PEN. File names must be enclosed in quotations. This is achieved by using the OPEN command as shown below: OPEN ["Mode".PENSION becomes PROGRAM. It is important to note that opening a file for output destroys the existing data in that file.4.DTA" FOR INPUT AS# 1 20 OPEN" TEMP" FOR OUTPUT AS #3 If a file opened for input operation does not exist. 28.BAS gives an error. a "FILE NOT FOUND" error will be shown on the screen. PROGRAM. #file number. File number is an integer number and can be any number between 1 and 15. in that case file will be created.] 117 . 28. " PANKAJ. .DTA" 20 OPEN "O". PAYROLLCALUCTION. "TEMP" These can also be written as 10 OPEN" PANKAJ.3 Closing a File A previously opened file can be closed using the CLOSE statement as follows CLOSE [# file number.. or expression. # 3... variable..

You should also note that execution of END and RUN statements also causes all open sequential files to be automatically closed. For example. the statement. list of variables] WRITE [ #file number. list of variables ] File number refers to the file designator used when the file was opened for output. List of variables specifies the data that is to be written to the file. 100 CLOSE #1. Example 1 Program 10 REM *** PROGRAM INVENTI *** 118 .4 Writing Data to a File We may write data to a sequential file using either of the following two statements. etc. PRINT [# file number. The difference between PRINT # and WRITE # Statements is that WRITE # inserts commas between the data items and quotation marks for strings while PRINT # causes data to be written without any delimiters (commas. The CLOSE statement is used when you have finished processing data from a file. STOP does not close any files.4. AMT would write the following image to the file 1: "PANKAJ". AMT In case N $ = " PANKAJ" and AMT = 2000. Let us take an example for proper understanding the use of "WRITE" and "PRINT" statement.The file number is the number used in the OPEN statement. the statement would write the following image to the file 1: PANKAJ 2000 The statement 40 WRITE # 1. 2000 The delimiters are useful when we try to read the data with an INPUT # statement. However.). N $. For example consider the statement 40 PRINT #1 N $. 28. # 3 causes the files with file numbers 1 and 3 to be closed. A CLOSE statement with no file numbers specified causes all files that have been opened to be closed.

QTY QUANTITY 60 OPEN "O". P.PN PART NUMBER 40 REM -.4. DTA" 70 FOR I =1 TO 3 80 INPUT "NAME" . PNM$.P PRICE 50 REM -. It takes the form INPUT [ # file number. PN.PNM$ PART NAME 30 REM -. list of variables ] 119 . "INVENT . QTY 130 PRINT 140 NEXT I 150 CLOSE #1 160 END Output NAME? AAAA NUMBER? 101 PRICE? 8 QUANTITY? 100 NAME? BBBB NUMBER? 102 PRICE? 10 QUANTITY? 200 NAME? CCCC NUMBER? 103 PRICE? 12 QUANTITY? 300 28. PNM$ 90 INPUT "NUMBER" PN 100 INPUT "PRICE" P 110 INPUT "QUANTITY" .20 REM -.5 Reading Data from a File Data can be read from a sequential file using the INPUT # statement. # 1. QTY 120 WRITE # 1.

"PART".#1. PN. 120 . P. DTA: 200 INPUT #1.The following INPUT # statement can be used to read data from the file INVENT . P. This can be avoided by using the EOF function. PN."NUMBER" 40 PRINT 50 INPUT #1 PNM$. "QUANTITY". line 50 causes an "Input past end" error. Example 2 Write a program to read inventory data stored in the file INVENT. When all the data have been read. QTY 60 LET V= P* QTY 70 PRINT PNM$. PN. "INVENT . QTY The type of data in the file must match the type specified in the list. Unlike INPUT. DTA inventory and print the table with the value of each product. V 80 GOTO 50 90 CLOSE 100 END Output PART NAME AAAA BBBB CCCC Input past end in 50 101 102 103 PART NUMBER 8 10 12 100 200 300 800 2000 3600 PRICE QUANTITY VALUE The program in Example 2 reads sequentially. Program 10 REM ** PROGRAM INVENT 2 ** 20 OPEN I". This function tests for end of file and the control is directed appropriately. " VALUE " 30 PRINT "NAME". QTY. " PRICE". PNM$. P. DTA" 25 PRINT "PART". The end of the file is indicated by a special character in the file. every item in the file. no question mark is displayed with INPUT # The following example will illustrate clearly the use of INPUT # statement.

and read back to produce a list. V 90 GOTO 50 100 CLOSE 110 END 28. Example 3 illustrates the use of LINE INPUT #statement. from a sequential file and assign to a string variable. P. "QUANTITY" "VALUE" 30 PRINT "NAME". It is of the form LINE INPUT [ #file number. store them in a file named ADDRESS.4. #1 "INVENT . PN. PN. LINE INPUT # reads all characters in the sequential file up to a carriage return which was inserted by the PRINT # statement. ignoring delimiters. DTA" 25 PRINT "PART".The program INVENT2 is modified as follows: 10 REM ** PROGRAM INVENT 2** 20 OPEN "I". QTY 70 LET V = P*QTY 80 PRINT PNM$."PRICE. #1 "ADDRESS" 121 .6 Reading lines from a File The LINE INPUT # statement may be used to read an entire line. Example 3 Write a program to input employee addresses from the keyboard. Program 10 REM ** PROGRAM EMPLOYEE ** 20 REM ** INPUT EMPLOYEE ADDRESS THROUGH KEYBOARD ** 30 OPEN "O ". The next LINE INPUT # reads all characters up to the next carriage return. string variable ] File number is the number under which the file was opened and string variable is used to store a line of string constant. "NUMBER" 40 PRINT 50 IF EOF (1) THEN 100 60 INPUT #1. QTY. P. PNM$. "PART".

PITAMPURA. AUDIT OFFICE. For example. ADDR$ 120 PRINT ADDR$ 130 NEXT I 140 CLOSE 1 150 END Output TYPE IN ADDRESSES? PANKAJ KUMAR GOEL.7 Adding Data to a Sequential File To add any data to a sequential file that is already residing on a disk. MEDICAL COLLEGE. SANJU. GWALIOR DR. JODHPUR 28. DELHI -34 TYPE IN ADDRESSES? RAJESH KUMAR. DELHI-34 RAJESH KUMAR. its current contents are lost. DDDD 104 20. MEDICAL COLLEGE.4. You must note that when a sequential file is opened for output.0 200 EEEE 105 30. you should open the file with APPEND. you cannot just open the file and write data to it. which has been numbered as 1.0 300 122 . GWALIOR TYPE IN ADDRESSES? DR. "ADDRRESS" 100 FOR I= 1 TO 3 110 LINE INPUT # 1. In such cases. DTA" created earlier in Example 1. JODHPUR PANKAJ KUMAR GOEL. Now we can add records to the file. PITAMPURA. SANJU. Following example will illustrate the use a of Append Example 4 Write a program to add two more products to the file "INVENT . the statements 10 FILE = " A: TEMP" 20 OPEN FILE FOR APPEND AS #1 will open the file named TEMP on the disk in drive A and position the file pointers at the existing data. AUDIT OFFICE.40 FOR I = 1TO 3 50 LINE INPUT "TYPE IN ADDRESS" ADDR$ 60 PRINT # 1 ADDR$ 70 NEXT I 80 CLOSE 1 85 PRINT 90 OPEN : "I" # 1.

P. PNM$. QTY 50 WRITE #1. 300 AAAA BBBB CCCC DDDD EEEE 101 102 103 104 105 8 10 12 20 30 100 200 300 200 300 28. QTY 130 PRINT PNM$. P. 20. Random files require more programming steps and skills. 104.5 HANDLING OF RANDOM ACCESS FILES Unlike sequential files. DTA 100 PRINT 110 IF EOF (1) THEN 160 120 INPUT #1.1 Creating a Random File Following are the steps required to create a random file: 123 . random files cannot be created so easily. PN. QTY 140 GOTO 110 150 CLOSE # 1 160 END Output ? DDDD. 28. P. P. 105.Program 10 FILES = "INVENT . #1. QTY 60 NEXT I 70 CLOSE # 1 80 REM ** DATA INPUT FROM FILES ** 90 OPEN "I". PN. "INVENT . PN. PNM$. 200 ? EEEE.5. since random access files effectively retrieve or write individual data items anywhere in the file they are often preferred. PN. However. 30. DTA" 20 OPEN FILES FOR APPEND AS #1 30 FOR I=1 TO 2 40 INPUT PNM$.

" AS #3 LEN = 120 Step2: Space in the random buffer is allocated by the FIELD statement in the form FIELD [#file number. For example. 100 OPEN "R". we may open random files using the OPEN Statement . Note that FIELD is a declaration statement and does not actually place data into the random buffer. OPEN ["R".120 These statements can also be written as 100 OPEN "PANKAJ" AS#2LEN =100 200 OPEN "CHAPS. #2. w1 AS u1.. random files cannot be created so easily. For examples.Open the file Allocate space in the random buffer for variables that will be written to the file Move the data into the random buffer Write the data from the buffer to the disk Step1: Like sequential files. For instance. Random files require more programming steps and skills.100 200 OPEN "R".Record length] The character R indicates that the file to be opened is a random access file.#3. w2 AS u2..] File number is the number of the concerned file just opened. "CHAP5". A FIELD statement defines variables that are used to put data into or get data out of a random buffer.20 AS A$. However. since random access files effectively retrieve or write individual data items anywhere in the life.#2 "CHAP1".40 20 FIELD #2. Record length is a number that specifies the length of records. w1 specifies the number of character positions to be allocated to the string variable and so on. Unlike sequential files. 5 AS B$. the statement 50 FIELD #2."File name". The default record length is 128 bytes. the statements 10 OPEN "R". they are often preferred. 10 AS C$. The total number of bytes allocated in a FIELD statement must not exceed the record length specified in the OPEN statement. 20 AS A$ 10 AS B$ defines two string variables A$ and B$ and allocates first 20 bytes to the variable A$ and next bytes to B$. 10 AS D$ 124 . The length may range from 1 to 32767. #File number. "PANKAJ'.

Let us suppose F1$ represents CONNECTING-PROD and F2$ represents 5000. MKD$ converts a double-precision number to an 8-byte string. This can be done using the following `convert' functions. then the field represented by A$ and B$ in the random buffer are filled like this: C O N N E C T I N G - P R O D 5 0 | --------------. MKI$ converts an integer to a 2-byte string. MKS$ converts a single-precision number to a 4-byte string. the record length as defined in the OPEN statement in line 10. In this case. They take the form: LSET u$ = x $ RSET u$ = x $ Where u$ is the name of a string variable that is defined in a FIELD statement and x$ is a string variable representing the data to be placed into the field identified by u$ Examples of these statements are: 30 LSET A$ = F1$ 40 RSET B$ = F2$ LSET statement left-justifies the string in the field. which is more than 40. a "Field overflow" error will appear on the screen. any number value that is to be placed in a random file buffer must be converted to string value before it is LSET or RSET.open a file named CHAP1 as a random file and allocates character positions as follows: First 20 bytes to A$ Next 5 bytes to B$ Next 10 bytes to C$ Next 10 bytes to D$ Note that the total number of bytes allocated is 45. If the character positions allocated to A$ is 18 andB$ is 5.| 0 0 | --------------------------------------A$------------------------------------------ Since all the fields in a random buffer are defined as string fields. Step 3: Placing data into the random file buffer is done by the LSET and RSET statements. 125 . and RSET statement right justifies the string.

PUT {# file number. Each time a PUT statement is executed.MKI$(RN) RSET B$.C. For example LSET A$ . Example 5 Write a program to open a random and record salary file statement of employees with the following details: 1 Name 2 Basic Pay 3 D.LSET A$ or RSET A$ MKI$ ( integer variable) MKD$ (double-precision variable) Where A$ is the string variable defined in the FIELD statement. record number] File number refers to the number under which the file was opened. 5 C.MKS$ (PAY) Step 4: Moving of data from a random buffer to a random file is done by the PUT statement. It can also be written as 100 PUT #2. the statement 100 PUT #2.A. Let us take an example to clarify various statements discussed for creating a random file.A.A.A. Record number is the number of the record to be written and expressed as an integer constant or variable. The value of K must be defined before using the PUT statement. H. Each time a PUT statement is executed. Assume the following data: Name Basic Pay D. 126 . 1 will write the information contained in the buffer to the first record of the random file numbered 2.K where K is an integer variable. For example.C.A. C. If record number is omitted.R. 4 H. a record is written to the file. the record will have the next available number. a record is written to the file.A.R.

UPMA SANJU ANAMIKA

25,000 20,000 15,000

5000 4000 3000

8000 7000 6000

2000 1500 1000

Program 10 REM ** CREATION OF RANDOM FILE ** 20 OPEN " R",#1,"SALARY" 60 30 FIELD #1,20 AS N$, 10 AS B$ 10 AS D$, 10 AS H$, 10 AS C$ 40 INPUT "RECORD NUMBER"; I 50 IF I=0 THEN 150 60 INPUT "NAME "; A$ 70 INPUT "BASIC PAY"; P 80 INPUT " DEARNESS ALLOWANCE"; Q 82 INPUT "HOUSE RENT ALLOWANCE"; R 85 INPUT " COMPENSATORY CITY ALLOWANCE"; S 100 LSET N$ = A$ 110 LSET B$ = MKS$ (P) 120 LSET D$ = MKS$ (Q) 122 LSET H$= MKS$ (R) 125 LSET C$ = MKS$ (S) 130 PUT # 1, I 140 GOTO 40 150 CLOSE # 1 160 END

Output Record Number? 1 Name? UPMA Basic pay? 25000 Dearness Allowance? 5000 House Rent Allowance? 8000 Compensatory city Allowance ? 2000 Record Number? 10 Name? SANJU Basic pay? 20000

127

DA? 4000 HRA 7000 CCA? 1500 RECORD NUMBER? 40 Name? Anamika Basic Day? 15000 DA? 3000 HRA? 6000 CCA? 1000 Record Number 0

28.5.2 Accessing a Random File Like creation, accessing a random file includes the following points: Open the file for random access Allocate space in the random buffer for variable using the FIELD statement that will be read from the file.(Remember that if a program performs both the input and output on the same random file, you may use only one OPEN statement and one FIELD statement) Bringing data from the file to the buffer for processing Access and use data in the program

Step 1: Follow the procedure of step 1 in creating a file. (see Section 5.4.1) Step 2: Follow the procedure of step 2 in creating a file. (see section 5.4.1) Step 3: Bringing data from the file to the buffer is done by the GET statement. This is similar to the PUT statement. GET [#file number, record, number]

Record number is optional and, if it is omitted, the next record (after the last GET ) is read into the buffer. For example, 200 GET #2, 10 will transfer the content of the record number 10 from the file number 2 to the buffer. Step 4: After a GET statement, the data available in the buffer can be used by the program for further manipulation and printing outputs. Remember that the numeric values are recorded as string values in the buffer and therefore all numeric values must be converted back to numbers for performing any arithmetic operations on them: This is done using following "convert" functions: CVI converts a two-byte string to an integer. CVS converts a 4-byte string to a single-precision number.

128

CVD converrts an 8-byte string to a double-precision number.

These functions are written in the form: x = CVI (u$) x = CVS (u$) x = CVD (u$)

u$ is the name of a string variable containing numeric values in the buffer and x is a numeric variable representing the data to be used in the program. The following program segment illustrates the use of GET and convert functions: 40 FIELD #2, 10 AS A$, 6 AS B$, 3 AS C$ 50 GET #2 55 LET N$ = A$ 60 LET M1 = CVS (B$) 70 LET R1 = CVI (C$) 80 PRINT N$, M1, R1

This program uses a random file numbered 2, which has fields as defined in line 40. Line 50 reads a record from the file. Line 60 converts the contents of to a single-precision numeric value and assigns it to the variable MI. Similarly, line 70 converts the contents of to an integer number and assigns the value to the variable R1. Line 80 writes the vales of N, MI and R1 on the screen.

In this case, N$, M1 and R1 may represent student names, marks and class rank. Note the conversion functions do not change the actual data. They only change the way the data is interpreted.

Remember that B$ and C$ were originally numbers which would have been written to the file using the MKS$ and MKI$ functions. Example 6 will help us in understanding the technique of accessing data stored in random life.

Example 6 Write a program to access the random file "SALARY" that was created in example 5. You are required to print the data contained in any desired record along with the total salary. Program 10 REM ** ACCESSING A RANDOM FILE **

129

20 OPEN "R" # 1, " SALARY", 60 30 FIELD # 1, 20 AS N$, 10 AS B$, 10 AS D$, 10 AS H$, 10 AS C$ 40 INPUT "RECORD NUMBER' K 50 IF K=0 THEN 130 60 GET # 1, K 70 LET P = CVS (B$) 75 LET Q =CVS (D$ ) 80 LET R =CVS (H$) 85 LET S = CVS (C$) 90 LET T = P+Q+R+S 100 PRINT "Record" K, N$, .P, .Q, .R, .S, .T 110 PRINT 120 GOTO 40 130 CLOSE 140 END

Output RECORD NUMBER? 40 RECORD 40 ANAMIKA 15000 3000 6000 1000 25000 RECORD NUMBER? 1 RECORD 1 UPMA 25000 5000 8000 2000 40000 RECORD NUMBER? 10 RECORD 10 SANJU 20000 4000 7000 1500 32500 RECORD NUMBER? 0

IN-TEXT QUESTIONS 1

1. Determine whether the following statement to true or false (a) A file can store a program's output for future use (b) A file cannot be used by more than one program. (c) When a file is opened for INPUT, data can be written from the program to the file. (d) If a sequential file is created and then read in the same program, it must be closed and reopened between these operations. 130

2. Correct the syntax errors in each statement. (a) 10 OPEN "FILE 1" AS # 2 FOR OUTPUT (b) 20 WRITE # 2 A, B, C, D, (c) 30 KILL FILE 2

3 Following program segment is supposed to create and display (on the screen) in file containing the integers from 1 to 100, but it does not run properly. Correct the errors.

10 OPEN "FILE1" FOR INPUT AS # 1 20 FOR I = 1 TO 100 30 PRINT # 1, I 40 NEXT I 50 FOR I= 1 TO 100 60 INPUT # 1, I 70 PRINT # 2, I 80 NEXT I 90 CLOSE # 1 100 END 4. Write a program in BASIC to create a file called "STUDENT' containing the following data: (a) Name of the student (b) Roll Number (c) Marks in LOTUS (d) Marks in dBASE (e) Marks in BASIC 5. Write a program to retrieve data from the "STUDENT' file created in question 4 above and copy the same in a file named "STUDENT"1.

28.6

WHAT YOU HAVE LEARNT

In this lesson, we have discussed about processing of both sequential and random files. Although, now-a-days advance programming languages are used to process files, file handling through BASIC is quite simple and useful. Even today, BASIC files are quite popular in business data processing. It is hoped that the fundamentals and the examples presents in this lesson will be helpful in understanding the various steps involved in file processing and also to develop your own programs.

28.7

FEEDBACK TO IN-TEXT QUESTION

131

(a) True (b) False (c) False (d) True 2 (a) 10 OPEN "FILE1" FOR OUTPUT AS # 2 (b) 20 WRITE # 2. ROLLNO. B 70 GO TO 40 80 CLOSE # 1 90 CLOSE # 2 100 END 28.0. BASIC. B 60 IF N = "AAA" THEN 90 70 WRITE # 1. B 80 GO TO 50 90 CLOSE # A 100 END 5. N$. R. D. LOTUS-MARKS. L.0.MARKS" 40 PRINT "Type AAA. 10 REM PROGRAM TO CREATE " STUDEN" FILE 20 OPEN "STUDENT" FOR OUTPUT AS # 1 30 PRINT "NAME. R. L. 0. DBASE-MARKS. 10 REM PROGRAM TO COPY "STUDENT" FILE 20 OPEN "STUDENT" FOR INPUT AS # 1 30 OPEN "STUDENT1 FOR OUTPUT AS # 2 40 IF EOF (1) THEN 80 50 INPUT # 1. C. D. N$. B. D (c) 30 KILL "FILE 2" 3. R. L. D. B 60 WRITE # 2. R. L. N$.8 TERMINAL QUESTIONS 132 . A.IN-TEXT QUESTIONS 1 1. D. CHANGE: 10 OPEN "FILE1" FOR OUTPUT AS # 1 70 PRINT I INSERT: 45 CLOSE # 1 47 OPEN "FILE1" FOR INPUT AS # 1 4.0 TO MAKE AN END" 50 INPUT N$.

7. 20 AS NM$ 30 GET #2. A: B: C 40 OPEN #2 LEN = 128 50 FIELD #1. The following program segment is supposed to create and display a file of numbers. ". 15. 20. PAY 30 INPUT #2. 4 AS COST $. N 80 PRINT N 90 NEXT I 100 CLOSE #1 110 DATA 5. 19. NM$.DTA" A$ #1 LEN = 24 20 FIELD #1. Correct the errors in it. N 50 NEXT K 60 FOR K = 1 TO 10 70 WRITE #1.".DAT. 10 OPEN "NUMFL" FOR INPUT AS #1 20 FOR I = 1 TO 10 30 READ N 40 PRINT #3. 9. B$. A$ AS 10 2. (b) Delete the fourth record from the file. 133 . Write a program segment that performs the following operations: (a) Display the number of record of records in EMPLOYEE. Suppose that a file named COMPUTE. 10. 12. COST 4. 22 120 END 3. Find the syntax errors in the following statements: 10 OPEN "FILES" AS #5 FOR OUTPUT 20 PRINT #6 A.DTA exists with 20 records of the form: NM$ 20 bytes COST$ 4 bytes Correct the following program so that it displays the fifth record in this file on the screen: 10 OPEN "COMPUTER. ". 17.".1. 5 40 LET NM$ = N$ 50 LET COST$ = COST 60 PRINT #1.

In our life we have to remember so much of data. 20. In fact. But it is too difficult for you to memorise all these information for a large number of individuals. Rate of pay (RATE). subjects offered and postal address of all these students. educational qualification. Name (NM$). number of students in a school. But it is easier for us to remember all information for a few individuals. 1500 to Rs. 5. 2500. price of potato. it will not be possible for you. If you are asked to memorise records of date of birth. pin code of a city. of your close friends.(c) Change the pay in the sixth record from Rs. LESSON 20 INTRODUCTION TO DATABASE 20. residential address. We arrange all information about students in a tabular form. Let us consider the example of National Open School (NOS). Write a program segment that (a) Renames this file as PAY. income. unknowingly we come across data in our day to day life everyday. „How many students are there in Economics?‟ I am in a position to answer. are some examples of data.3 WHAT IS A DATABASE? 134 . 12 (d) Change the rate of pay of employee number 140 from 15 to 20. For example. (c) Adds the records 135. complexion. "AAA". "SANJU". and a sentinel record of 0. To deal with such problems we construct a database. The age of a person. Assume that a file PAYROLL exists with records with form Employee number (NUM). you may be in a position to tell accurately the age. etc. (b) Deletes a record with employee number 50. Every year about one lakh students take admission in NOS.1 INTRODUCTION All of us are familiar with the term data. height. We keep all the records so that if I am asked.2 OBJECTIVES After going through this lesson you will be in a position to explain the concept of database appreciate the features of database management system (DBMS) learn about the software packages available in the market to deal with database Invoke the dBASE III + programmes explain the advantages of dBASE III + work in dBASE III +. etc. 20. 0.

We have given 6 items of information on every student. Bhubaneswar Orissa Pol Sc. 20.1981 M At/Po. Hindi 9724004 Ahmad Ali 23. Eco.06.09. 20. Sector 2. A sample of 5 students is presented in the table below (see.1980 M C36. 20. Database is a collection of information in a structured way.11. Date of birth. Sex.1 135 .05. Eng. Sex.1980 M 96. Sambal Pur 9732012 Madhu Jain 03. Hindi 9721002 Aditya Bhoi 12. Suresh 07. Hindi Fig. Each field represents one and only one characteristic of an event or item. Name. We can say that it is a collection of a group of facts. Thus there are six fields in this database.1979 F A31. Eng. Eng. Your personal address book is a database of names you like to keep track of.1 contains required details about each student. There are six pieces of information on each student. Hindi Phy. Name. Pilani. They are Roll No. Eco. Let us look into our earlier example of information on students in NOS. Eco.Let us begin with the concept „database‟ and its management.01.1). namely. New Delhi Phy. Fig. Date of birth. Address and Subjects. Malviya Nagar. Postal address and Subjects offered by the student.1979 M 12A. We can define field as the smallest unit in a database. History. Chem. Eng. Chem. Sheikh Sarai-I. Hindi 9715023 C. Eng. Fig. Each piece of information in database is called a Field. Biology. Rajasthan Pol Sc. History. Roll No. ROLL NO NAME DATE OF BIRTH SEX ADDRESS SUBJECTS 9721001 Subrat Das 21. Biology. Bhopal Pol Sc. Burla. such as personal friends and members of your family. History.

We can say that it is a collection of logically related records. 20. Using a DBMS files can be retrieved easily and effectively. Date of birth is date type whereas Name is character type. they are not of the same type. There are many DBMS packages available in the market. Data management involves creating.4 HOW TO START dBASE III PLUS? 136 . and using this data to generate reports or answer queries. First let us be familiar with another concept that we will use frequently.If you take a close look at all these fields. modifying. all six fields taken together for a particular student is called a record of that student. In this lesson we will discuss about the package dBASE III + which is a DOS based package. In other words a database is a collection of database files. This means you can work through both assist screen and dot prompt. we can define record as a collection of logically related fields. deleting and adding data in files. In the example above. It allows you to work with both financial figures and text. It provides many choices to work with the program. In database there can be five categories of fields. The software that allows us to perform these functions easily is called a Data Base Management System (DBMS). Some of them are: dBASE III Plus FoxBASE Plus SoftBASE Clipper Paradox There are some WINDOWS based database packages available in the market such as MS ACCESS (part of MS OFFICE). and each database file is a collection of records. since there are six students there are six records. Thus. Hence. They are: Numeric Character Logic Memo Date We will discuss about each type of field in detail later on in this lesson. The task before us is creation of a database and its management. Now we are in a position to define database in a formal manner. All the related fields for a particular event is called a Record.

etc. 4. Remove the system disk # 1 from drive A and insert system disk # 2. 2. You can type either lower case or upper case alphabets. As the computer displays the main menu of dBASE III + your monitor will look somewhat like Fig. Press ENTER key. 5. 6. 2. 20. 4. The dBASE III + logo will disappear from the screen and main menu of dBASE III Plus will appear. Note that dBASE III + comes in two diskettes: system disk # 1 and system disk # 2. Insert system disk # 1 in drive A. Let us begin with the procedure of loading dBASE III + into systems with Hard disk. 3. The computer will take a few seconds to show the copyright and logo of dBASE III + on the screen. Now you are inside the dBASE III + program. 5. 137 . It will look like C:\>. In these days more and more people are using the Hard disk to run the program. we will discuss the procedures to invoke dBASE III + in both Hard disk and floppy drives systems. The steps that you have to follow are: 1. You have to change the directory to come into dBASE III +. As you start the computer on the DOS mode you see C:\> on the top left corner of the monitor. Press ENTER key again. Type A: The prompt will change to A:\> 3.2. After a few seconds the screen will display details of the dBASE III + package like name. Type CD\DBASE and press ENTER key. Type DBASE and press ENTER key. Suppose your system does not have a hard disk and there are two floppy drives. On the screen you will see C:\DBASE>. version. After a few seconds main menu of dBASE will appear on screen. Type dBASE and press ENTER key. The computer systems with two floppy drives and no Hard disk are obsolete now. Now let us discuss how to load dBASE III + from floppy drives. Start the computer in the DOS mode. The bottom of the screen will contain the message. The C prompt will appear on the screen. However. The computer does not distinguish between the two.You can invoke dBASE III + either from Hard disk or from floppy drives. You have to obtain both the diskettes before loading the dBASE III + in your computer. „INSERT SYSTEM DISK # 2 AND PRESS ENTER KEY‟. The steps that you should follow are 1.

(e) Paradox is a DBMS package. (d) You can invoke dBASE III + either from Hard disk or from floppy drives.Fig. and the underscore character ( _) It cannot contain blank space. record. Define field. (b) A database is a collection of logically related records. (c) Date of birth is character type field. For example. Write True or False (a) In database there can be six categories of fields. 2.DBF to your database file. you can give a file name NAMELIST. Saving the database structure 2.2 (given at the end) IN-TEXT QUESTIONS 1 1. file. Name three DBMS packages.1 Creating a Database When you want to create a database you have to take care of the following steps: You have to specify the database file structure such as File name Field names Field types Field widths Decimal places (for numeric fields only) 1. Entering data into the file as records 20.2 File Name File name can be up to eight characters with additional three characters extension. 20.5. and database briefly.5. 138 . It must begin with an alphabet Can include numbers. 3. 20.5 HOW TO CREATE A DATABASE? 20.

In Fig. Remember you can type commands either in lower case or in upper case. 20. 20. It is in the form of MM/DD/YY where MM is the month. When you enter the file name you will see a screen as in Fig. Character field can contain up to 256 characters or bytes. address. 4. For example. Memo: Memo fields are used to store large block of text or tabular information. dBASE III Plus does not distinguish between the two. Numeric: This type of field contains integers or decimal numbers. On the screen you will find the following message: Enter the name of the new file: You have to type a file name. Remember that file name should not be more than eight characters in length. numbers and blank spaces. During data entry it is activated by pressing CTRL+HOME and completed by pressing CTRL+END. DD is the day of the month and YY is the year.5. Logical: It contains either a 'true' or 'false' (YES or NO) value.1 the field Date of Birth is of date type. Its length is one character or one byte. NOS and press ENTER.20.5. Here you have to specify the structure of your database. The field width of memo field is upto 5000 characters or bytes. 20. Let us create a new database file NOS. For example. In Fig.3. Let us discuss them in detail.1 the fields Name. Sex and Subjects are character types. In order to create a new database you have to give the CREATE command at the dot prompt (see. You have to type . 1. Another point to remember is that in dBASE III Plus you can write the first four alphabets of a command instead of writing the whole command. 2.3 Field Types and Widths In the beginning we had mentioned that there are five types of fields. special symbols. Fig. Bytes remaining: 4000 139 . The maximum length of numeric field is up to 19 digits long. Address. Date: Date fields are 8 characters long.3 Field names Can be up to 10 characters long Can start only with an alphabet Can contain digits in between Cannot contain any special character except the underscore ( _ ). name.2). in place of CREATE if you can write CREA. 5. say. CREATE and press ENTER. Character: This type of field contains textual matter. either positive or negative. 20. 3. 20.

Here you have to specify the number of digits the field ROLLNO has and press the RIGHT ARROW key. You can change it to other field types by typing the first alphabet of the field type you want. L for logic and M for memo. 20. For ROLLNO the field type is Numeric. Type Width Dec CREATE <C:> NOS Enter the Field Name. . Hence you type in N. 20. Width .3 Suppose the name of the first field is ROLLNO. N for numeric. digits and under scores Fig. D for date. Field: 1/1 | Field names begin with a letter and may contain letters. Here you have to give specifications for the second record and go on till all records are specified.4. Since ROLLNO does not contain any decimal number you have to press ENTER only. The cursor will move automatically to the second record. Bytes remaining: 4000 140 . For example: C for character. Cursor will move to the last column Dec asking you to specify the number of decimal places the field contains. Hence you have to type in ROLLNO against the highlighted space below field name and press ENTER. The cursor will jump automatically to the column Type. .CURSOR   Char: Word: Pan: Home End ^ ^ INSERT Char: Field: Help: Ins ^N F1 DELETE Char: Word: Field: Del ^Y ^U Up a Field: Down a Field: Exit/Save: Abort: ^End Esc Filed Name Type 1. Your screen will look like Fig. Here by default the Field type is 'Character'. . Dec Character Filed Name . . The cursor automatically moves in to the column Width.

. CREATE <C:> NOS Field: 2/2 Enter the Field Name. .ROLLNO 2. Type Width Dec 1. Field names begin with a letter and may contain letters. . digits and under scores Fig. The computer screen will look like Fig. . 20.CURSOR   Char: Word: Pan: Home End ^ ^ INSERT Char: Field: Help: Ins ^N F1 DELETE Char: Word: Field: Del ^Y ^U Up a Field: Down a Field: Exit/Save: ^End Abort: Esc Filed Name Type Width Dec . 20. Bytes remaining: 4000 141 . Once you press the ENTER key you will find another message: Input data records now? (Y/N) If you want to type in data then press Y.4 Once you have created a structure you want to use. Any other key to resume. Numeric Filed Name .5 . Character . . . you can save it in your disk. Then you have to save the structure by pressing CTRL+W or CTRL+END At this point the computer will prompt you Press ENTER to confirm. . .5.

SUBJECTS: . . . 20. You give the command: . existing on a floppy or a hard disk. Thus you have to enter as many records as you want.6 OPENING AN EXISTING FILE Just as you open a book in order to read it. If you type Y you will return to dBASE dot prompt and if you type N you can continue editing of your file. also has to be opened. BIRTH DATE: . The USE command opens an existing database file so that it can be used for querying.CURSOR   Char: Word: Pan: Home End ^ ^ INSERT Char: Field: Help: Ins ^N F1 DELETE Char: Word: Field: Del ^Y ^U Up a Field: Down a Field: Exit/Save: Abort: ^End Esc ROLLNO: NAME: . At this point dBASE asks you if you really want to “Abort Editing? (Y/N)”.USE NOS 142 . . Suppose you want to open the earlier created file BIODATA for further modification. CREATE <C:> NOS REC:NONE Fig. After completion of data entry you have to save it by pressing CTRL and END keys together (CTRL+END). As you know. You have to type Y for yes and N for no. .5 Now you can enter data on the screen. reporting or editing. 20. . If you want to quit dBASE without saving then you have to press ESC or CTRL+Q. data on a particular student is a record. Another method of saving a database is by pressing CTRL and W keys together (CTRL+W). a database file.

Enter a dBASE III PLUS command. you have to instruct dBASE III+ to make the A drive as the active work drive. 20. all subsequent commands will apply to that drive.DBF file. Command Line <C:>BIODATA Rec: EOF/5 NAME Anant Babloo Manju Sibu Soma SEX m m f m f AGE 25 13 30 12 8 Type a command (or ASSIST) and press the ENTER key.Note that when you save a database file in dBASE the computer gives an extension . This you can do by the LIST command.6 Since there are 5 records only in the database we are dealing with all the records are visible on a single screen. Enter file name: biodata Record# 1 2 3 4 5 . Fig. SET DEFAULT TO A: On selecting a work drive.e. i. If the file is on a floppy.List The screen will look like Fig. When all the records cannot come on a single screen the records scroll down and you cannot see the records in the beginning. . 20. list No database is in USE. This can be done by the following command: .DBF along with the file name. . While opening a file. In order to overcome this problem you have to use the DISPLAY ALL command.1 Viewing the Contents of the File After opening the file BIODATA you may like to see its content. dBASEIII+ assumes it to be a . The USE command assumes that the file is to be loaded from the default or active drive. rather than the C drive. 20.6.6. 143 . the drive from which dBASE was invoked.

until the user presses a key to continue.7 ADDING RECORDS Suppose some new students have taken admission in National Open School. Enter a dBASE III PLUS command.Display All command displays a screen full of records and pauses. display Record# 1 NAME Anant SEX m AGE 25 . . In order to do so you have to use the APPEND command. You want to add these student records to the existing file BIODATA. use biodata . it presents another blank record. 20. Once the data has been entered.7 20. Command Line |<C:>|BIODATA |Rec: 1/5 | | Type a command (or ASSIST) and press the ENTER key. Press the F1 key for HELP. Fig. This process continues till the user presses CTRL+END CURSOR   Char: Word: Pan: Home End ^  ^ INSERT Char: Field: Help: Ins ^N F1 DELETE Char: Word: Field: Del ^Y ^U Up a Field: Down a Field: Exit/Save: Abort: ^End Esc 144 . The APPEND command displays a blank record for data entry.The .

SEX AGE .NAME . What is the usefulness of the following commands: APPEND.9 TERMINAL QUESTIONS 145 . . Write True or False (a) The field name can be a maximum of 10 characters. 20. LIST. 20. (b) The maximum width for a character type field is 250. add records to an existing database and see the contents of a database. (d) Character field is used for mathematical calculation. We have also explained the different types of fields in a database. . 2. .8 IN-TEXT QUESTIONS 2 1. (e) A field name should always start with an alphabet. CREATE. . 20. (c) The width of a logical field is 2 digits. APPEND <C:> BIODATA Rec: EOF/5 | Fig. What are the different types of fields in dBASEIII+.8 WHAT YOU HAVE LEARNT In this lesson we discussed the concept of database and the software available to manage it. . Now you should be in a position to create a new database. 3. The different methods to invoke dBASE III Plus are discussed.

2. Date field.1. There are five types of fields in database. How do you add records a database? 20. FoxBASE. 2. Numeric. What are the different methods to start dBASEIII+ ? 1. Clipper 3. Each piece of information in database is called a Field. Create command creates a new database. Field is the smallest unit in a database. Numeric field and Memo field. Logic and Memo. The Append command displays a blank record for data entry. All the related fields for a particular event is called a Record. Explain in brief the following field types: Character field. Date. (a) False (b) True (c) False (d) True (e) True IN-TEXT QUESTIONS 2 1.10 FEEDBACK TO IN-TEXT QUESTIONS IN-TEXT QUESTIONS 1 1. 4. dBASE. List command displays all the records in a database. (a) True (b) False (c) False (d) False (e) True 146 . They are Character. 2. What are the advantages of dBASEIII+? 3.

personal license to use dBASE III + on one microcomputer or workstation.2 147 . nor do you have the right to copy or alter the software or printed materials. or trade secret laws. Dot prompt Fig. Enter a dBASE III + command. All Rights Reserved. non-transferable. You are legally accountable for any violation of the License Agreement or of copyright. 1985. In summary. 20. Ashton-Tate grants you a paid-up. dBASE III +. trademark. and Ashton-Tate are trademarks of Ashton-Tate You may use the dBASE III + software and printed materials in the dBASE III + software package under the terms of the dBASE III + Software License Agreement. 1986. You do not become the owner of the package.0 IBM/MSDOS Copyright © Ashton-Tate 1984.dBASE III + version 1. dBASE. dBASE III. Press the F1 key for HELP Command Line |<C:>| Type a command (or ASSIST) and press the ENTER key.

Before sorting a database you make sure that the database you want to sort is current: 21. 3 DATABASE ORGANISATION Information must be organized before you can make much sense of it. Imagine a situation where names in the directory are not arranged alphabetically.2 INTRODUCTION OBJECTIVES HOW TO START dBASE III PLUS? LESSON 21 ARRANGING RECORDS OF A DATABASE 21. 21. 1 INTRODUCTION Organizing a database means arranging individual records so that they appear in a sequence that makes a proper sense and helps you to work with database efficiently. The concept can be appreciated by taking an example of telephone directory.1 20. 148 . The elements of a database structure . type. There are two ways to organize records in database. One is INDEXING and the other is SORTING. 3.1 20. and size are all intended to organise within each record. 1 SORT Command The SORT command gives us the ability to copy the record and structure of a database to another database.field name. 2 OBJECTIVES At the end of this lesson you would be able to use the SORT and INDEX commands to organise records of a database differentiate between FIND and SEEK commands count the number of records in a database modify a database DELETE records in a database RECALL and REPLACE records in a database 21. Files can be arranged in either ascending order or descending order by using SORT command. This will create a mess and take much longer time to find a particular name in the directory. Sort command can be used in multiple fields for data arrangement.LESSON 20 INTRODUCTION TO DATABASE 1.

149 . 21. You have to give the command at the dot prompt: .USE BIODATA and press ENTER . 1 RECORD NO. The following examples show the forms of the SORT command. 21. Thus you have to give the command .DBF To see the contents of the sorted file give the following commands: . Let us consider a database file BIODATA. USE BIO. LIST The sorted file BIO.This SORT command creates a new database file. SORT ON fieldname TO new filename. whose structure is shown in Fig. 21. NAME SEX AGE 1 2 3 4 5 Anant Babloo Manju Sibu Soma M M F M F 25 13 30 12 28 Fig. DBF looks like as shown in Fig. But the new file contains records of the original database file only the order is different.DBF . SORT ON AGE TO BIO and press ENTER Here field name is AGE and the sorted file name is BIO.1 Suppose you want to sort the records in this file in increasing order of the AGE field.2 .

sort on age/d to temp 100% sorted . In this new file. The new file TEMP looks like as shown in Fig. because you have sorted the BIODATA.DBF.3 150 .2 Here you notice one thing that BIO. 21. the record numbers given by database is in a new order. Suppose you want to sort the file in descending order of the AGE field. list Record# 1 2 3 4 5 NAME Manju Soma Anant m Babloo Sibu SEX f f 25 m m 13 12 AGE 30 28 5 Records sorted Fig. list Record# 4 2 1 5 3 NAME Sibu Babloo Anant m Soma Manju SEX AGE m m 25 f f 28 30 12 13 5 records sorted Fig. Then you have to give the command SORT ON AGE/D TO TEMP . use biodata . use temp . But Age field is in sequence..DBF is a new file. use bio . 21. sort on age to bio 100% sorted . use biodata .3 .DBF to increasing order of the AGE field. 21.

2 INDEX command Index command can also be used to organise a data file.NDX). When you index a database. Unlike SORT command however INDEX does not permit the user to arrange the data in descending order. The index command does not create a new database file.dbf are arranged in ascending order as given in Fig. It can also be used to arrange the records in multiple fields. 21. The command structure for index command is .USE BIODATA . INDEX ON field name TO file name For example.dbf according to field age to the file bioage then the records in the file biodata. use biodata . list Record# 4 2 1 5 3 NAME Sibu Babloo Anant m Soma Manju SEX m m 25 f f 28 30 Fig 21. index on age to bioage 100% indexed . 3.4 AGE 12 13 5 Records indexed DIFFERENCE BETWEEN SORT AND INDEX COMMAND Sort Command Index command 151 . if we index the file biodata. you ask dBASE to create a separate and smaller file based upon designated fields in the database.21. It creates an index file for the database with a default extension (.4 .

NDX Faster than sort command Does not renumber records 21. you must give the command . USE BIODATA INDEX BIOAGE 152 . FIND 30 . If SEEK operates with a character string the string must be enclosed in a single or double quotes or square bracket Let us take some examples .3. index on age to bioage . The SEEK command like FIND command also works only with an index file. you must use quotes. INDEX ON AGE TO BIOAGE .3 FIND and SEEK Commands The FIND and SEEK commands both are used in indexed database.Creates a new database file Arranges the records in ascending and descending order File extension is . FIND operates with character strings. display Record# 3 NAME Manju SEX f AGE 30 Fig 21. When you SEEK command with strings. Consider the previous example. INDEX ON AGE TO BIOAGE . while SEEK operates with either character string or numeric values. to SEEK the NAME Manju. DISPLAY The screen will look like this . find 30 . use biodata index bioage . USE BIODATA INDEX BIOAGE .5 The FIND command will move the record pointer to the first record which matches with find query and the DISPLAY command will display it on the screen. USE BIODATA .DBF Slower than index command Renumbers records Does not create a new file Arranges the records only in ascending order File extension is . USE BIODATA . use biodata .

gives the total number of records in the active database file. count for age >13 3 records . index on age to bioage .6 The main difference between SEEK and FIND commands is that SEEK command will not work with macros but FIND command is used in macros.7 The COUNT command. use biodata .use biodata . USE BIODATA . count 5 records Fig 21. 153 . without any condition. COUNT FOR AGE> 13 The screen will appear as follows: .4 Counting Command The COUNT command helps in finding the number of records in the active database that meet a given condition. 21. DISPLAY The screen will look like this . SEEK 30 . seek 30 .. .3. use biodata index bioage . display Record# 3 NAME Manju SEX f AGE 30 Fig 21.

8 For displaying that particular record in a database give the command DISPLAY and if you want to continue the search give the command CONTINUE along with LOCATE command.3. LOCATE FOR AGE =25 The computer will prompt RECORD =1 Your screen will appear like this . USE BIODATA . continue 154 ..5 LOCATE Command The LOCATE command is used to find the records in a database which satisfy certain conditions. use biodata . The general form of LOCATE command is . locate for age=25 Record = 1 Fig 21. COUNT The computer prompts 5 RECORDS 21. use biodata . locate for age=30 Record = 3 . LOCATE [scope] FOR [condition] Suppose you give the command . Your screen will appear like this .

21.9 IN-TEXT QUESTIONS 1 1. Begin with opening the file. USE BIODATA .End of LOCATE scope Command Line ¦<C:>¦BIODATA ¦Rec: EOF/5 ¦ ¦ Enter a dBASE III PLUS command. Define the following command with a suitable example (a) COUNT (b) LOCATE 21. EDIT 5 CURSOR  Char: Word: Pan:  Char: INSERT Ins ^N F1 DELETE Char: Word: Field: Del ^Y ^U Up a Field: Down a Field: Exit/Save: Abort: ^End Esc Home End ^  ^ Field: Help: NAME Soma 155 . What is the usefulness of FIND and SEEK commands? 3. 4 MODIFYING A DATABASE Modifying a database is almost as easy as creating a database. You begin with an existing structure and want to modify the database by Inserting a new field Deleting an existing field Inserting a new record Deleting a record permanently Let us explain the steps by taking our previous file BIODATA. . What is the difference between SORT and INDEX command? 2. Fig.

the record pointer moves to the end of the file. This command is used to position a particular record.> is a condition.e. pressing Ctrl+W saves the changes and exits to the prompt.SEX AGE f 28 EDIT ¦<C:>¦BIODATA ¦Rec: 5/5 Fig. Let us consider the following example dBASE will display the 4th record in the file along with header.4.10 After making the desired changes. display Record# NAME SEX AGE 156 . .USE BIODATA . When the file is open the pointer points to the first record in the file and moves to the other records after a command has been given. 1 The Record Pointer How did the EDIT command display only the 5th record? This can be explained by the concept of a record pointer that is maintained for each file opened by dBASEIII+. which is to be displayed. with the LIST command. >] [<expr_list>] [FOR<expl. 21. For example. goto 4 . 21 . . use biodata . DISPLAY DISPLAY [ALL!RECORD<recordno. since it moves successively from the first record to the last record.. <expl.DISPLAY dBASE will display only the first record along with header which we have discussed earlier.>] [TO PRINT] where: <expr_list> is a list fields or expressions. the record on which the pointer is positioned currently) can be displayed by giving the command. DISPLAY. . The current record (i.

GOTO 5 This command will position the pointer on the 5th record. 2 EDIT Command Similarly. use biodata .11 The GOTO command followed by the record number moves the record pointer to a specified record. goto 5 . . Sibu m 12 Fig 21. To summarise. GOTO<expN> where <expN> is the record number.12 21. Save the changes by pressing <Ctrl>+<W>. using the EDIT command are: Open the file by the command USE File Name Access the record(s) to be modified. 4. . the steps involved in modifying a database. the record pointer moves to the 5 th record and displays it for modification. . Make the required changes in the records.4 . This command positions the record pointer at the required record and displays it for modification 157 . display Record# 5 . on giving the command EDIT 5. NAME Soma SEX f AGE 28 Fig 21.

>] [FIELDS<fieldlist>] [FOR<expl>] Where: <fieldlist> is a list of fields to be edited <expL. Now we open BIODATA by the command USE . REPLACE ALL Syntax: REPLACE [ALL] <field> WITH <expr> [FOR<expl>] 158 . depending on the form of the command. 21. 4.EDIT [ALL![RECORD]<record no.USE BIODATA . > is a condition.13 21. EDIT The screen looks like this CURSOR  Char:  INSERT Char: Ins Field: ^N Help: F1 DELETE Char: Del Word: ^Y Field: ^U Up a Field: Down a Field: Exit/Save: Abort: ^End Esc Word: Home End Pan: ^ ^ NAME SEX AGE EDIT f Soma 28 ¦<C:>¦BIODATA ¦Rec: 5/5 ¦ ¦ Fig. 3 REPLACE command The REPLACE command is used to REPLACE the contents of one or more specified field either the current record or all record. .

while one record is displayed at a time when EDIT is used.14 The difference between BROWSE and EDIT Command is that several records are viewed simultaneously using BROWSE. CURSOR  Char:  INSERT Char: Ins Field: ^N Help: F1 DELETE Char: Del Word: ^Y Field: ^U Up a Field: Down a Field: Exit/Save: Abort: ^End Esc Word: Home End Pan: ^ ^ NAME Anant Babloo Manju Sibu Soma SEX m m AGE 25 13 f 30 m 12 f 28 BROWSE ¦<C:>¦BIODATA ¦Rec: 1/5 ¦ ¦ View and edit fields. The BROWSE command also provides the option of displaying and modifying selective fields. 5 MODIFY STRUCTURE 159 . 21. BROWSE Immediately dBASE will display a screenful of records as shown in Fig. Once you make changes through BROWSE command you can save the changes and exit to the dot prompt by pressing Ctrl + W. USE BIODATA . 4. Fig. 21. 21. Consider the following example: . 4 BROWSE Command BROWSE command gives an option of adding new records.Where: <field> <expr> <expl> is the field to be replaced is the expression to replace the field is a condition.14 21.

Let us consider the following example. LIST 160 . digits and underscores Fig.15 . You should keep in mind that if the field widths are reduced. MODIFY STRUCTURE displays the structure of the database file as shown in figure 21.The MODIFY STRUCTURE command helps to change the structure of an active database file. The MODIFY STRUCTURE command also allows deleting fields or changing the field types and widths. The command that can be given to activate the printer is as follows: . Field names begin with a letter and may contain letters. Bytes remaining: 3987 CURSOR  Char: Word: Home End Pan: ^ ^  INSERT Char: Ins Field: ^N Help: F1 DELETE Char: Del Word: ^Y Field: ^U Up a Field: Down a Field: Exit/Save: Abort: ^End Esc Filed Name 1 NAME 2 SEX 3 AGE Type Width Dec Filed Name Type Width Dec Character 10 Character Numeric 1 2 0 MODIFY STRUCTURE |<C:>|BIODATA |Field: 1/3 | | Enter the field name. 6 MORE ON QUERIES Instead of giving the List to Print command with each and every query.15 21. SET PRINT ON . After adding the field to the file save the modified structure by pressing <Ctrl>+<W>. Hence changes to existing fields must be made with proper care. 21. the data in that field may be lost. the printer can be activated to print the command as well as the output of the command. The command: .

SET PRINT OFF 21. delete all 5 records deleted . Now delete all the records in the active database file BIODATA.FRM on logged disk. . use biodata . When the records are marked for deletion they are not transferred during copy and sort operation. You will find an asterisk (*) against the records marked for deletion. DELETE RECORD 5 <marks record 5 for deletion>.1 Deleting Records The delete command marks the current record for deletion. 1 records deleted The DELETE command also provides the following options: OPTION DESCRIPTION DELETE ALL DELETE FOR DELETE FILE ABC. Now we will discuss how delete command is used in different ways. list Record# 1 2 3 4 NAME *Anant *Babloo *Manju *Sibu m SEX m m f 12 AGE 25 13 30 161 .FRM DELETE NEXT 4 Mark all records for deletion Mark selective records for deletion Delete file ABC. Mark next 4 records for deletion.6. .To deactivate the printer the command is: .

use biodata . DELETE 3 . 21.17 21.6. 21. . Fig.5 . The records are first marked for deletion with the DELETE command. Fig.2 PACK Command This command removes records permanently from the database file. delete next 4 4 records deleted . Deleting records in dBASEIII+ is a two step process. PACK 162 . and then removed permanently from the file by PACK command Let us take the following example . Once packed a record cannot be recovered. *Soma f 28 Command Line ¦<C:>¦BIODATA ¦Rec: EOF/5 ¦ ¦ Type a command (or ASSIST) and press the ENTER key ( -+).16 In this example we delete the next four records from the active database file. Enter a dBASE III PLUS command. USE BIODATA . list Record# 1 2 3 4 5 NAME *Anant *Babloo *Manju *Sibu Soma SEX m m f m f AGE 25 13 30 12 28 Command Line ¦<C:>¦BIODATA ¦Rec: EOF/5 ¦ ¦ Type a command (or ASSIST) and press the ENTER key ( -+). Enter a dBASE III PLUS command.

3 RECALL Command The RECALL command is used to unmark those records that were marked for deletion with DELETE command. Open database can also be closed with the QUIT. 21. recall all 5 records recalled . Now we recall all the records marked for deletion in the active database file BIODATA. RECALL RECORD 4 . Notice that the RECALL command unmarks the records. which were marked for deletion earlier.6. 7 CLOSING AN OPEN DATABASE FILE The USE commands without file name closes an open database file. 21. CLOSE DATABASE and CLOSE ALL commands.Next if you give LIST command then you will not find record 3 in database. Like DELETE command. list Record# 1 2 3 4 5 . RECALL ALL Unmark record 4 for deletion Unmark the next 3 records for deletion Unmark all records within the database for deletion. use biodata . Enter a dBASE III PLUS command. OPTION DESCRIPTION . Command Line ¦<C:>¦BIODATA ¦Rec: EOF/5 ¦ ¦ NAME Anant m Babloo Manju Sibu Soma SEX 25 m f m f 13 30 12 28 AGE Type a command (or ASSIST) and press the ENTER key ( -+). RECALL has several forms. CLEAR ALL. . Fig.18 21. 163 . RECALL NEXT 3 .

Differentiate between EDIT and BROWSE commands. (i) stop (ii) use (iii) start (iv) none of the above (e) The modify structure command helps 164 .IN -TEXT QUESTIONS 2 1. 2. Bring out the uses of the following commands DELETE PACK RECALL REPLACE USE 3. you would use (i) continue (ii) list (iii) append (iv) use (c) Which of the following command physically remove the records (i) change (ii) modify (iii) pack (iv) none of the above (d) Which of the following command is used to close a database file. Choose the correct answer (a) Delete command (i) marks the record for deletion (ii) append the record (iii) change the number (iv) none of the above (b) To add record at the end of the database.

(ii) to remove the structure (iii) to name the structure (iv) none of the above 21.? Explain briefly.9 TERMINAL QUESTIONS 1. RECALL and PACK commands.(i) to change the structure of an active database file. But SORT command creates a new database file. Index command does not create a new database file. Now you should be in a position to count the number of records in a database and modify structure of a database. FIND operates with character strings. What are the different methods of data organisation. Define SORT and INDEX command with suitable example. 3. DELETE and PACK commands. EDIT. Files can be arranged in either ascending order or descending order by using SORT command. Example: . Write short notes on SEEK.10 FEEDBACK TO IN-TEXT QUESTIONS IN-TEXT QUESTIONS 1 1. 4. 2. 5. LOCATE FOR AGE=18 165 . But incase of INDEX command you can arrange the file only ascending order. 21. What are the different steps involved in modifying a database. COUNT FOR AGE> 11 that (b) The LOCATE command is used to find the records in a database which satisfy certain conditions. while using EDIT command? Define COUNT command with example. Example: . 21. 3. (a) The COUNT command helps in finding the number of records in the active database meet a given condition. 2. USE BIODATA .8 WHAT YOU HAVE LEARNT In this lesson we discussed the procedures of organising a database. USE NAME . FIND. GOTO. FIND and SEEK commands. while SEEK operates with either character string or numeric values. In this process we distinguished between SORT and INDEX commands. BROWSE and EDIT commands.

3 MULTIPLE FILE HANDLING In the previous two lessons we have discussed about the commands to manipulate and retrieve data from a single database file.2 OBJECTIVES After going through this lesson you should be in a position to explain the concept of multiple database understand work area relate more than two databases create a report file from a database print a report file 22. dBASE provides scope for handling up to 10 database files open at the same time and access data from them. It has to be put in a presentable format. PACK: Permanently deletes the records from the database file. 22. But at times we may need to combine data from different database files for purpose of manipulation and reporting.1 INTRODUCTION Many times we have to combine data from more than one file. (a) i (b) iii (c) iii (d) ii (e) i LESSON 22 HANDLING MULTIPLE FILES 22. In such situations we have to handle multiple databases. REPLACE: used to REPLACE the contents of one or more specified field USE: Closes the active database file.IN-TEXT QUESTIONS 2 1. This is called Multiple File Handling. which were earlier marked for deletion by DELETE command. 2. 3. This aspect of dBASE III Plus is possible through the report form facilities of a database. But BROWSE command displays all the records in the database file. 166 . DELETE: marks the record for deletion. RECALL: Unmarks the record marked earlier. EDIT command displays one a particular record that is the record at the cursor position. Another point is that the data contained in a database file is not suitable for presentation.

1 Characteristics of Multiple Files Before we discuss the procedure of handling more than one-database files let us look into the characteristics of multiple database files. The number of fields is same but type of fields is different. dBASE allots a work area for that file. we give the commands as follows: . Situation 1: The number of records in both database files dB1 and dB2 is the same. USE dB1 167 .SELECT workarea .3. When we use only one file. We may require updating of one or more fields in a file called the master file taking the data from another file called the transaction file.3 Selecting Work Areas for Different Files When a database file is opened by the USE command.3. 22. 22. Let us take dB1 as the master file and dB2 as the transaction file. dB1 and dB2. ii) selected fields from the records of dB1 and dB2. Situation 3: The number of records is different. Situation 2: The number of records in both dB1 and dB2 is same. But number of fields and type of fields is the same. This common field is called the Key Field. But when we use multiple files (up to 10 files).USE filename Suppose we have two database files. We may come across the following situations. we do not need to give any reference to the work area.3. dBASE assigns numbers 1 to 10 or characters A to J to these work areas.22. Situation 4: The number of records and number of fields are different. SELECT A . we have to specify the areas in which the different files will work. Let us start with two files (dB1 and dB2). So we take data from dB2 to update dB1. But there is at least one field which is common to both dB1 and dB2.2 Types of Operations in Multiple File Handling Let us look in to the type of work that we may require while handling two database files: We want to access data from both dB1 and dB2 at the same time. The SELECT command is used to allot work areas for different files in dBASE. We want to create a database file dB3 by combining i) all the fields in the records of dB1 and dB2. For allotting the work areas A and B for the two files. The general form of the SELECT command is . The number of fields and the type of fields are the same.

we give the commands as follows: . Then this field is referenced by writing as A-> STDNAME (note that when we refer to a field in the non-active file we prefix it with the work area allotted to the no-active file). This can be referenced simply as AGE (note that AGE is a field in the active file. Suppose in the example considered earlier if we give the command . the file dB2 is selected last and so it is the active file.4 ACTIVE AND NON-ACTIVE FILES When several files are in use by the SELECT command. Suppose you have a field by name AGE in dB2. SELECT 2 . USE dB1 . 22.SELECT non-active-file-name. The SELECT Command does not open a file but simply switches between the work areas. active by giving the command . In this case the file in the work area 1 is made active currently. since it is a syntax error. SELECT B . SELECT 1 . the file that is selected last is called the active file and other files are called non-active files. 168 .). 22.. When we allot work area to multiple files the file selected last becomes the active file.1 How to Switch the File Status from Active to Non-Active? You can make any non-active file. In place of dB1 and dB2 you can give any other file name. USE dB2 In the example we have taken two database files but you can take any number (up to 10) of database files.SELECT A The file dB1 in the work area 1 becomes active and the file dB2 becomes non-active. The symbol (->) 'a minus sign followed by a greater than symbol' is used to establish the relation between the non-active database file name and its field name. The USE command opens a file and a file that is once opened must not be again opened.4. Suppose you have a field by name STDNAME in the file dB1. For allotting the work areas 1 and 2 to the files dB1 and dB2. One must not give the USE command for making a file active. In the last example. Thus we see that the SELECT command enables us to access fields or data from as many as 10 database files. USE dB2 On the other hand we may allot numbers to the work areas.

dbf : dB2. CLOSE ALL .4. DISPLAY stdname If no alias names are given by the user.2 ALIAS Names for Database Files dBASE has got a facility to give an alternate or an ALIAS name to a database file dB1.SELECT A .4. we can display the field by the command .USE dB1 ALIAS biofile If at any time you want to make the file dB1 active you can give the command . USE dB1 . Select Area : B. you can display any particular field from a non-active database can by giving command as follows: .3 The SET RELATION TO Command 169 .dbf alias : dB1 alias : dB2 Fig 22. DISPLAY alias name ->field-name or . Suppose you give the following commands: .22. SELECT B . DISPLAY STATUS On the monitor you will see the status as follows: (This command closes all files) (This will select work area B) (This will assign work area B to file dB2) (This will select work area A) (This will assign work area A to file dB1) Currently Selected Database Select Area : A. USE dB2 .1 22. For the field STDNAME in the active file dB1. Without making a file active. dBASE will assume the filename itself as the alias name. DISPLAY work area name -> field-name (if you have not given an alias name) (if you have given an alias name) You already know that the symbol (->) is used to establish the relation between the database name (or its alias name) and its field names. SELECT A . The SELECT command is written as follows: . Database in Use: A Database in Use: A : dB1.SELECT biofile The above command automatically puts the file dB1 in the work area A and makes it active.

USE dB2 .2 and Fig.2 . Enter a dBASE III PLUS command.This command is used to link two database files with or without a common field between them. Suppose you have to link two database files dB1 and dB2. 22. 22. Enter a dBASE III PLUS command. Command Line CITY Cuttack Orissa Delhi Madras Bombay Chandigarh STATE SALARY 2500 Delhi Tamilnadu Maharastra Punjab 8000 1350 3000 1280 ||<C:>|| dB1 || Rec: EOF/5 || || Type a command (or ASSIST) and press the ENTER key ( ). USE dB1 . Fig.3 170 . Command Line NAME Anant Babloo Manju Sibu Soma AGE 25 23 30 22 28 <C:>dB2 Rec: EOF/5 Type a command (or ASSIST) and press the ENTER key ( ). 22. .3 respectively. Fig. LIST Record# 1 2 3 4 5 . The contents of these two are as shown in the Fig. LIST Record# 1 2 3 4 5 . 22.

Which command is used to select a work area in dBASE III+? Differentiate between active and non-active files. 5. Command Line CITY Cuttack Orissa Delhi Madras Bombay Chandigarh STATE SALARY 2500 Delhi Tamilnadu Maharastra Punjab 8000 1350 3000 280 NAME Anant Babloo Manju Sibu Soma AGE 25 23 30 22 28 <C:>dB1 Rec: EOF/5 Type a command (or ASSIST) and press the ENTER key ( ). Fig. We will now link the two files using this common feature between them. B->AGE The listing of the combined file looks as shown in the Fig. STATE. Choose the correct answer: (a) What is the maximum number of work areas that can be used in dBASE 171 .SELECT B . In the above case all the fields and all the records are listed. SALARY. 2. USE dB2 . The only relation which we see between these two files is that there is one to one correspondence between the record number of the two files. LIST CITY. USE dB1 .4 IN-TEXT QUESTIONS 1 1.In this example the two files have the same number of records but completely different field types. 4. The commands are given as follows: . SELECT A . Record# 1 2 3 4 5 . B->NAME. 3. How many databases can be used simultaneously in dBASE III+? Give the name of the first work area used in dBASE III+. 22.4. Enter a dBASE III PLUS command. 22. SET RELATION TO RECNO( ) INTO dB2 .

CREATE REPORT dBASE responds to the above command by displaying the following message: Enter Report File Name: You have to type the filename BIO and press ENTER key. 22.FRM. the report is printed as it is displayed on your screen. Before the command is used.6 HOW TO GENERATE THE REPORT FORM? Open the file BIODATA and give the CREATE REPORT command. or you can use the RENAME command rename the file extension. Such a task is possible through the report form. the REPORT FORM filename command is used to reproduce the report on your screen.VUE files are used with the CREATE or MODIFY REPORT command. USE BIODATA . We cannot take a print out and submit it straight away. Instead of the word CREATE you can use the word MODIFY also.(i) 20 (ii) 10 (ii) „A‟ (iii) 5 (iii) „A-J‟ (iv) 9 (b) The first work area in dBASE is referred as (i) W -area (iv) none of the above 22. If you add the TO PRINT clause to the REPORT FORM command. The default extension given a report form file is . you can assign a different extension upon creation. We also know how to link two files. However. Report form files are created and modified with the CREATE or MODIFY REPORT command. Both . Once designed. a database file must be in use.DBF and . The result we generate has to be presented in a suitable form. Fig.5 REPORT FORM So far we have covered listing and modification of raw data. The field characteristics within the selected database file are used to help you design your report form.5). as we will see below. 22. . dBASE displays a menu screen with five items in the main menu as follows (see. Options Groups Columns Locate Exit 172 . But in all the cases discussed so far the result we get is not formatted in a presentable manner.

6. Options Groups Columns Locate Exit 01:43:57 pm Page title Page width (positions) Left margin Right margin Lines per page Double space report Page eject before printing Page eject after printing Plain page 80 .FRM . 22. We will discuss about each of these in detail. 22. 8 0 58 No Yes No No CURSOR  Char: Word: Pan:  INSERT Char: Ins ^N F1 DELETE Char: Word: Field: Del ^Y ^U Up a Field: Down a Field: Exit/Save: ^End Abort: Esc Home End ^  ^ Field: Help: CREATE REPORT |<C:> | BIO. .5. | Leave menu . | Position selection bar - Enter up to four lines of text to be displayed at the top of each report page. They are discussed below. | Opt: 1/9 Select . In the menu item OPTIONS there are 9 sub-items as shown in Fig 22. By default the sub-item PAGE TITLE is highlighted.1 OPTIONS There are nine sub-items under the menu item OPTIONS.5 173 . Fig.By default the menu item OPTIONS is highlighted.

4. By default a page is skipped before a report is printed.6. The titles can be up to lines of text. Summary report only: The default option under this item is NO. Default is single space. 5. 2. Page Title: By default the cursor is over the page title item.6). The default is 8 characters. Left margin: In this option you can specify the number of characters required as left margin. Plain page (Y/N): Used to suppress/display page number and date. Number of Lines/Page: Used to specify the number of lines on every page of the report. This includes all records in the report. The option NO prints the groups together. 7. The default is 80 characters. 22. The default is NO which suggests that page number. Page Eject before Printing (Y/N): Used to skip to a new page before printing.6. page title and date are displayed on each page. Group heading: This let you enter a report heading that is displayed as each new group is encountered and displayed. Page width: This is used to specify the number of characters to be printed on each line of the report. The key field is selected in the COLUMNS menu selection. 174 . This causes a form feed after each group is printed. If you change it to YES detail information is not provided and only subtotals are provided. 4. The default is 0. By typing Y (for Yes) you will get the page title only on the first page. 1. 8. There are six sub-items under the menu item GROUPS. Page Eject after group: YES. 22. The default is 58 lines. New groups are started when a new value is encountered.2 GROUPS After setting the above options now let us take the cursor to the second menu item GROUPS by the right arrow key. 9. By default it does not skip a page after a report is printed. 3. The contents of the screen will change as shown in Fig. Double Space Report (Y/N): Used to specify double spacing in the report. This item groups the records having a common value in a key field. But the page number and date will not be printed. 3. each line can be up to 60 characters. Page Eject after Printing (Y/N): Used to skip a page after the report is printed. 6. Each of them is described below. 2.1. Right margin: Used to specify the number of characters required for right margin. Group on expression: This sub-item is highlighted by default (see Fig. 22. On pressing the control key CTRL a window opens up by the side of the option menu box where you want to enter titles of further report.

5. Sub-group on expression: This selection lets you specify a secondary level of grouping for subgroups within groups. Like the main group, sub-groups should also be indexed or sorted. 6. Sub-group heading: Lets you enter a report heading that is displayed as each new sub-group is encountered and displayed.

Options

Groups

Columns

Locate

Exit

02:02:46 pm

Group on expression Group heading Summary report only Page eject after group Sub-group on expression Sub-group heading No Yes

.

. CREATE REPORT ¦<C:>¦ BIO.FRM . ¦ Opt: 1/6 Select . ¦ Leave menu -  ¦ .

Position selection bar -

Enter a field or expression on which to break for the first level of subtotals.

Fig. 22.6

22.6.3 COLUMNS Now let us discuss the menu item COLUMNS. You can select this item by the right arrow key. The screen will be displayed like Fig. 22.7. There are five sub-items under COLUMNS. Each of them is discussed below. 1. Contents: Enter the field name for each column. You can press ENTER or F10 key to display a field list. Select and return to the Column menu with the Right or Left Arrow key. 2. Heading : Lets you enter up to four 59-character lines as column headings. 3. Width: The column widths default to the field width or heading width, whichever is larger. You can modify the width by typing a new field. 4. Decimal places: Uses the file structure value. If you enter a smaller number, the displayed result is rounded. Only applies to numeric fields. 5. Total this column: The default is to print the total at the bottom of the report. Type NO to suppress printing.

175

Note that the column specifications must be given for each column. As you fill the items for the column details, you will find that a REPORT FORMAT box is opened at the lower end in the position of the cursor control menu. This shows the column heading and the column formats. The following symbols are used to represent the structure of the report as you enter it.

Options

Groups

Columns

Locate

Exit

02:19:26 pm

Contents Heading Width Decimal places Total this column

.

0

________Report Format_______________________________________________________ >>>>>>>

CREATE REPORT

¦<C:>¦

BIO.FRM .

¦ Select -

Column: 1 .

¦

¦

Position selection bar -

Prev/Next column - Pg Up/Pg Dn.

Enter a field or expression to display in the indicated report column. Fig. 22.7 22.6.4 LOCATE The locate menu is provided to help with column definition. This menu item lists the selection that you made using COLUMNS menu. If you do not define the columns earlier the screen will display like Fig. 22.8.

Options

Groups Columns

Locate

Exit

06:25:04 pm

No columns defined

176

________Report Format_______________________________________________________ >>>>>>>

CREATE REPORT

¦<C:>¦ BIO.FRM .

|

Opt: 1/1 .

¦

¦ .

Position selection bar -

Select -

Leave menu - 

Step to any column immediately by selecting the column expression. Fig. 22.8

22.6.5 EXIT MENU The Exit Menu box has two items as shown in the Fig. 22.9. When SAVE is highlighted, press the CTRL key. The Report File BIO.FRM is now saved and can be used for printing the report. The option ABANDON does not save the report file.

Options

Groups

Columns

Locate

Exit

03:06:53 pm

Save Abandon

________Report Format_______________________________________________________ >>>>>>>

CREATE REPORT ¦<C:>¦

BIO.FRM

¦

Opt: 1/2

¦

¦

177

Position selection bar -

. Select -

. Leave menu - 

Exit and save changes. Fig. 22.9 22.7 PRINTING THE REPORT

To print the Report for selected records a FOR clause or a WHILE clause can be added to the REPORT command. For saving the Report in a .TXT file, you give a TO filename clause to the REPORT commands as shown below: .REPORT FORM BIO TO REPO.TXT The bio report is now stored in the REPO.TXT file. This is an ASCII file and you can see by giving the TYPE command from DOS prompt.

IN-TEXT QUESTIONS 2

1. Which command is used for report creation? 2. What are the sub-menus of COLUMNS menu? 3. Choose the correct answer (a) The extension name for Report file is (i) .NDX (ii) .DBF (iii) .FRM (iv) .PRG

(b) How many items dBASE displays in the main menu of Report generation? (i) 2 (ii) 7 (iii) 5 (iv) none of the above

22.8

WHAT YOU HAVE LEARNT

In this lesson we covered the basic commands and techniques for displaying data in a formatted report. The first part of this lesson discusses the multiple database concepts like file handling, work areas and the commands related to multiple database. The second part covers report generation from a database file.

22.9

TERMINAL QUESTIONS

178

1. 2 3 4

What are the characteristics of multiple files? How do you switch the File Status from Active to Non-Active form? What is the usefulness of SET RELATION TO command? Explain with example. What are five items or menus while creating a report? Explain in brief.

22.10

FEEDBACK TO IN-TEXT QUESTIONS

IN-TEXT QUESTIONS 1 1. 10 databases 2. The first work area in database is A. 3. SELECT command 4. The file that is selected last is called the active file and other files are called non-active files. 5. (a) ii (b) ii

IN-TEXT QUESTIONS 2 1. CREATE or MODIFY commands are used in report creation. 2. Contents, Heading, Width, Decimal places, Total This Column are five sub menus of COLUMNS menu. 3. (a) iii (b) iii LESSON 23 PROGRAMMING CONCEPT

23.1

INTRODUCTION

By now we are familiar with various dBASE commands and how they are used. Let us consider another use of dBASE namely in the area of programming. In this lesson we will discuss some programming constructions in general sense. We will also point out the situations in which they are used. We had given a brief idea about the concept of programming while dealing with the lesson on 'Software' in the module 'Computer Fundamentals'. Here we will discuss programming in the context of dBASE III Plus.

23.2

OBJECTIVES

After going through this lesson you should be in a position to understand the need of writing programs identify the important programming commands in dBASE III + write programs in dBASE III +

179

The complete DO WHILE statement has the form: 180 . The loop command is used to return control directly back to the DO WHILE command. As you know program is a set of instructions given by the user to the computer for solving a problem. 23. When we give a single dBASE command to execute the file all the dBASE commands contained in the file are executed. Within these categories we see a number of commands.3 WHAT IS THE NEED OF PROGRAMS? In the previous three lessons you have learnt so many commands in dBASE. 23. or until an ENDDO or EXIT command is encountered. Endcase. In the programming mode it is possible to write any number of commands together in single file. Input Commands and Output Commands.1 DO WHILE COMMAND This command is used when a particular segment of commands have to be executed repeatedly. We will discuss the important ones only in this lesson. Otherwise We will now consider the general forms of these commands. Hence we need to develop computer programs and store it in a file.identify the types of files created by dBASE III + 23.4 CONTROL COMMANDS The important commands under this heading are Do While Exit If … Else…Endif Loop EOF( ) Do case. These commands are given to the computer step by step. We give a second command only after the first command is executed. The first line of the DO WHILE statements has the form: DO WHILE logical expression Continuous operation is sustained as long as the expression is true.4. Thus it is a looping command that sustains operation while some condition is true. Now let us discuss some of the important commands that are used in programming. Another factor is the chance of committing mistakes while keying in the commands. In such situations writing the same set of instructions every time is time consuming. But many times the user has to give a set of instructions repeatedly to solve a particular problem. They can be broadly categorised into three areas: Control Commands.

This shows that natural numbers increase by 1 at a time.4. The command line S=S+N shows the sum of numbers. When N=2. Thus a loop is formed.+100). S=0 N=1 DO WHILE N<101 S=S+N N=N+1 ENDDO In the above example we assume that S=0 and N=1. Suppose you have to fine the sum of natural numbers 1 to 100. (That is 1+2+3+4+………. The process stops at the ENDDO command.2 EXIT COMMAND 181 . obviously the sum of numbers will be S=S+N = 0+1= 1. S= 1+2=3. N stands for natural number which takes value from 1 to 100. S is the sum of the numbers. Every time a sum is obtained by the statement S=S+N. In order to do this we take two variables S and N. it repeats the summation process till N<101.DO WHILE expression (Command lines) ENDDO Now let us consider an example using the do while command. 23.. Let us interpret the command line N=N+1. The process is repeated till the expression N<101 is true. S=3+3=6 ………… and so on. Here the role of the DO WHILE command is that. N takes the next value N=N+1. When N=1. When N=3.

Let us consider the following example: Do while N < 51 S=S+N If N = 10 Exit Endif Enddo The exit statement completely exits the control from the loop when the value of N = 10 and immediately it stops execution following the ENDDO statement. 23.3 The IF…ELSE…ENDIF Commands The IF…ELSE…ENDIF clauses allows a program to make decesions while it is running. which is always the last line in a DO WHILE statement.The exit command transfers control from the DO WHILE loop to the command line following the ENDDO statement.4. The IF command means the same thing that it does in English: IF this is the case THEN do this ELSE do not instead. IF <condition> <commands…> [ELSE] <commands…> ENDIF 182 .

is used with several commands including DO WHILE. In that case the loop statement is used as shown below: Do while logical-expression ……………….F You can also go to the end of the file with the COUNT command.Where <condition> is a valid dBASE logical expression. Enddo 23. When an end-of-file condition exists EOF( ) returns a true value. (command lines) …………….GO BOTTOM .4. (If you forgot to include the ENDIF command.) 23. Otherwise it shows a false value.. and IF (We will discuss these commands later).5 EOF( ) Command The EOF statement. Sometimes it may be required to stop executing some of the statements at the lower end of the loop body and transfer the control to the beginning of the loop. which stands for end of file. dBASE will not give you any error message.. If condition Loop Endif ……………. and ENDIF is the command required to close the IF clause. your program will just behave in a strange and unpredictable manner. Let us consider the following example . (command lines) ………………. Going to the bottom of a file with GO BOTTOM does not position the record pointer to the end of the file. 183 .. Instead.USE FILENAME .4 LOOP COMMAND When the loop command is executed the control passes back to the command line following the DO WHILE command. ? EOF( ) . DO CASE.4. ELSE is an optional branch to alternative commands.

. the second CASE statement is never evaluated. Although it is true that X is equal to five.6 DO CASE . dBASE performs all commands between that CASE statement and the next CASE statement. (command lines) CASE………. (command lines) CASE X = 2 ………………. 184 . the output from this routine is simply X is less than ten. If a CASE statement is true. X=5 DO CASE CASE X < 10 ? "X is less than ten" CASE X = 5 ? "X is equal to five" ENDCASE However. In a DO CASE clause. all remaining commands and CASE statements up to the ENDCASE command are ignored completely. ENDCASE. only the first alternative that evaluates to true is processed. ENDCASE Let us consider the following example. ……………….4. This process continues till a true CASE is found or the ENDCASE statement is reached. Each CASE statement is followed by one or more command lines. If a CASE statement is false the command lines are ignored and the control passes to the next CASE statement. The CASE statement is used to check for a specific condition. AND OTHERWISE COMMANDS The DO CASE Command is used when only one option out of several alternatives (That is several CASEs) is to be selected..23. DO CASE CASE X = 1 ……………… ………………. In other words. the alternatives in the DO CASE clause are mutually exclusive.

OTHWERWISE: It is an alternative statement. 2. PROGRAMMING THE PROMPT The optional prompt can be surrounded by quotation marks. Characteristics of ACCEPT Command 185 . Give three examples of control commands. When do you use the DO CASE command? 23. The syntax for the ACCEPT command is: ACCEPT [<prompt>] TO <memory variable> Where <prompt> is optional and <memory variable> is the name of the character memory variable that will store the user's entry. 23. IN-TEXT QUESTIONS 1 1. apostrophes. which are used to get data into a dBASE program. just use different characters for the outside delimiters: ACCEPT "What's your name" TO Name The prompt itself can be stored in a memory variable. the stored memory variable has an ASCII value of zero and a length of zero. which is used when none of the CASE statements are true. Whatever you type is stored in a memory variable. The data stored in the memory variable can be from 1 to 254 characters in length.1 ACCEPT Command The ACCEPT command presents a prompt on the screen and waits for the user to respond by typing some text and pressing ENTER key. If the user presses the ENTER key without typing any character.5. or brackets. The examples below are equivalent: ACCEPT "Enter your name" TO Name ACCEPT 'Enter your name' TO Name ACCEPT [Enter your name] TO Name To embed an apostrophe or other character in the prompt. What is the usefulness of EXIT command? 3.5 DATA INPUT COMMANDS IN dBASE Now we will discuss some input commands.

Any data entered via the ACCEPT command can be used for macro substitution.col as „at row number. 2. 23. Let us consider the following example: @ 7.1. use the @…. To restrict the size of the memory variable character string. apostrophes. INPUT “Enter value for the principal” TO principal The computer will display the prompt on the screen and will wait until you enter the value for the principal variable. It accepts only a single keystroke and does not require the ENTER key to be pressed. 23. use the VAL or CTOD functions.40 GET name 1 2 186 .5. The row-column notation starts at 0. The optional prompt can be enclosed in double quotation marks. The SAY and GET statements are used individually or in combination with @ row.READ command. 23. 5.3 WAIT COMMAND The WAIT command suspends processing of a program and waits for the user to press any key.10 SAY “What is your name?” @ 7.5. The syntax for the INPUT command is: INPUT [< prompt >] TO < memory variable > Where <prompt> is an optional character string enclosed in double or single quotation marks or brackets and <memory variable> is any valid memory variable name.col.0 which is the first row and first column on the screen. INPUT “Enter your age” TO Age INPUT „Enter your age‟ TO Age INPUT [Enter your age] TO Age INPUT [Enter your age] TO Age Let us consider another example to get data into the program through INPUT command.4 @ ROW. You can think of @ row.2 INPUT COMMANDS INPUT command is usually used to enter numeric data from the user. To convert the character data entered via the ACCEPT command to numeric or date data. Therefore. COLUMN COMMAND The symbol @ followed by row and column position used to position text at a specific row and column location on the screen. column number‟. rows are 0-24 for a 25 line screen and columns are 0-79 for a 80 column screen. ACCEPT will work with character strings of any length up to 254 characters. 4. 3. or brackets.

7 dBASE COMMANDS AND FUNCTIONS Several different types of files are created and used by dBASE III Plus.TXT . BROWSE.3 4 5 @11. EDIT.DBF .SYS . column 10 on the scr een.MEM . We give a description for each file type listed above. 23.LBL .10 SAY “PIN number?” @11.QRY . Line 5 contains READ command which reads your typed response to the GET statement into the specified field of the database in use. Other files. 23.40 GET PIN number READ In this example.NDX .BAK . Let us discuss some important files and their extensions.FRM . line 1 displays the question “What is your name?‟ at row 7.SCR .DB CONFIG. Examples are APPEND.CAT CONFIG. Line 2 allows data entry from the keyboard into name field of the database in use. 187 . etc. LIST.6 OUTPUT COMMANDS These are some of the important commands used in dBASE in the programming mode in addition to all dot prompt commands we have used earlier. they are assigned different three-character extensions. They are: Backup files Catalog files dBASE configuration file System configuration file Database files Database memo field file Report form files Label form files Memory variable files Database index files Command files Query files Screen files Standard data (or text) files View files .DBF.VUE When the files are created by dBASE.PRG .FRM . like text files and report form files are created by dBASE. like CUSTOMER. Line 3 and line 4 are similar to lines 1 and 2.

DBT file.BAK extension. 6. which speeds up dBASE III operation by letting it work in memory buffers rather than having to read and write information to your disk during sorting and listing. The REPORT commands are described in lesson 22. CHANGE. It can also contain a command line that causes automatic execution of a command file. index Files.DBF): A standard database file is created and saved using te CREATE command. 8. Although memo fields use a minimum of 512 bytes in the .FRM): The CREATE/MODIFY REPORT command helps you to create and save report format files that control the display and printing of data. Backup (. Database (. or EDIT by pressing Ctrl-Home at the begining typing text into a memo field. The catalog file is established with SET CATALOG TO filename before file creation activity is started. including function key values and SET functions. Report form (. an auxiliary file having the extension . they only occupy 10 bytes in a database file. 2.1. Catalog (. Memo file (. Databases can contain as many as 128 memo fields. System Config (CONFIG. 5.000 characters. the previous version of the modified file is kept with a . 188 . BROWSE. BAK): Backup files are automatically created as a safety measure when an edited version of a text file is saved. if you use the MODIFY COMMAND FILENAME statement to change a file. Memo files are accessed when a database is being edited with APPEND.SYS): This file is used by DOS when you turn on your computer. etc. are controlled by this file.LBL): The CREATE/MODIFY LABEL command helps you create and save label formats files that control the display and printing of data. It contains one or more commands that control dBASE operation.DBT): When a database file contains memo (text) fields. dBASE Config (CONFIG. This happens when you press CTRL-W to save (write) your modified version. Label from (.DBT is created to contain the memo fields .CAT): A catalog of filenames. 3. including 15 within dBASE III applications. including databases. is created as files are created or put into use. Each memo field can contain up to 5. It lets you have 20 files open at the same time.DB): This file is used by dBASE when it is started. 7. press Ctrl-End to return to the data entry mask. It also creates 15 buffers. Normal defaults. For example. 4.

Memory Varible (. 13. . 2. 11. Changes to the contents of index files change the database file. What is the difference between INPUT and ACCEPT commands. These are pure ASCII files and are transferable (transportable) between different computer and operating systems. 14. such as WordStar‟s Mail Merge. The resulting file has the extension .MEM ) Memory files are created when memory variables are written to disk using the SAVE command. Used to call all related files with a single command. The CREATE/MODIFY VIEW command is used for this purpose. 12. Give the extension of the following database files: Program File Memo File View File Back up File 189 . Screen (. which list selected field names and relations. Index (. Records retain their original record number. The CREATE/MODIFY QUERY command is used. The CREATE/MODIFY SCREEN command is used.TXT file is created when information is displayed when the SET ALTERNATE TO filename and SET ALTERNATE ON commands are in effect.QRY): A query file establishes a filter that restricts display to specific records that meet some established condition. Command files are created by the dBASE MODIFY COMMAND.NDX) An index file is created from an existing database file. The resulting file may be used by other programs. which are refereed to as "key" fields. 10. Standard Data (.9. Query (. The records within an index file are sorted (rearranged alphabetically or numerically) on one or more specified fields. View (. Procedure (or command file) (.VUE): Contains the name of related database files and related index and format files.TXT): A standard data or text file is created by copying a database file with COPY TO filename SDF or DELIMITED. IN-TEXT QUESTIONS 2 1.SCR): A screen file is used to create or edit screen format files.PRG) A procedure or command file is created and saved using the dBASE full-screen editor or some other text editor.MEM which allows you to save memory variables to disk. 15. and then clear memory to make room for more memory variables.

If … Else…Endif 2. These are control commands. . 4.23.BAK 190 .MEM . 23. Write a program for finding the sum of natural numbers between 1 to 10. INPUT command is usually used to enter numeric string whereas ACCEPT command is used in character string.10 FEEDBACK TO IN-TEXT QUESTIONS IN-TEXT QUESTIONS 1 1. 2. Write a program for finding prime numbers between 1 to 100. The DO CASE Command is used when only one option out of several alternatives (That is several CASEs) is to be selected. Write a program for printing Pay -slips using INPUT and ACCEPT commands. 2. . We have provided examples so that you can develop programs in dBASE yourself.PRG . 3.VUE . Do While.9 TERMINAL QUESTIONS 1. IN-TEXT QUESTIONS 2 1. In this context we discussed three types of programming commands. 23. input commands and output commands. Exit. The exit command transfers control from the DO WHILE loop to the command line. Write a program for simple and compound interest using DO-WHILE command. The important commands available and their syntax for use in practice are discussed.8 WHAT YOU HAVE LEARNT In this lesson we discussed the need for programming in dBASE. 3.

A good operating system should have the following features. 5.2 OBJECTIVES At the end of this lesson. 2.1 INTRODUCTION When the computer starts. explain the concept operating system 191 . Accept input from the user through the keyboard or mouse. such as. Store the output data or programs written on the computer in storage device. you would be able to. Communicate the message from the system to the user through the VDU.Disk Operating System (DOS) 5. 1. Help programs to perform input/output operations. An Operating System is a set of programs that help in controlling and managing the Hardware and the Software resources of a computer system. Print or display the result of a program on the printer or the screen. Help in the loading of programs and data from external sources into the internal memory before they are executed. it starts the operating system that takes the control of the machine.

passes the control on to it. DOS provides features essential to control hardware devices such as Keyboard. It is a set of computer programs and also known as DOS (Disk Operating System). the ROM bootstrap loader attempts to read the Boot record and if successful. Disk Devices. Then it tests the RAM memory. Basically. The instructions/programs in the boot record then load the rest of the program. (a) Loading of DOS The BOOT Record into the computer memory loads DOS.COM. and check whether peripherals connected to the computer are working or not. Screen. DOS translate the command issued by the user in the format that is understandable by the computer and instruct computer to work accordingly. Printers. After the ROM boot strap loader turns the control over to boot record.3 DISK OPERATING SYSTEM As the name suggests. The main functions of DOS are to manage disk files. allocate system resources according to the requirement. It also translates the result and any error message in the format for the user to understand. The system start-up routine of ROM runs a reliability test called Power On Self Test (POST) which initializes the chips and the standard equipment attached to the PC. DOS is the medium through which the user and external devices attached to the system communicate with the system. Modems and programs. Once this process is over. BOOT Record in turn is triggered by ROM program already there in the computer. If these two are found. the operating System is used for operating the system or the computer.COM and IBMDOS.COM. they are loaded along with the DOS command interpreter COMMAND.discuss the functions of operating system understand the procedures of loading operating system into the memory use file management features of operating system create separate locations for logically related files copy files from one computer to another use Windows for File Management 5. 192 . the boot tries to load the DOS into the memory by reading the two hidden files IBMBIO.

If your PC includes a hard disk. The floppy disk drives are assigned alphabets A and B.4 COMPUTER FILES IN DOS A file may contain a program or any other kind of information. using the complete name (primary name and extension. whereas the hard disk drive is assigned the alphabet C. Number and Hyphen). Primary name can be linked to proper name. Using extensions can be an excellent way of naming a file so that it can be identified easily.Exe Employee Employee. are to be separated by a dot (. with the period separating them can only refer the file). . it acts by executing the required routines/commands or by searching for the required routine utility and loads it into the memory.COMMAND. DOS permits the user to assign a name consisting of two parts to a file . the drive would be A and if it has two.COM contains routines that interpret what is typed in through the keyboard in the DOS command mode. Primary name can be of a maximum of eight characters consisting of Characters. which is optional. besides a FDD (Floppy Disk Drive). Exe Dbf DOS has a way of showing which disk drive is currently active. if any. Alphabets. the drive names would be A and C. 5. Examples: Filename Employee Primary Name Employee Separator Secondary Name Employee. they would be termed as A and B. By comparing the input with the list of command. if the hard disk is active. once the extension is specified. then it implies that the first floppy disk drive is active.5 DIRECTORY STRUCTURE IN DOS 193 . Data as well as instructions reside in a file stored in a disk. whereas extensions are like surnames of people. though optional.Dbf Employee . a file must be given a name that can be used to identify it. Where as the DOS prompt would be C.primary and secondary names.). However. Generally. and the Secondary name should consist of three characters. Using an extension with the file name is preferable. 5. If your PC has a single floppy drive. If the prompt is A. The primary name and the secondary (or extension) name.

These files contain codes and other information that is necessary to make the computer application operational. Thus. Otherwise. Therefore. a file name corresponds to a tree leaf.bat LEAVE INSURANCE GPF PENSION LOAN The directory/sub-directory is represented in bold letters. Sample of Directory Structure ROOT Command.com (Personal) Autoexec.The files in the computer come from various sources. which can make it difficult to locate specific files.bat (Accounts) Pk. Directory is just like a file folder. hence the name ROOT DIRECTORY. The names of all the files created in a disk are stored in its directory. which in turn may contain folders. The file cabinet here is the ROOT DIRECTORY. The general analogy is with a file cabinet containing a number of drawers. Of course. DOS files are organized in a hierarchical or an inverted tree-like structure. 194 . The content of these folders is the needed information. there will be hundreds or even thousands of files in the computer. Before long. but a file name is the furthest you may descend down the (inverted) tree of directories and files. Directories can contain other directories. which contain all the logically related files. Some files come with DOS. the folders are SUBDIRECTORY and the information in these folders may in turn be classified as FILES. there may be sub-directories of sub-directories. A directory within another directory is called a sub-directory. the large number of files that get created for various purposes in a disk can make the directory huge and difficult to view and manage. DOS enables the user to organize the files in a disk into directories and sub-directories in a hierarchical structure. the drawer is INDIVIDUAL DIRECTORY. a sub-directory to a branch. the directory to the trunk. and the root directory to the root of the tree. while other come with publications such as a word processor.

the ROOT DIRECTORY (\) is the initial working directory. DOS indicates which directory you are in by displaying the directory's name in the command prompt. Knowing which directory is current helps you find files. as shown in the following figure: C:\ NOS ACCOUNT SALARY 195 .6 DIRECTORY COMMAND The content of each of the sub-directory cannot be viewed unless it is made active. and to move from one directory to another more easily. The directory. For example. Typically. For example. By itself.5. The names of the subdirectories at adjacent levels are separated by backslash (\). the user is in at any point of time. is called the WORKING/PRESENT/CURRENT directory. or a sub-directory is specified as part of the DIR command. 5.LET file in the LETTER subdirectory of NOS directory.7 USING PATH TO SPECIFY THE LOCATION OF FILES A path is the route that leads from the root directory of a drive to the file you want to use. the following command prompt indicate that you are in the DOS directory: C:\DOS>. the DIR command is applicable to the working/present directory. DOS must go from the ROOT (\) directory through the NOS directory to the LETTER directory. to access the NOS. The entire specification of directory from root is called a PATH. while specifying the path to be followed while traveling to a sub-directory. Doing either of these requires an understanding of the concepts of navigating around the disk.

colon.LET This is the path or route to the file NOS. Syntax : C:\> DIR A:\> DIR Example A:\> DIR 196 . and backslash).LET PROJECT To specify the same path at the command prompt. The first back slash (\) represents the root directory. Note: MS-DOS recognizes path up to 67 characters long (including the Drive letter.LETTER NOS.8 DIR COMMAND The DIR command gives the list of is there on the disk that is mounted on the active drive. The third backslash separates the LETTER subdirectories from the file name. 5.LET. The first letter and the colon (C:) represent the drive the file is on.LET. you would type it as shown in the following illustration: C:\NOS\LETTER\NOS. NOS. The second backslash separates the NOS directory from the LETTER sub-directory.

Syntax: A:\> CHDIR {path} or a:\> CD {path} Examples : (Refer to the figure) # 1. It is important to note that the DIR command only displays the names of the files and not their contents. Whereas. However. 5. which appear in the second column. most files are named with an extension. five columns of data followed by the number of files and bytes that are free in the disk are displayed. Type the CD command at the command prompt. on typing DIR followed by <Enter> key at DOS prompt. You can see the list of files in another directory by changing to that directory and then using the DIR command again.30a 12. A:\>CD \NOS 197 .00p 3 file(s) A:\> 325013 bytes free As can be seen.00p 12.Volume in drive A has no label Directory of A:\ COMMAND DISKCOPY FORMAT COM COM COM 23612 4235 15780 10-20-88 10-20-88 03-12-89 11. The Change Directory (CHDIR) or CD command enables the user to travel around the directories in a disk. the third column contains the size of the file in bytes. The last line displays the number of file(s) and remaining disk space free in bytes.9 CHANGING A DIRECTORY All the names displayed using DIR command that have <DIR> besides them are directories. and the fourth and fifth columns show the date and time on which the files was created or last modified. The first column contains the primary name of each file resident on the disk.

Syntax: A:\>MKDIR [drive:] {pathname} or A:\>MD [drive:] {pathname} Square brackets indicate that [drive:] entry is optional. To create a directory. the drive need not be specified. in the specified drive. becomes the working directory. No matter which directory you are in. The MD or MKDIR command creates a new empty directory whose name is the last item specified in the pathname. you will change back to the root or main directory. this command always returns you to the root directory of a drive. Examples: # 1. a need is felt to organize them in a meaningful way by creating sub-directories to store a group of logically related/similar files. A:\> CD \ The root directory becomes the working directory. A:\> MD \ACCT\SALARY 198 .10 MAKING OR CREATING DIRECTORY As the number of files increases in a disk. which is a sub-directory under the NOS directory. If the directory is to be created as a sub-directory of the working directory on the active drive. A:\>CD \NOS\LETTERS The backslash indicates the root.This command makes the NOS sub-directory under the root directory (\) active. The root directory does not have a name. # 2. The slash typed in this command is a backslash (\). DOS provides the MKDIR (Make Directory) or MD command. # 3. i. it is simply referred to by a backslash (\).e. If active. and LETTERS. 5. typing MD {directory name} at the DOS prompt or command prompt is sufficient.

under ACCT directory. under root directory. DOS provides RD (Remove Directory) to delete a directory. # 2. you must type cd. 5. Before you can delete a directory. The syntax of the `COPY' command is COPY {source} {destination} or. When you use `copy' command. 5. the directory to be deleted should be empty. you must use the following two parameters. A:\> RD \ACCT\SALARY removes the SALARY sub-directory in ACCT directory. NOTE: You cannot delete a directory if you are in it. At the same point of time. You separate the source and the destination or target with a space.. and the location and the file name to which you want to copy the file or the target (destination). Example: # 1.makes a SALARY directory in the: drive. at the command prompt. COPY [drive:] [path] [filename] [drive:] [path] [filename] 199 .11 DELETING A DIRECTORY You may want to delete or remove a directory to simplify your directory structure. A:\> MD C:\> SALARY Makes a salary directory in the C: drive. or the source. DOS provides `COPY' command. the location and the name of the file you want to copy.12 COPYING FILES To copy a file.

bak makes a copy of the office.13 USE OF WILDCARD CHARACTERS 200 .mem copy the file office.EXE file from the DOS directory to the NOS directory 1. 5. A:\> copy a:\letter\office. To copy the file DEBUG. the first set of drive.doc \letter\office.exe c:\nos and the following message appears: 1 file (s) copied Examples: # 1.doc a:\letters\nos. and the second set of drive. Return to the root directory by typing the following command prompt: CD\ 2.e. (a) Copying Single File To copy the DEBUG.doc from the root directory to the sub-directory LETTER under root directory with a new name nos. path and filename refers to the destination file. directory type the following at the command prompt: Copy c:\dos\debug. the copied file will reside in the disk mounted on the active drive.i. path and filename refers to the source file. If the target drive is not specified. A:\> copy office. Change to the DOS directory by typing the following commands at the DOS prompt: CD DOS 3.doc file in the current or working directory with a new name office.EXE file from the DOS directory to the NOS.bak # 2.mem.

COB B: It means. and the question mark (?) represents a single character that a group of files has in common. with any or no extension SUN.XLI ???.LET REPORT.* 201 .TXT JULY.LET You can include the wildcard in the command.* All files having 3 letter names. # 2. A:\>COPY \letters\*. You can use wildcards to replace all or part of a file's name or its extension. you can use wildcard characters to specify groups of files. Use of wildcard characters in COPY command # 1. A:\> COPY B:\COMPANY\OPEL.COB from the directory LETTERS under the ROOT directory to the working or ROOT directory of the `B' drive.WRI REPORT.BMP WIN.TXT All files with a . copy all files with extension *.* All files beginning with letter M regardless of their extension MEMO. DOS recognize two wildcard characters: asterisk (*) represents one or more characters that a group of files has in common.TXT REPORT.TXT MARCH.* All files named REPORT with any extension REPORT. The following table shows examples of wildcards: Wildcard What it Represents Example *.TXT M*.If you want to carry out a task for a group of files whose names have something in common.TXT extension LETTER.

Incase of one drive.15 DELETING FILES 202 . The REN command stands for "Rename". 5. you must include two parameters.* B: copies all files with primary name consisting of 6 characters in total and LETTE as the first five characters (irrespective of extension name) into drive `B'. the system will ask for the source and target drive.MEM.* copies all files of the ROOT directory of the 'C' drive into the working directory of the 'A' drive.MEM Rename the old filename NOS. You separate the two names with a space. When you use the REN command.DOC copies all files having a primary name of one character with an extension .A:\>COPY C:\*.14 RENAMING FILES To rename a file. and the second is the new name for the file.DOC to a new filename NOS.DOC from ROOT directory of 'B' to the ROOT directory of `A' drive. 5. DOS provides REN command. # 4. A:\> COPY B:\?. A:\> COPY LETTE?. The REN command follows this pattern: REN oldname newname Example: REN NOS.The command is to copy all files with primary name OPEL (irrespective extension) in the directory COMPANY under ROOT of the drive `B' into the current working directory of the disk mounted in `A' drive. The command. #3. # 5. The first is the file you want to rename.DOC NOS.

1 1.HLP from the DOS directory under ROOT directory.HLP delete the EDIT. which means to delete. it enables the content of a text file to be printed on a paper. DEL \DOS\EDIT. DOS provides DEL command. Operating system is also known as: (a) database (b) system software 203 .LET IN-TEXT QUESTIONS 5.16 PRINTING A FILE The `PRINT' command of DOS works more or less like `TYPE' com mand. 5.This section explains how to delete or remove a file that is no longer required in the disk. Syntax : DEL {drive:} {path} {filename} Example: # 1. The startup routine runs. when machine boots up is known as a) POST b) BOOT up c) Operating Routine d) I/O operation 2. but at the same time. Syntax: A:\> PRINT [drive:] {path} {filename} Example: A:\> PRINT \AIAET\LETTER\AIAET.

What is the name given to something that the computer will automatically use unless you tell it otherwise? (a) a specification (b) a wildcard (c) a default (d) a rule 7.OST (c) NOSFILE.DOC (d) NOST.(c) hardware (d) printer 3.FILEDOC 5. How many characters form a secondary name for a file? (a) 8 (b) 12 (c) 3 (d) None of the above 6. which of the following indicates the ROOT directory (a)* (b) > 204 . As per symbolic notation of DOS. What is the maximum length allowed for primary name of a computer file under DOS? (a) 8 (b) 12 (c) 3 (d) None of the above 4.P. Which of the following could be a valid DOS file specification? (a) NOSFILE.POST (b) NOSFILE.

DOS system file consists of (a) IBMBIO.DOS 12.COM. FORMAT. COMMAND. IBMBIO.(c) / (d) None of the above 8. To display the list of all the file of the disk you would type (a) DIR (b) COPY (c) DIR FILES (d) DIR AUTOEXEC.COM.IBMDOS.PRG d) .COM. With DOS.COM.COM (c) SYS.DOC c) .IBMBIO. you may use the `*' and `?': (a) when changing the default settings (b) to represent unspecified characters in a filename (c) instead of wildcard characters (d) in the extension but not in the drive name or the file name 10. The batch file uses the extension a) . IBMDOS.BAT 205 .COM.COM (b) COMMAND.COM.BAT b) . In wildcard specification `?' is used as replacement for (a) one character (b) two character (c) three character (d) none of the above 9.COM (d) None of the above 11.

13.12. Explain in brief what do you understand by Operating system.a. 5.d.7. 2. Explain the process involved in loading of Operating System.5. 5.a.b.10.EXE is not an executable file.4. F.1 INTRODUCTION 206 .b.1 6.a. (c) The command MKDIR and MD performs the same task.c.6. (d) Under DOS . 2.F INTRODUCTION TO WINDOWS 3. and MOVE.a.13.b. DEL.F.T. State whether the following questions are True(T) or False(F).F.11.a. 5.19 FEEDBACK TO IN-TEXT QUESTIONS 1. It also talked in great length about the file management in terms of COPY.8.18 TERMINAL QUESTIONS 1. file naming conventions.b3. It explained the directory structure.17 WHAT YOU HAVE LEARNT In this lesson you were introduced to one of the most popular desktop operating system and its working environment. (e) DIR command is used to see the content of a specific file.Com is hidden file.9. Here you learned the steps involved in loading of operating systems into computer. (b) Primary name of a file can be of 10 characters. (a) Command.

207 . It is a Graphical User Interface (GUI) program meant for IBM compatible PCs. In general. Application windows. These windows can be. He just has to move the small mouse arrow key. it is very essential to understand the concept of window type and Icons used in Windows. there are two types of windows and three types of Icons which window uses.2 OBJECTIVES At the end of this lesson you would be able to understand the concept of windows working environment differentiate between confessional character display interface and graphical user interface. Multiple windows can appear on the screen at the same time giving user the flexibility of operating more than one Program.3 TYPES OF WINDOWS AND ICONS Before using Windows effectively. on which all windows are displayed. One doesn't need to remember operating system commands and type them. explain about various features of Windows understand various Icons and their functions. known as mouse pointer around the screen (better known as window) and select the require command by pressing the click button. resized and moved around the screen or the desktop. which displays the executable windows program in GUI mode. The entire screen is termed as Windows Desktop. It is same as that of laying all your work on the surface of your working table. which represents programs. it will probably come loaded with Windows. closed. opened. It provides the flexibility of using graphical icons and work interactively with the computer. The window types are 1. can be resized and moved around the screen. 6. Here the working table is the Windows Desktop and all your work is individual windows on the desktop. Each window.If somebody buys a new computer today. 6.

2. 3.4 PARTS OF WINDOWS All most all windows have common components. The scroll bar Control Button Scroll Bar Resizing Bar 208 . Maximize and Restore 3. Menu bar and Pull-down menus Menu Bar Minimise and Maximise Button Title Bar 5. Borders for Resizing 4. Application icons are the minimized version of the currently running application program. it appears within an application window's workspace. Windows uses three types of icons. document and program icons. 1. 6. Program icons that appear within Program Manager and clicking on these icons activate the associated applications and also load the related documents or files. Title Bar 2. This icon appears at the bottom of the desktop and can be maximized. These document windows cannot be sized or moved outside the limit of its parent application windows.2. namely application. The other type of windows is a document window. 1. Buttons for Minimize. which are generated by the executable or application program. When maximized. The components are. Document icons are the reduced document windows.

while corner border can be used to change width and height simultaneously. Similarly. Vertical and Horizontal borders can be used to change the width and height of the windows respectively. The windows can be moved around the window desktop using this title bar. Clicking on a menu name will activate a pull-down menu with various options to select. click the mouse button. minimise button is used to reduce the current windows into an applications icon. (d) Menu bar and Pull-down menus Menu bar is located under the Title bar and contains the related Pull-down menus for the currently active windows. Maximise and Restore Status Bar These buttons are displayed at the top-right corner of the screen. (c) Borders for Resizing A thin border appears around the windows. Restore button is used to restore the state of the windows. or the title of the current windows. The windows will change its size. hold and drag to the desired location. which will appear at the bottom of the windows desktop. which can be used to resize the current windows. It contains the name. maximise button is used to expand the current windows to take up the entire desktop. where it was before maximization. (b) Buttons for Minimise. To resize the current windows. As the name suggests.(a) Title bar Title bar is displayed in color at the top of the windows. (e) The scroll bar 209 . just place the pointer on the border (this will become two-headed arrow ) of the windows.

) indicate a link to another dialog box. sometimes it is require to change the settings within a program for example default margin the a word processing document. Command buttons with an ellipse (.. (a) Command Button This button activates an action. then it provides a scroll bar to move through the entire range of items in the list box. It is basically serve two purposes one that it allows to change/rest the parameters related to currently running application and displays information such as warnings. When selected an X appears besides the option selected and the corresponding option becomes active. Vertical scroll bar allows to view data by moving up or down through a document. If the number of items is more than the height of the list box. 6. (b) Check Box Check box allows selecting one or more option from a list of options. font type and size etc. whereas horizontal bar allows the movement from left to right. move the mouse pointer to the item and click on it. (d) Option Buttons 210 .) beside it is activated. The displayed dialog box may contain the followings. All these are accomplish by window's dialog box. which appear when the menu with an ellipsis (. The vertical scroll bar appears on the right side of the active windows and horizontal scroll bar at the bottom. (c) List Box List box displays a series of options available in a column. To select an item. error message etc.When the active windows cannot accommodate the data to be displayed then it provides a scroll bar that helps to move through the data.5 WINDOWS DIALOG BOXES While using application program in window.. default printer. The most commonly used command buttons are OK and CANCEL.

The only way to leave windows is to closing or exiting this program manager. are discussed. It allows selecting an option in a list of choices. These are vital part of windows operating environment and one must know how to work and use these programs. Within Program Manager there is some secondary window known as group windows. (a) Program Manager When window program starts Program manager is the first windows displayed on the window desktop. such as one group windows can contain all programs associated with database while another may be for word processing. File manager etc. Windows supports all the File and Directory management commands of MS-DOS and it also supports Ms-DOS conventions in working with files such as wild card characters. which can be minimized. other options automatically get deselected. 6. Once an option gets selected from the available set of options. which appears at the bottom of 'Main' windows.7 WINDOWS VS. network or printer settings. Rather than remembering all the commands and typing them at the DOS prompt. Minimum disk space assumes no optional components. programs provided in windows such as program Manager. and windows will execute the command.3 MB of free disk space. 6. the small hollow circle gets filled. network and printer. in Windows one can move the mouse pointer to the required command.6 DISK SPACE REQUIRED Ms-Windows along with MS-DOS version 6. However maximum disk space includes all installable components. A group icon is a group window. which appears as fully opened window such one with title 'Main' or as group icons. MS-DOS Windows provides tools to accomplish all the tasks in case of file and directory management as in MS-DOS.0 requires a minimum of 15. Group windows contains logically related programs. The main difference is how the work is done.8 MB and maximum of 18.It has the same features as that of check box. 211 . When selected. 6.8 WINDOWS PROGRAMS In this section.

They are. plus several other useful applications. during installation process if you chose the Custom Setup option and chose not to have Windows set up applications from your hard disk. MS-DOS prompt.There are five default groups in Windows. 212 . Applications group consists of all the application found on your hard disk. Main group of windows contain all the system applications: File manager. Windows Setup and PIF Editor. How ever if. communications (Terminal). drawing (Paint). the program manager will not contain an Application group. while installing the windows. Print Manager. Accessories group is made of windows based applications for word processing (Write).

an application is added to it. However neither the group windows can be moved outside the program manager nor the group icons. Windows provide the flexibility to install other group windows also. Program items can be added deleted in-group windows and they can be copied between group windows also. 213 . which can be executed. Group windows can be resized. File manager is used to manage or manipulate both disk and the disk files. one can run the associated program files. (b) File Manager As the name suggests. It provides visual representations of all disks and disk files in the system. StartUp group has application that loaded when windows system starts initially.Games group contains windows based games. By selecting the icons. moved and it contains the icons for the program. This group remains empty until. All the program items can be moved between groups copied or renamed. Any applications can be added to this group.

press and hold down the SHIFT key and then use arrow keys to extend the selection to the last item in the group. and then use the direction keys or arrow keys to select. (i) Selecting File(s) and directories File Manager allows you to select one or more than one files at a time for copying. 214 . renamed. moving or deleting or to perform other related task. They can also be moved between directories. Alternatively. The attributes of one or more file can be changed. or opened. known as directory window. deleted or copied. select the first file. by selecting them from the directory window. Or press the TAB button to move to the list of files. To select consecutive files.Window Menu Drive label Or Network Drive Window Title Drive Icons File and subdirectory icons of current directory Directory Icons As displayed in the above figure. appear in a document windows. printed. press and hold down the SHIFT key. and then click the last file on the desired file list or group. select the first file. To select a file or directory clicks the desired icon. the directory structure for the hard disk of the system and all the files in the current directory.

This also discussed how to select files and directories. To activate a program when windows starts. To select similar type of file. File maintenance is done using File manager in windows.1 1.To select or cancel selection of the non-consecutive files. press and hold CTRL key and click on each file. e. then press SHIFT and F8 again. d. use SPACEBAR to select the file or to cancel already the selected file. How a group icon is different from individual program icon? 4.DOC as extension or secondary name. 6. Alternatively. b. File Manager is used to start Windows. Briefly discuss why Windows is popular.10 TERMINAL QUESTIONS 1. you need to add it to File manager.9 WHAT YOU HAVE LEARNT In this lesson you were introduced to the concept of windows working environment and graphical user interface. For example *. a. IN-TEXT QUESTION 6. 6. Print manager and File Manager are available in Games windows. In the text box of the dialog box specify the type of files to be selected. 2. It also discussed various features and components of windows. use arrow keys to move to each file. State True or False. Briefly explain about different components of windows and how to start windows. activate the Select Files option from the File menu bar. press SHIFT and F8 key.DOC to select all files in the current directory that has . Which group programs are loaded when windows starts-up? 215 . It explained with examples the icons and their functions. Group windows and group icon can be moved out of Program Manager c. 3.

DOS based applications are standard DOS programs such as WordStar. Whereas a windows application is specifically developed to run under Windows environment which support GUI. move from floppy disk to hard disk drive and vice versa. standard DOS based applications and Windows based applications.1 7. (a) False (b) False (c) True (d) False (e) False FILE HANDLING IN WINDOWS 3.2 OBJECTIVES At the end of this lesson you would be able to appreciate the GUI feature of windows understand the file and directory handling in windows use file manager for file handling in windows sort file using file size. gives better flexibility and easier to use for file management. name. and not specifically meant for windows.1 INTRODUCTION Windows being a GUI. type search and locate file(s) do file copy. Using the File Manager feature of Windows. move. This avoids the painful task of remembering all the file management DOS commands. 7. Windows can run two types of applications. developed to run in DOS environment.3 DIRECTORY AND FILE MANAGEMENT IN WINDOWS 216 . 7. dBase etc. delete. one can easily copies. rename files and also create and remove directory. Can a DOS based application be used in Windows? 6.5.11 FEEDBACK TO IN-TEXT QUESTION 1.

Double clicking on the File Manger icon activates it from the Main program group.) of the currently selected directory. The total amount of diskspace. Right Pane of window drive 217 . (a) Drive Window Currently selected drive is displayed as another windows within the File Manager window. The only difference is that it is divided in two parts. free diskspace available. right one displays the directory structure of the currently selected drive and the left part displays the contents (such as files. Other way of activating it is to highlight the File Manager icon and hit the Return key File Manager can be closed like any other windows program. sub-directory etc. move or minimize is same as that of any other window. The command to resize.Windows provides File manager for manipulating Directory and Files of a system. File Manager can be minimized while running some other application and expanded once the execution is over. Main program consists the icon for File Manager. which appears at the bottom of the File Manager. the size of the selected file is shown for the currently open directory on the status bar. It is an essential part of Windows and run like any other windows program.

(b) Directory Operations Drive windo w File Manager provides the features to manage all the drives in your system and/or connected to your system through network. Other way of selecting a drive is to click on the Disk option of the File Manager menu bar. move or delete files within a drive. (d) Creating a New Directory A new directory or sub-directory under an already existing directory can be created using File Manager. Once the drive is changed. D E etc. It allows to copy. between drives of the system and systems connected through network. First click on the File menu option of the File Manager. directory and files under the newly selected drive will be displayed in the current directory window. This will bring up the pull down menu having Create Directory. Selecting this option will activate the Create Directory dialog box with current directory path. Left Pane of window drive (c) Changing Disk Drives To change drive. and select the desired drive letter. click on the desired drive icon or press <CTRL> and the designated drive letter such as C. To create a sub 218 .

(e) Changing Directory To go to the desired directory under the currently selected drive. To finish the entry and create the new sub-directory. To display all file information. the desired file type you want to see.4 FILE OPERATIONS 219 . select the VIEW option on the File Manager menu bar and activate the option 'All File Details'. Sort by Size: Display all files in order of File Size. date and time it was created/or last modified etc. click on the OK button. which will activate the pull-down menu with option 'By File Type'. Sort by Name: Displays all files in alphabetical order of File name. In addition to the File name. File path one can display file size. This will make the selected directory as the currently active directory and all the sub-directory and files under this directory will be displayed at the right pane of the document window. select the VIEW option on the menu bar and selected the desired option. Selecting this will bring up the 'By File Type' dialog box. Available options are. type the entire path in the name text box. File manager has the flexibility of displaying different groups of files in the currently selected directory. However they can also be displayed in order of file type. double click on the directory name. 7. Use the wild card characters to enter inn the name text box. In File Manager. sub-directory and file under the currently selected directory are displayed in alphabetical order. To change the displays option. In File Manager. Click on the View option of the File Manager menu bar. To create a sub-directory under some other directory. date or file size.directory under the current directory. it can also be specified what all information for files can be displayed. type down the new sub-directory name in the text box. Sort by Type: Displays all files in alphabetical order of extension Name Sort by Date: Displays File in order of creation/last modification Date.

(i) Drag-and-Drop Method 220 .File Manager provides tools such as copy. rename. Insert the source disk into the drive and select the DISK option of the File Manager menu bar. between directories and also between drives. and activate the 'Copy Disk'. move. Now select the target drive from the copy dialog box and click on OK button. The source disk replaces the content of the target. rename for management of files within directory. Drag-and-Drop method and Keyboard method. windows also have the tool in File Manager for making copies of disk. the target disk is formatted as that of source disk type and size while copying the files. However the target disk type and size should same as that of source disk. This will start the coping process from the source to target disk. If an unformatted disk is used in target drive. This will copy the files from the source disk into the memory. (b) Copying/Moving Directory or Files In file Manager. (a) Copying a Diskette Like Diskcopy of DOS. This copy option is very useful for making back-up copy. one or more files or Directory can be copied or moved into different location using two different methods.

(ii) Using Keyboard 221 . by clicking on the OK button of the dialog box. This will copy the selected files in to the target drive. another drive icon.File Manager has the capabilities of copying or moving files and directories in more interactive and visual ways as compared to MS-DOS. confirm replace message by clicking on the YES button of the dialog box. If the file(s) to be copied is/are already presents on the destination directory or drive. Confirm the copying operation. another directory window or to a file list in a different directory window and drop them. Open the source directory select the files to be copied and then drag them in to the desired target directory.

However. click on the OK button or press Enter key (). one first need to delete all the files and sub-directory of the desired directory to be deleted. Enter the destination path or drive. Select the COPY or MOVE option from the File menu bar of File Manager as per the requirement. COPY or MOVE dialog box appears on the screen. Alternatively press F8 for copy or F7 for MOVE operation to start. As in the case of drag-and-drop method.Instead of using mouse for the above operation. it will ask whether to create a new one. To start the operation. File Manager allows to delete an entire directory including all its files and subdirectory in a single command. However in the case of network drive. one cannot delete files or directories if he has not the privilege or permission of doing so.5 DELETING FILES AND DIRECTORIES File Manager provides greater flexibility in deleting files and directories. the destination can be a directory window. If the destination directory does not exist. directory icon or drive icon. Click on the desired file name to be copied or use the direction key to highlight it. in DOS. As in the case of drag-and-drop method. 222 . one can alternatively use the keyboard to select COPY and MOVE command. 7.

To delete the already select files or directory. Activate the Delete option from the File menu bar of File Manager and the delete dialog box appears on the window desktop. Click on YES button to confirm the deletion. enter the file name or path and click on the OK button. This will activate directory delete dialog box. 7. To delete other files or directory. Click on Yes to All to delete all selected files or click on Cancel button to cancel the delete operation.Select the file(s) or directory to be deleted (alternatively use tab to move the cursor to the desired location and use direction keys to select the files).6 FILE RENAMING 223 . click on the OK button.

Note: One can use wild card characters for renaming files. The Rename dialog box appears with name of the currently selected file in the From text box. Now enter the new name for the file in the To text box and click OK button or press Enter key. First select the file to be renamed. and then chose the Rename option from the File menu bar of File manger. 224 .File Manager allows changing the name of a file with a restriction that the new file name should follow the DOS file naming conventions. This completes the renaming process. The new file name should not be more than eight characters long with an optional three characters extension or secondary name with permissible set of characters.

Here you can conduct a search on your disk. Specify the filename. The result is displayed in Search Result window.7. This is particularly helpful.7 SEARCHING FOR FILES AND DIRECTORIES File Manager provides the tool to search a file. closed the same way as other window. directory to locate the file. or use wildcard character (such and * or?) in the Search For text box to search 225 . but you don't remember where the file exists. a group of files or subdirectories. Click or select the directory to be searched and then choose Search option from the File menu. which can be resized. minimized or maximized. if you know a particular file is on your disk.

When opted. File manager provides tools to work with floppy disks. 7. However Quick Format does not check the disk for bad sectors. Quick Format This option is available for disk that has already been formatted.8 WORKING WITH FLOPPY DISKS At times one need to copy files onto a floppy as backup or copy file from floppy to hard disk for further processing of files. making it faster as compared to standard format procedure. File Manager format command allows you to prepare a new/old floppy to receive data. To cancel the search operation. Label As the name suggests.for a group of files or directories that have related file names or extensions. which are optional. press ESC key. The Search Result windows will contain all the files that meet the search criteria. it has to be prepared for that. A label or volume label should not more than 11 characters long. When selected. in case the hard disk is not working or one needs to bypass booting from hard disk for any reason. The format command has three options. System disk is used to boot the system from a floppy drive. it is a name for the formatted disk to identify it. 226 . (a) Formatting a Floppy Before using a new floppy to receive data. System disk comes handy. file Manager just removes all information about directory and files from disk. all the system files are copied into the specified area called system area or boot sector of the floppy drive. System Disk While formatting a disk. it can be opted to make the disk a system or startup disk.

select the appropriate drive letter. Choose the option such as Label.To format a disk or floppy using File Manager. From the list of drives. Complete the other areas of the dialog box and click on OK button. 227 . System Disk or Quick Format. All the required parameters are adjusted according to the selected drive. In case of Label option. This completes the entry and File Manager starts formatting the disk according to the specification given. insert the disk into the drive and select Format Disk option from Disk menu bar. specify the volume label name for the disk.

1 Choose the best answer for each of the following questions. (a) Main 228 . Windows is a (a) System Software (b) Database Software (c) GUI based Software (d) None of the Above 2. operating system (b) program. (d) None of the above 4. Which of the following on a command button indicates a link to another dialog box (a)/ (b)* (c). application (c)only program (d) None of the above 3. 1.. Which of the following groups of Windows contain all executable software found on your hard disk. File manager is a part of which group of Windows Program Manager Main Application None of the above 5. document.IN-TEXT QUESTIONS 7. Which are the following types of Icons used by Windows (a) database.

(b) Print Manager (c)Application (d) None of the above

6. Which of the following allows all types of file manipulation such a COPY, MOVE etc.

(a) Print Manager (b) File Manager (c) System setup (e) None of the above

7.9

WHAT YOU HAVE LEARNT

This lesson discussed windows's graphical user interface (GUI) in a great length. In the beginning it discussed what is directory and file management. Then with examples it explained how to do directory maintenance in-terms of create, delete and change directory. It also discussed how to sort files by name, type, size and dates. Here you learned how to file operation in windows using File manager and what is drag and drop method. At last it explained how to search for file and directory and how to work using a floppy diskette in windows.

7.10 TERMINAL QUESTIONS

7.11

FEEDBACK TO IN-TEXT QUESTIONS

1. (c) 2. (b)

3. (c)

4. (b)

5. (c)

6. (b)

WINDOWS 95- AN INTRODUCTION

8.1

INTRODUCTION

Windows 95 is the upgraded version of Windows 3.x series with lots of new features embedded into it. It is a complete paradigm shift from windows 3.x working environment.

229

It is the entry point to a 32-bit operating/computing environment with less set of hardware requirements. It has more compatibility with other software as compared to its previous version and provides easy installation. It also runs most of the Windows 3.x and Ms-DOS programs. Windows 95 also provides flexibility to configure hardware, easy link to a network or setup a network, install and uninstall programs automatically. It also has lots of other useful features like easy Internet access, multitasking, and its most useful feature is long file names.

8.2

OBJECTIVES:

At the end of this lesson you would be able to

understand the difference between Windows 3.11 and Windows95. able to work on Windows95 appreciate the uses of Long file name appreciate the new look and feel of Windows95.

8.3

IMPROVED FEATURES OF WINDOWS 95

Graphical User Interface :

As compared to Windows 3.x, Windows 95 provides user-friendlier interface to work on. Its improved graphical user interface makes learning and using Windows 95 more natural and easier for all types of users. It is more powerful, customizable and efficient.

Start Button

Introduction of START button in Windows 95 made life much simpler while there is a need to access multiple programs. It is the gateway of accessing most of the functionality available in the computer loaded with Windows 95. Just Click on the Start button anytime to start any programs, open or find documents, change windows settings, get Help, manage Files, maintain system, and much more.

230

Taskbar

As the name suggests, the Task bar provides information and access to the entire task that has been currently activated by Windows 95. Using this one can keep a track of what all programs have been

activated and switched between them.

Windows Explorer

Windows Explorer is more or less acts as a File Manager for Windows 95, but with lots of new features. It is more efficient, faster and user friendly as compared to File Manager of Windows 3.x.

Using Explorer one can easily browse through all the drives and network resources available and

manage files.

Right Mouse Button

Clicking on the right mouse button activates a pop-up menu in any programs so as to help in completing a task efficiently.

Long File Names

As the Ms-DOS convention follows, non-of the file used in DOS environment should be more than 8 characters of primary name and optional secondary name (extension) of three characters. However Windows 95 has broken this barrier. Windows 95 supports long file names, maximum of 255 characters. It also allowed space to be used in between file name. This helps to make files and folders (directory/subdirectory) easier to organize and find.

Shortcuts

As the name suggests, SHORTCUTS are the shortest way to access programs, files and other resources in Windows 95. Instead of going through the structural process of accessing a program, one can create "shortcuts" to access them. It creates links for easy access to files, programs, folders, and more.

231

Multitasking

Multitasking allows the user to activate and accomplish more than one task at a time. For example, work on a document file in WORD programs, while copying file from other computer available in the network. With Windows 95, 32-bit computing environment, the user can do more than one task a time.

Easy Internet Access

One of the most useful and entirely new features is Windows 95 easy access to Internet. It provides built-in Internet functionality to setup link and access Internet with less amount of Hardware and Software requirement. It also provides connectivity software from Microsoft Network (MSN), CompuServe, and America Online.

It also improves the efficiency of working on Internet with applications that support the latest Internet technologies, such as ActiveX, Java, and streaming audio and video.

Software Compatibility

Windows 95 provides complete backward compatibility. It is easily compatible with applications developed for MS-DOS and Windows 3.x environment. It also supports the latest 32-bit technology. Most of the latest software packages are now built on Windows 95 operating environment.

Great Gaming Platform

232

Windows 95 support rich graphics, high quality audio and video. It also requires all most no editing of Config.sys files so as to support these technologies. All this is possible because of Windows 95 compatibility with latest and hottest technologies like Plug and Play, AutoPlay, and built-in support for MIDI and digital and surrounds video.

Hardware Compatibility

Windows 95 provides greater Hardware compatibility as compare to any other operating environment. It has flexibility of supporting hardware from different vendors. Its Plug and Play functionality allows to insert the hardware card into the computer and when the computer is turned on Windows 95

automatically recognizes and sets up the hardware.

Find Utility

Find Utility of Windows 95 allows you to do searches by partial name, last modified date, or full text. In addition, you can save, rename, or view files from within the result pane, just like you can from

Windows Explorer.

Help

Windows 95 provides online help to accomplish a task. If the user is not sure how to perform a task, Windows 95 Help will provide structured process how to accomplish the task. Simply right-click on any object in the user interface (icons) and you'll get relevant descriptions about that object.

(a)

System Requirements

CPU

Recommended 486/25 MHz-based system or more

Memory

Recommended a minimum of 8-MB memory

233

mail. printers.(RAM). Recycle Bin Provides drag and drop facilities. exchange. Hard Disk Space Available free hard disk space of 40-45 MB. Display VGA or higher-resolution display Operating System Peripheral/ Miscellaneous MS-DOS Compatible pointing device (b) Windows Desktop Icons Icon Purpose My Computer Provides direct access to local drives. and the Dial-up Network utility. Inbox or Microsoft Outlook Universal in-box for all mail sources including faxes. deletion of file from folders in the machine and provides a second chance to recover files deleted from the hard disk. 234 . Network Neighborhood Access to shared resources on the machine and computers on local and wide area network. Control panel. and others.

8.1 8. Quick help on how to use windows can also be obtained from this task bar. a program can be quickly started or file can be searched for.4 START BUTTON AND TASK BAR Windows now features the Start button and Taskbar at the bottom of the screen. This bar contains the Start button.Fig. Using this button. 235 .

2 236 . 8.Fig.

Click on the desired icon to open the designated program. click on the required program icon on the taskbar to make it currently activated program. Click on the Start button. Select the program you want to run. If you have opened more than one program or windows. 2. If you have opened more than one program.Click on the Start to activate the Pop-up menu so as to open a program. click on the minimized button of the windows. find a file or folders (directory or sub-directory). point to the folder that contains the program. Once the selected program starts. and then click Files Or Folders where the program resides. (a) Steps to start a program 1. 237 . you can switch between them. If the program you want is not on the menu. a small icon appears on the taskbar. Click on the program icon or menu. This will send the activated window as small icon to the task bar. and change the settings for Windows95. If the desired program is not available on the program menu or one of its submenus. Run a program or shut down the computer and also to get help on windows. Similarly if you don't need a windows too frequently. and then point to Programs option. You can also use the Find dialog box to locate the program file. All the opened windows or program appears on the Start or the Task bar as a minimized icons. 3. point to Find on the Start menu.

Double clicking on any of the folders in the drive window will open another window showing the contents of the folder. Select the document you want to open. So if the desired document to be opened is not listed or available in Document Menu. by clicking on it Note: All programs are not capable of adding files to Document menu. CDROM drive. and then use the Find dialog box to locate the file. Hard Disk etc. Select/Click "Files Or Folders" option. Double clicking on a drive in the top level of my computer will open another window containing the main folders on the select drive. Double clicking on either the Control Panel folder or the Printers folders in My Computer windows will activate the respective windows for Control panel or Printers. and then select the Find option. Fig. 8.5 MY COMPUTER It allows looking at a glance to all the resource available on the machine such as floppy drive. Using this you can manipulate the settings for your Computer or Printer the same way that you were accessing them from the Start menu. If you have network drives mapped as local drives they will also show up here.3 238 .(b) Steps to open a recently used document 1 2 3.8. Click on the Start button Select/point to Documents option. click on the Start button.

Even this can be used to copy.4 239 . Fig 8. delete files among or between floppy and Hard Disk or network drives. move.My Computer is the quickest way of accessing all the resources available on the computer.

Windows Explorer let you explore the contents of your computer and do file management. Select the media such as floppy disk.11. It is the improved version of File Manager in Windows 3. Now select the Properties option from the pop-up menu. Fig. 5 240 .My Computer also provides the tools to change the settings of the available resources.1 or 3. This will activate a Pop-Up menu.6 WINDOWS EXPLORER As the name suggests. 8. hard disk drive you want to change the settings and right click on it. Tools and Sharing. This action will display the property windows with three options: General. 8. Using these three options you can change the properties of the selected media.

Now select Windows Explorer Option. Windows Explorer displays on the left-hand side of the screen. This will activate another Pop-Up menu. all the folders on your computer in a hierarchical order. On the right hand side of the screen.To activate Windows Explorer.6 241 . Click on the Start Button on the Task Bar and select Programs option. it displays all the files and folders in each selected folder. Fig 8.

5. Go to Edit Menu and Select/Click Copy option. Go to My Computer or Windows Explorer Select the file you want to move by clicking on it. 2. the item will be deleted permanently from the computer without being stored in the Recycle Bin. and then drag it to the folder you want to put it in.Windows Explorer is especially useful for copying and moving files. 3. You can open the folder that contains the file you want to move or copy. 4. Files or folders can also be deleted by dragging file or folder icons onto the Recycle Bin icon. Go to My Computer or Windows Explorer Select the file or folder you want to delete by clicking on it. 3. Again go to Edit Menu and Select/Click Paste option. Go to Edit Menu and Select/Click Cut option. Open the folder or disk drive where you want to copy. 4. If SHIFT key is pressed while dragging. 2. Note: Files or folder deleted are stored in the Recycle Bin until the Recycle Bin is emptied. 3. Go to File Menu and Select/Click Delete option. (c) Steps to delete a file or folder 1. (a) Steps to copy a file or folder 1. Again go to Edit Menu and Select/Click Paste option. 2. (b) Steps to move a file or folder 1. Open the folder or disk drive where you want to move. Go to My Computer or Windows Explorer Select the file you want to copy by clicking on it. 5. 242 .

Type a new name for the file or Folder. while pressing the CTRL key. a filename can be up to 255 characters. point to "Send To" option. and then click on the "Folder" option. and then press ENTER. 3. Insert the disk in the floppy disk drive. Go to File menu. Go to the File menu. Go to My Computer or Windows Explorer Select the File you want to Copy. point to New. (d) Steps to copy a file to a floppy disk 1. open the folder in which you want to create a new folder by double clicking on it. Note : As Windows 95 supports long file name. 3. (e) Steps to create a new folder 1. 2.7 NETWORK NEIGHBORHOOD 243 . and then press ENTER. click the items you want to select. The new folder appears with a temporary name. Type a name for the new folder. Go to My Computer or Windows Explorer Click on the file or folder you want to rename. by clicking on the file. 4. Go to the File menu. including spaces.To select more than one file or folder to copy. 2. it cannot contain any of the following characters: \/:*?"<>| 8. 4. Go to My Computer or Windows Explorer. However. 4. and Select/Click "Rename" option. Steps to change the name of a file or folder 1 2 3. and then select the drive you want to copy the file to.

If you double click on one of the Computers. Network neighborhood takes the ability of My Computer and extends them one step further. any resources that Computer shares with others in the workgroup like.7 244 .8. directories or printers will be listed Fig.A Network is a group of Computers connected to each other to share available resources such as storage and printers. and see what drives or Printers may be available for use. by giving you with the ability to view all of the Computers connected in workgroup or network.drives.

the Network Neighborhood icon appears on the desktop. however. 8.8 RECYCLE BIN The files deleted by you are put in the Recycle Bin. There you can also drag and drop files for quick deleting. They are. It is a safety feature. Fig 8. 8 1. built in to protect you against the possibility of deleting something you should not have.9 245 . To browse through the computers in the workgroup and the computers on the entire network. Fig. a holding place for files that are no longer needed.When connected to a network. not actually removed from the hard disk until the user "empty" the Recycle Bin. double click on the icon Network Neighborhood.

But if you want to find something quickly.10 246 . you can use the Find command on the Start menu.8. One way is to browse through folders in My Computer. Fig. 8.9 FIND Using Windows 95 it is easy to locate files and folders on the computer.

You can also use wildcard character to Find files Fig. To install a program from a network 1. Select Control Panel from the Settings option of Start Menu Double Click on the Add/Remove Programs icon. if the Install/Uninstall tab is selected. and then click Find Now. and your computer is already connected to a network. 2. 11 8. To install a program from a floppy disk or CD-ROM 1. This will activate the Find Dialog box.10 WORK WITH PROGRAMS Windows 95 provides higher level of flexibility in terms of installing and removing programs. type the name of the file or folder you are looking for. Click here to open the Add/Remove Programs dialog box. and then click Next.Click on the Start button and select "Find" option. 247 . Follow the instructions on your screen. click Install button. 3. Now select the Option " Files or Folders". Follow the instructions on your screen. 2. In the Find dialog box.

3. Note Only programs that were designed for Windows 95 can be removed by using Add/Remove Programs. you must connect to it by using My Computer or Windows Explorer. 1. or both. Select Control Panel from the Settings option of Start Menu Double Click on the Add/Remove Programs icon. your network. To remove a program from your computer 1.11 MS-DOS WINDOW Windows 95 provides the flexibility of executing most of the DOS commands or DOS based program without going out of Windows 95 GUI.Note If you do not have a Network Install tab in the Add/Remove Programs dialog box. 2. Click the Start button. To use DOS prompt. and then point to Programs. this feature has not been enabled on your computer. 2. Follow the instructions on your screen. Click/Select MS-DOS Prompt. If you are not already connected to the shared folder you want to install from. For all other programs. See your system administrator. check the program's documentation to determine which files should be removed. 8. or type the path to it in the text box. 248 .

Fig 8. click the MS-DOS icon in the title bar. To quit MS-DOS.12 Tips To view the toolbar. To switch between a full screen and a window. 249 . click or type Exit at the command prompt. and then click Toolbar. press ALT+ENTER.

To activate these tools. Using these tools you can change the desktop background.8. right click on the windows. Fig 8. wallpaper and lots of other settings according to your choice.13 Desktop Background To change the background of the desktop 250 . You can also activate these tools from Control panel by selecting the Display icon. This will display a menu now select the Properties option.12 CHANGE WINDOWS SETTINGS Windows 95 provides tools to change the look and feel of the desktop window.

click the pattern or wallpaper you want to use.14 Tips To cover the entire screen with wallpaper image. In the Pattern or Wallpaper list. 251 . Fig. click Tile.Right Click on the Desktop to view the Display properties. 8.

Screen Saver and Settings can be used. and then select the option Shut down the Computer and click on the Yes button. Fig. Patterns and wallpaper can be used simultaneously. one can select the number of colors.To center a wallpaper image. you will not be able to see the pattern. 8. However. Click the Shut Down button. click Center. Similarly all other option such as Appearance. if Title is selected. 8. pixel type and display adapter for the system.13 SHUT DOWN THE COMPUTER Click the Start button. Using the Settings option.15 252 .

What is the Windows 3.x series equivalent to Windows Explorer in Windows95? (a) Program manager (b) File manager 253 . IN-TEXT QUESTIONS 8. Which of the following is introduced exclusively in Windows95? (a) Control panel (b) File manager (c) Start button (d) None of the above 2. Choose the best answer for the following questions.Important Do not turn off your computer until the "You can now safely turn off your computer" message appears.1 1.

and also we learned how to change look and feel of Windows 95 desktop according to user requirement. It explained the new features of Windows95 and hardware requirement for installation. 8. 4. how Windows95 is different from Windows 3. (b) GUI stands for ________________________.1 254 .16 FEEDBACK TO IN-TEXT QUESTIONS IN-TEXT QUESTIONS 8. In the beginning it discussed what is GUI and its usefulness. but can not be deleted. (c) Windows 95 is a application software.(c) Print manager (d) None of the above 3.x series. Here we discussed how to do file management in Windows 95. (d) In Windows 95 desktop icons can be created. Answer whether the following statement is True (T) or False (F). 8. (a) Windows 95 supports file name of 255 characters including space in between. (d) Explain what do you understand by multitasking? (e) What is the minimum hardware requirement for installing Windows95 software? (f) What is the purpose of recycle bin? (g) Explain the steps involved to shut down Windows95. (b) Windows 95 does not support Ms-DOS based application. 8. Fill in the blanks (a) Inbox in Windows 95 is used for ______________________.15 TERMINAL QUESTIONS (c) Briefly explain.14 WHAT YOU HAVE LEARNT This lesson introduced you to one of the most popular and widely used GUI operating system in desktop environment. You also learned about various Windows 95 icons and their usability.

(c) 2. (a) Getting e-mail.(a) True (b) False (c) False (d) False 4. 255 . (b) Graphical User Interface.1. (b) 3.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer: Get 4 months of Scribd and The New York Times for just $1.87 per week!

Master Your Semester with a Special Offer from Scribd & The New York Times