Computer Programming 1 PDF
Document Details
Uploaded by ReformedFunction5208
BPSU-Main
Tags
Summary
This document provides an overview of computer programming and computer organization. It covers key components, functionalities, advantages, and disadvantages of computers. It also briefly discusses various applications of computers in different fields.
Full Transcript
EAAC0203-Computer Programming Course Packet 01: History of Computer and Computer Organization Computer Computer is an advanced electronic device that takes raw data as input from the user and processes it under the control of set of instructions (called program), gives the result (output), and...
EAAC0203-Computer Programming Course Packet 01: History of Computer and Computer Organization Computer Computer is an advanced electronic device that takes raw data as input from the user and processes it under the control of set of instructions (called program), gives the result (output), and saves it for the future use. Today’s world is an information-rich world and it has become a necessity for everyone to know about computers. Purpose of this tutorial is to introduce you about computer and its fundamentals. Key Points: Computer is an advanced electronic device that takes raw data as input from the user and processes it under the control of set of instructions (called program), gives the result (output), and saves it for the future use. Functionalities of a computer Any digital computer carries out five functions in gross terms: Takes data as input. Stores the data/instructions in its memory and use them when required. Processes the data and converts it into useful information. Generates the output. Controls all the above four steps. Computer Input Process Output Definition Computer is an electronic data processing device which accepts and stores data input, processes the data input, and generates the output in a required format. Advantages Following list demonstrates the advantages of computers in today's arena. High Speed Computer is a very fast device. It is capable of performing calculation of very large amount of data. The computer has units of speed in microsecond, nanosecond, and even the picosecond. It can perform millions of calculations in a few seconds as compared to man who will spend many months for doing the same task. Accuracy In addition to being very fast, computers are very accurate. The calculations are 100% error free. Computers perform all jobs with 100% accuracy provided that correct input has been given. Storage Capability Memory is a very important characteristic of computers. A computer has much more storage capacity than human beings. It can store large amount of data. It can store any type of data such as images, videos, text, audio and many others. Diligence Unlike human beings, a computer is free from monotony, tiredness and lack of concentration. It can work continuously without any error and boredom. It can do repeated work with same speed and accuracy. Versatility A computer is a very versatile machine. A computer is very flexible in performing the jobs to be done. This machine can be used to solve the problems related to various fields. At one instance, it may be solving a complex scientific problem and the very next moment it may be playing a card game. Reliability A computer is a reliable machine. Modern electronic components have long lives. Computers are designed to make maintenance easy. Automation Computer is an automatic machine. Automation means ability to perform the given task automatically. Once a program is given to computer i.e., stored in computer memory, the program and instruction can control the program execution without human interaction. Reduction in Paper Work The use of computers for data processing in an organization leads to reduction in paper work and results in speeding up a process. As data in electronic files can be retrieved as and when required, the problem of maintenance of large number of paper files gets reduced. Reduction in Cost Though the initial investment for installing a computer is high but it substantially reduces the cost of each of its transaction. Disadvantages Following list demonstrates the disadvantages of computers in today's arena No I.Q A computer is a machine that has no intelligence to perform any task. Each instruction has to be given to computer. A computer cannot take any decision on its own. Dependency It functions as per a user’s instruction, so it is fully dependent on human being. Environment The operating environment of computer should be dust free and suitable. No Feeling Computers have no feelings or emotions. It cannot make judgement based on feeling, taste, experience, and knowledge unlike a human being. Applications of Computers Following list demonstrates various applications of computers in today's arena. Business A computer has high speed of calculation, diligence, accuracy, reliability, or versatility which made it an integrated part in all business organizations. Computer is used in business organizations for: Payroll calculations Budgeting Sales analysis Financial forecasting Managing employees database Maintenance of stocks etc. Banking Today banking is almost totally dependent on computer. Banks provide following facilities: Banks provide online accounting facility, which includes current balances, deposits, overdrafts, interest charges, shares, and trustee records. ATM machines are making it even easier for customers to deal with banks. Insurance Insurance companies are keeping all records up-to-date with the help of computers. The insurance companies, finance houses and stock broking firms are widely using computers for their concerns. Insurance companies are maintaining a database of all clients with information showing: procedure to continue with policies starting date of the policies next due installment of a policy maturity date interests’ due survival benefits bonus Education The computer has provided a lot of facilities in the education system. The computer provides a tool in the education system known as CBE (Computer Based Education). CBE involves control, delivery, and evaluation of learning. The computer education is rapidly increasing the graph of number of computer students. There are number of methods in which educational institutions can use computer to educate the students. It is used to prepare a database about performance of a student and analysis is carried out on this basis. Marketing In marketing, uses of computer are following: Advertising - With computers, advertising professionals create art and graphics, write and revise copy, and print and disseminate ads with the goal of selling more products. At Home Shopping - Home shopping has been made possible through use of computerized catalogues that provide access to product information and permit direct entry of orders to be filled by the customers. Health Care Computers have become important part in hospitals, labs, and dispensaries. The computers are being used in hospitals to keep the record of patients and medicines. It is also used in scanning and diagnosing different diseases. ECG, EEG, Ultrasounds and CT Scans etc., are also done by computerized machines. Some major fields of health care in which computers are used are: Diagnostic System - Computers are used to collect data and identify cause of illness. Lab-diagnostic System - All tests can be done and reports are prepared by computer. Patient Monitoring System - These are used to check patient's signs for abnormality such as in Cardiac Arrest, ECG etc. Pharma Information System - Computer checks Drug-Labels, Expiry dates, harmful drug’s side effects etc. Surgery : Nowadays, computers are also used in performing surgery. Engineering Design Computers are widely used in Engineering purpose. One of major areas is CAD (Computer aided design). That provides creation and modification of images. Some fields are: Structural Engineering - Requires stress and strain analysis for design of Ships, Buildings, Budgets, Airplanes etc. Industrial Engineering - Computers deal with design, implementation and improvement of integrated systems of people, materials and equipment. Architectural Engineering - Computers help in planning towns, designing buildings, determining a range of buildings on a site using both 2D and 3D drawings. Military Computers are largely used in defense. Modern tanks, missiles, weapons etc. Military also employs computerized control systems.Some military areas where a computer has been used are: Missile Control Military Communication Military Operation and Planning Smart Weapons Communication Communication means to convey a message, an idea, a picture or speech that is received and understood clearly and correctly by the person for whom it is meant for. Some main areas in this category are: E-mail Chatting Usenet FTP Telnet Video-conferencing Government Computers play an important role in government. Some major fields in this category are: Budgets Sales tax department Income tax department Male/Female ratio Computerization of voters lists Computerization of driving licensing system Computerization of PAN card Weather forecasting History of Computer Computer Generation Generation in computer terminology is a change in technology a computer is/was being used. Initially, the generation term was used to distinguish between varying hardware technologies. But nowadays, generation includes both hardware and software, which together make up an entire computer system. There are totally five computer generations known till date. Each generation has been discussed in detail along with their time period and characteristics. Here approximate dates against each generation have been mentioned which are normally accepted. Following are the main five generations of computers. 1. First Generation -The period of first generation: 1946-1959. Vacuum tube based. 2. Second Generation -The period of second generation: 1959-1965. Transistor based. 3. Third Generation -The period of third generation: 1965-1971. Integrated Circuit based. 4. Fourth Generation -The period of fourth generation: 1971-1980. VLSI microprocessor based. 5. Fifth Generation -The period of fifth generation: 1980-onwards. ULSI microprocessor based Computer Types The computers that are developed are not alike rather they have different designs and features. Some computers have very high capacity as well as working speed; however, some are slow. Depending upon the requirements, computers are being developed. Types of Computer Depending upon the internal structure and subsequent features and applicability, computer system is categorized as follows: Mainframe Computer - It is high capacity and costly computer. It is largely used by big organizations where many people can use it simultaneously. Super Computer - This category of computer is the fastest and also very expensive. A typical supercomputer can solve up to ten trillion individual calculations per second. Workstation Computer - The computer of this category is a high-end and expensive one. It is exclusively made for complex work purpose. Personal Computer (PC) - It is a low capacity computer developed for single users. Apple Macintosh (Mac) - It is a sort of personal computer manufactured by Apple company. Laptop computer (notebook) - It is a handy computer that can be easily carried anywhere. Tablet and Smartphone - Modern technology has advanced further. It has helped develop computers that are pocket friendly. Tablets and smartphones are the best examples of such computer. Computer Organization All types of computers follow a same basic logical structure and perform the following five basic operations for converting raw input data into information useful to their users. No. Operation Description 1. Take Input - The process of entering data and instructions into the computer system. 2. Store Data - Saving data and instructions so that they are available for processing as and when required. 3. Processing Data - Performing arithmetic, and logical operations on data in order to convert them into useful information. 4. Output Information - The process of producing useful information or results for the user, such as a printed report or visual display. 5. Control the workflow - Directs the manner and sequence in which all of the above operations are performed. Input Unit Input Unit - This unit contains devices with the help of which we enter data into computer. This unit makes link between user and computer. The input devices translate the information into the form understandable by computer. CPU (Central Processing Unit) - CPU is considered as the brain of the computer. CPU performs all types of data processing operations. It stores data, intermediate results and instructions(program). It controls the operation of all parts of computer. CPU itself has following three components: ALU (Arithmetic Logic Unit) Memory Unit Control Unit Output Unit - Output unit consists of devices with the help of which we get the information from computer. This unit is a link between computer and users. Output devices translate the computer's output into the form understandable by users. CPU – Central Processing Unit Organization CPU consists of the following features: CPU is considered as the brain of the computer. CPU performs all types of data processing operations. It stores data, intermediate results and instructions(program). It controls the operation of all parts of computer. CPU itself has following three components: Memory or Storage Unit Control Unit ALU (Arithmetic Logic Unit) Memory or Storage Unit This unit can store instructions, data and intermediate results. This unit supplies information to the other units of the computer when needed. It is also known as internal storage unit or main memory or primary storage or Random access memory(RAM). Its size affects speed, power and capability. Primary memory and secondary memory are two types of memories in the computer. Functions of memory unit are: It stores all the data and the instructions required for processing. It stores intermediate results of processing. It stores final results of processing before these results are released to an output device. All inputs and outputs are transmitted through main memory. Control Unit This unit controls the operations of all parts of computer but does not carry out any actual data processing operations. Functions of this unit are: It is responsible for controlling the transfer of data and instructions among other units of a computer. It manages and coordinates all the units of the computer. It obtains the instructions from the memory, interprets them, and directs the operation of the computer. It communicates with Input/Output devices for transfer of data or results from storage. It does not process or store data. ALU(Arithmetic Logic Unit) This unit consists of two subsections namely: Arithmetic section Logic Section Arithmetic Section - Function of arithmetic section is to perform arithmetic operations like addition, subtraction, multiplication and division. All complex operations are done by making repetitive use of above operations. Logic Section - Function of logic section is to perform logic operations such as comparing, selecting, matching and merging of data. Computer Input Devices Following are few of the important input devices which are used in a computer: Keyboard Microphone Mouse Magnetic Ink Card Joy Stick Reader(MICR) Light pen Optical Character Track Ball Reader(OCR) Scanner Bar Code Reader Graphic Tablet Optical Mark Reader(OMR) Keyboard Keyboard is the most common and very popular input device which helps in inputting data to the computer. The layout of the keyboard is like that of traditional typewriter, although there are some additional keys provided for performing additional functions. Keyboards are of two sizes 84 keys or 101/102 keys, but now keyboards with 104 keys or 108 keys are also available for Windows and Internet. The keys on the keyboard are as follows: 1. Typing Keys - These keys include the letter keys (A-Z) and digit keys (0-9) which generally give same layout as that of typewriters. 2. Numeric Keypad - It is used to enter numeric data or cursor movement. Generally, it consists of a set of 17 keys that are laid out in the same configuration used by most adding machines and calculators. 3. Function Keys - The twelve function keys are present on the keyboard which are arranged in a row at the top of the keyboard. Each function key has unique meaning and is used for some specific purpose. 4. Control Keys - These keys provide cursor and screen control. It includes four directional arrow keys. Control keys also include Home, End, Insert, Delete, Page Up, Page Down, Control(Ctrl), Alternate(Alt), Escape(Esc). 5. Special Purpose Keys - Keyboard also contains some special purpose keys such as Enter, Shift, Caps Lock, Num Lock, Space bar, Tab, and Print Screen. Mouse Mouse is most popular pointing device. It is a very famous cursor-control device having a small palm size box with a round ball at its base which senses the movement of mouse and sends corresponding signals to CPU when the mouse buttons are pressed. Generally it has two buttons called left and right button and a wheel is present between the buttons. Mouse can be used to control the position of cursor on screen, but it cannot be used to enter text into the computer. Advantages Easy to use Not very expensive Moves the cursor faster than the arrow keys of keyboard. Joystick Joystick is also a pointing device which is used to move cursor position on a monitor screen. It is a stick having a spherical ball at its both lower and upper ends. The lower spherical ball moves in a socket. The joystick can be moved in all four directions. The function of joystick is similar to that of a mouse. It is mainly used in Computer Aided Designing(CAD) and playing computer games. Light Pen Light pen is a pointing device which is similar to a pen. It is used to select a displayed menu item or draw pictures on the monitor screen. It consists of a photocell and an optical system placed in a small tube. When the tip of a light pen is moved over the monitor screen and pen button is pressed, its photocell sensing element detects the screen location and sends the corresponding signal to the CPU. Track Ball Track ball is an input device that is mostly used in notebook or laptop computer, instead of a mouse. This is a ball which is half inserted and by moving fingers on ball, pointer can be moved. Since the whole device is not moved, a track ball requires less space than a mouse. A track ball comes in various shapes like a ball, a button and a square. Scanner Scanner is an input device which works more like a photocopy machine. It is used when some information is available on a paper and it is to be transferred to the hard disc of the computer for further manipulation. Scanner captures images from the source which are then converted into the digital form that can be stored on the disc. These images can be edited before they are printed. Digitizer Digitizer is an input device which converts analog information into digital form. Digitizer can convert a signal from the television or camera into a series of numbers that could be stored in a computer. They can be used by the computer to create a picture of whatever the camera had been pointed at. Digitizer is also known as Tablet or Graphics Tablet because it converts graphics and pictorial data into binary inputs. A graphic tablet as digitizer is used for doing fine works of drawing and image manipulation applications. Microphone Microphone is an input device to input sound that is then stored in digital form. The microphone is used for various applications like adding sound to a multimedia presentation or for mixing music. Magnetic Ink Card Reader(MICR) MICR input device is generally used in banks because of a large number of cheques to be processed every day. The bank's code number and cheque number are printed on the cheque's with a special type of ink that contains particles of magnetic material that are machine readable. This reading process is called Magnetic Ink Character Recognition (MICR).The main advantages of MICR is that it is fast and less error prone. Optical Character Reader(OCR) OCR is an input device used to read a printed text. OCR scans text optically character by character, converts them into a machine readable code and stores the text on the system memory. Bar Code Readers Bar Code Reader is a device used for reading bar coded data (data in form of light and dark lines). Bar coded data is generally used in labelling goods, numbering the books etc. It may be a hand held scanner or may be embedded in a stationary scanner. Bar Code Reader scans a bar code image, converts it into an alphanumeric value which is then fed to the computer to which bar code reader is connected. Optical Mark Reader(OMR) OMR is a special type of optical scanner used to recognize the type of mark made by pen or pencil. It is used where one out of a few alternatives is to be selected and marked. It is specially used for checking the answer sheets of examinations having multiple choice questions. Computer Memory A memory is just like a human brain. It is used to store data and instructions. Computer memory is the storage space in computer where data is to be processed and instructions required for processing are stored. The memory is divided into large number of small parts called cells. Each location or cell has a unique address which varies from zero to memory size minus one. For example if computer has 64k words, then this memory unit has 64 * 1024=65536 memory locations. The address of these locations varies from 0 to 65535. Memory is primarily of three types: Cache Memory Primary Memory/Main Memory Secondary Memory Cache Memory Cache memory is a very high speed semiconductor memory which can speed up CPU. It acts as a buffer between the CPU and main memory. It is used to hold those parts of data and program which are most frequently used by CPU. The parts of data and programs are transferred from disk to cache memory by operating system, from where CPU can access them. Advantages The advantages of cache memory are as follows: Cache memory is faster than main memory. It consumes less access time as compared to main memory. It stores the program that can be executed within a short period of time. It stores data for temporary use. Disadvantages The disadvantages of cache memory are as follows: Cache memory has limited capacity. It is very expensive. Primary Memory (Main Memory) Primary memory holds only those data and instructions on which computer is currently working. It has limited capacity and data is lost when power is switched off. It is generally made up of semiconductor device. These memories are not as fast as registers. The data and instruction required to be processed reside in main memory. It is divided into two subcategories RAM and ROM. Characteristics of Main Memory These are semiconductor memories It is known as main memory. Usually volatile memory. Data is lost in case power is switched off. It is working memory of the computer. Faster than secondary memories. A computer cannot run without primary memory. Secondary Memory This type of memory is also known as external memory or non-volatile. It is slower than main memory. These are used for storing data/Information permanently. CPU directly does not access these memories instead they are accessed via input-output routines. Contents of secondary memories are first transferred to main memory, and then CPU can access it. For example: disk, CD-ROM, DVD etc. Characteristic of Secondary Memory These are magnetic and optical memories It is known as backup memory. It is non-volatile memory. Data is permanently stored even if power is switched off. It is used for storage of data in a computer. Computer may run without secondary memory. Slower than primary memories. Computer Random Access Memory (RAM) RAM(Random Access Memory) is the internal memory of the CPU for storing data, program and program result. It is read/write memory which stores data until the machine is working. As soon as the machine is switched off, data is erased. Access time in RAM is independent of the address that is, each storage location inside the memory is as easy to reach as other locations and takes the same amount of time. Data in the RAM can be accessed randomly but it is very expensive. RAM is volatile, i.e. data stored in it is lost when we switch off the computer or if there is a power failure. Hence a backup uninterruptible power system(UPS) is often used with computers. RAM is small, both in terms of its physical size and in the amount of data it can hold. RAM is of two types: Static RAM (SRAM) Dynamic RAM (DRAM) Static RAM (SRAM) The word static indicates that the memory retains its contents as long as power is being supplied. However, data is lost when the power gets down due to volatile nature. SRAM chips use a matrix of 6-transistors and no capacitors. Transistors do not require power to prevent leakage, so SRAM need not have to be refreshed on a regular basis. Because of the extra space in the matrix, SRAM uses more chips than DRAM for the same amount of storage space, thus making the manufacturing costs higher. So SRAM is used as cache memory and has very fast access. Characteristic of the Static RAM It has long life Expensive There is no need to refresh High power consumption Faster Used as cache memory Large size Dynamic RAM (DRAM) DRAM, unlike SRAM, must be continually refreshed in order to maintain the data. This is done by placing the memory on a refresh circuit that rewrites the data several hundred times per second. DRAM is used for most system memory because it is cheap and small. All DRAMs are made up of memory cells which are composed of one capacitor and one transistor. Characteristics of the Dynamic RAM It has short data lifetime Used as RAM Need to be refreshed Lesser in size continuously Less expensive Slower as compared to SRAM Less power consumption Computer Read Only Memory (ROM) ROM stands for Read Only Memory. The memory from which we can only read but cannot write on it. This type of memory is non-volatile. The information is stored permanently in such memories during manufacture. A ROM, stores such instructions that are required to start a computer. This operation is referred to as bootstrap. ROM chips are not only used in the computer but also in other electronic items like washing machine and microwave oven. Following are the various types of ROM: MROM (Masked ROM) The very first ROMs were hard-wired devices that contained a pre- programmed set of data or instructions. These kind of ROMs are known as masked ROMs which are inexpensive. PROM (Programmable Read only Memory) PROM is read-only memory that can be modified only once by a user. The user buys a blank PROM and enters the desired contents using a PROM program. Inside the PROM chip there are small fuses which are burnt open during programming. It can be programmed only once and is not erasable. EPROM(Erasable and Programmable Read Only Memory) The EPROM can be erased by exposing it to ultra-violet light for a duration of up to 40 minutes. Usually, an EPROM eraser achieves this function. During programming, an electrical charge is trapped in an insulated gate region. The charge is retained for more than ten years because the charge has no leakage path. For erasing this charge, ultra- violet light is passed through a quartz crystal window(lid). This exposure to ultra-violet light dissipates the charge. During normal use the quartz lid is sealed with a sticker. EEPROM(Electrically Erasable and Programmable Read Only Memory) The EEPROM is programmed and erased electrically. It can be erased and reprogrammed about ten thousand times. Both erasing and programming take about 4 to 10ms (milli second). In EEPROM, any location can be selectively erased and programmed. EEPROMs can be erased one byte at a time, rather than erasing the entire chip. Hence, the process of re- programming is flexible but slow. Advantages of ROM The advantages of ROM are as follows: Non-volatile in nature More reliable than RAMs These cannot be accidentally These are static and do not changed require refreshing Cheaper than RAMs Its contents are always Easy to test known and can be verified Computer Mother Board The motherboard serves as a single platform to connect all of the parts of a computer together. A motherboard connects CPU, memory, hard drives, optical drives, video card, sound card, and other ports and expansion cards directly or via cables. It can be considered as the backbone of a computer. Features of Motherboard A motherboard comes with following features: 1. Motherboard varies greatly in supporting various types of components. 2. Normally a motherboard supports a single type of CPU and few types of memories. 3. Video Cards, Hard disks, Sound Cards have to be compatible with motherboard to function properly 4. Motherboards, cases and power supplies must be compatible to work properly together. Popular Manufacturers Intel ASUS AOpen ABIT Biostar Gigabyte MSI Description of Motherboard The motherboard is mounted inside the case and is securely attached via small screws through pre-drilled holes. Motherboard contains ports to connect all of the internal components. It provides a single socket for CPU whereas for memory, normally one or more slots are available. Motherboards provide ports to attach floppy drive, hard drive, and optical drives via ribbon cables. Motherboard carries fans and a special port designed for power supply. There is a peripheral card slot in front of the motherboard using which video cards, sound cards and other expansion cards can be connected to motherboard. On the left side, motherboards carry a number of ports to connect monitor, printer, mouse, keyboard, speaker, and network cables. Motherboards also provide USB ports which allow compatible devices to be connected in plug-in/plug-out fashion for example, pen drive, digital cameras etc. Computer Memory Unit Memory unit is: the amount of data that can be stored in the storage unit. that in which storage capacity is expressed in terms of Bytes. Following are the main memory storage units: 1. Bit (Binary Digit) - A binary digit is logical 0 and 1 representing a passive or an active state of a component in an electric circuit. 2. Nibble - A group of 4 bits is called nibble. 3. Byte - A group of 8 bits is called byte. A byte is the smallest unit which can represent a data item or a character. 4. Word - A computer word, like a byte, is a group of fixed number of bits processed as a unit which varies from computer to computer but is fixed for each computer. The length of a computer word is called word-size or word length and it may be as small as 8 bits or may be as long as 96 bits. A computer stores the information in the form of computer words. Few higher storage units are following: 1. Kilobyte (KB) 1 KB = 1024 Bytes 2. Megabyte (MB) 1 MB = 1024 KB 3. GigaByte (GB) 1 GB = 1024 MB 4. TeraByte (TB) 1 TB = 1024 GB 5. PetaByte (PB) 1 PB = 1024 TB