Introduction to Computers and Programming Preparatory Year PDF
Document Details
Uploaded by ShinyWilliamsite288
Assiut National University
2024
Assiut National University
Dr. Mahmoud Aref
Tags
Related
- Introduction to Computers and Programming PDF
- Introduction to Programming with Python PDF 2023
- Ch.01-Introduction to Computers and Programming (1) PDF
- Computer Programming (01CE1101) Unit 1 Introduction PDF
- Introduction To Computer & Programming PDF
- Chapter 1: Introduction to Computers and Programming PDF
Summary
This document is a past paper covering the introduction to computers and programming for preparatory year at Assiut National University, 2024. It includes fundamental concepts like computer hardware and software and problem-solving techniques.
Full Transcript
Assiut National University Faculty of Engineering and Applied Sciences Introduction to Computers and Programming For Preparatory Year Dr. Mahmoud Aref 2024/2025 1 Table of Contents Chapter Name...
Assiut National University Faculty of Engineering and Applied Sciences Introduction to Computers and Programming For Preparatory Year Dr. Mahmoud Aref 2024/2025 1 Table of Contents Chapter Name Page Chapter 1 INTRODUCTION TO COMPUTER 3 Chapter 2 DATA REPRESENTATION 14 Chapter 3 COMPUTER SOFTWARE 25 Chapter 4 PROBLEM-SOLVING AND 33 OFFICE APPLICATION SOFTWARE Chapter 5 INTRODUCTION TO C++ 44 Questions Bank 111 2 Chapter 1 INTRODUCTION TO COMPUTER 1.1 INTRODUCTION Definition A computer is an electronic machine, devised for performing calculations and controlling operations that can be expressed either in logical or numerical terms. Applications The applications domain of a computer depends totally on human creativity and imagination it covers a huge area of applications including education, industries, government medicine, scientific research, law and even music and arts. Millions of complex calculations can be done in a mere fraction of time Difficult decisions can be made with unerring accuracy for comparatively little cost A computer is an electronic device operating under the control of instructions stored in its own memory that can accept data (input), process the data according to specified rules, produce output (output), and store it for future use. 1.2 Functionalities of a computer Any digital computer carries out five functions in gross terms: 1.3 Computer Components Any computer consists of HARDWARE AND SOFTWARE. Hardware: Computer hardware is the collection of physical elements that constitutes a computer system. Computer hardware refers to the physical parts or components of a computer such as the monitor, mouse, keyboard, computer data storage, hard drive disk (HDD), system unit (graphic cards, sound cards, memory, motherboard and chips), etc. all of which are physical 3 objects that can be touched. Input Devices Input device is any peripheral (piece of computer hardware equipment to provide data and control signals to an information processing system such as a computer or other information appliance. Input device Translate data from form that humans understand to one that the computercan work with. Most common are keyboard and mouse Example of Input Devices:- 1. Keyboard 2. Mouse (pointing device) 3. Microphone 4. Touch screen 5. Scanner 6. Webcam 7. Touchpads 8. MIDI keyboard 9. 10.Graphics Tablets 11.Cameras 12.Pen Input 13.Video Capture Hardware 14.Microphone 15.Trackballs 16.Barcode reader 17.Digital camera 18.Joystick 19.Gamepad 20.Electronic Whiteboard 21. Note: The most common use keyboard is the QWERTY keyboard. Generally standard Keyboard has 104 keys. Central Processing Unit (CPU) A CPU is brain of a computer. It is responsible for all functions and processes. Regarding 4 computing power, the CPU is the most important element of a computer system. The CPU is comprised of three main parts : * Arithmetic Logic Unit (ALU): Executes all arithmetic and logical operations. Arithmetic calculations like as addition, subtraction, multiplication and division. Logical operation like compare numbers, letters, or special characters * Control Unit (CU): controls and co-ordinates computer components. 1. Read the code for the next instruction to be executed. 2. Increment the program counter so it points to the next instruction. 3. Read whatever data the instruction requires from cells in memory. 4. Provide the necessary data to an ALU or register. 5. If the instruction requires an ALU or specialized hardware to complete, instruct the hardware to perform the requested operation. * Registers :Stores the data that is to be executed next, "very fast storage area". Primary Memory:- 1. RAM: Random Access Memory (RAM) is a memory scheme within the computer system responsible for storing data on a temporary basis, so that it can be promptlyaccessed by the processor as and when needed. It is volatile in nature, which means that data will be erased once supply to the storage device is turned off. RAM stores data randomly and the processor accesses these data randomly from the RAM storage. RAM is considered "random access" because you can access any memory cell directly if you know the row and column that intersect at that cell. 2. ROM (Read Only Memory): ROM is a permanent form of storage. ROM stays active regardless of whether power supply to it is turned on or off. ROM devices do not allow data stored on them to be modified. Secondary Memory:- Stores data and programs permanently :its retained after the power is turned off 1. Hard drive (HD): A hard disk is part of a unit, often called a "disk drive," "hard drive," or "hard disk drive," that store and provides relatively quick access to large amounts of data on an electromagnetically charged surface or set of surfaces. 2. Optical Disk: an optical disc drive (ODD) is a disk drive that uses laser light as part of the process of reading or writing data to or from optical discs. Some drives can only read from discs, but recent drives are commonly both readers and recorders, also called burners or writers. Compact discs, DVDs, and Blu-ray discs are common types of optical media which can be read and recorded by such drives. Optical drive is the generic name; drives are usually described as "CD" "DVD", or "Bluray", followed by "drive", "writer", etc. There are three main types of optical media: CD, DVD, and Blu-ray disc. CDs can store up to 700 megabytes (MB) of data and DVDs can store up to 8.4 GB of data. Blu-ray discs, which are the newest type of optical media, can store up to 50 GB of data. This storage capacity is a clear advantage over the floppy disk storage media (a magnetic media), which only has a capacity of 1.44 MB. 3. Flash Disk: A storage module made of flash memory chips. A Flash disks have no 5 mechanical platters or access arms, but the term "disk" is used because the data are accessed as if they were on a hard drive. The disk storage structure is emulated. Output devices An output device is any piece of computer hardware equipment used to communicatethe results of data processing carried out by an information processing system (such as a computer) which converts the electronically generated information into human- readable form. Example on Output Devices: 1. Monitor 2. LCD Projection Panels 3. Printers (all types) 4. Computer Output Microfilm (COM) 5. Plotters 6. Speaker(s) 7. Projector Note Basic types of monitors are a.Cathode Ray Tube (CRT). B. Liquid Crystal Displays (LCD). c.light-emitting diode (LED). Printer types: 1-Laser Printer. 2-Ink Jet Printer. 3-Dot Matrix Printer 6 Software Software is a generic term for organized collections of computer data and instructions,often broken into two major categories: system software that provides the basic non- task-specific functions of the computer, and application software which is used by users to accomplish specific tasks. Software Types A. System software is responsible for controlling, integrating, and managing the individual hardware components of a computer system so that other software and the users of the system see it as a functional unit without having to be concerned with the low-level details such as transferring data from memory to disk or rendering text onto a display. Generally, system software consists of an operating system and some fundamental utilities such as disk formatters, file managers, display managers, text editors, user authentication (login) and management tools, and networking and device control software. B. Application software is used to accomplish specific tasks other than just running the computer system. Application software may consist of a single program, such as an image viewer; a small collection of programs (often called a software package) that work closely together to accomplish a task, such as a spreadsheet or text processing system; a larger collection (often called a software suite) of relatedbut independent programs and packages that have a common user interface or shared data format, such as Microsoft Office, which consists of closely integrated word processor, spreadsheet, database, etc.; or a software system, such as a database management system, which is a collection of fundamental programs thatmay provide some service to a variety of other independent applications. Comparison Application Software and System Software System Software Application Software Computer software, or just software is a general term primarily Application software, also known used for digitally stored data such as as an application or an "app", is computer programs and other kinds computer software designed to help of information read and written by the user to perform specific tasks. computers. App comes under computer software though it has a wide scope now. Example: 1) Microsoft Windows 1) Opera (Web Browser) 2) Linux 2) Microsoft Word (Word 3) Unix Processing) 4) Mac OSX 3) Microsoft Excel (Spreadsheet 5) DOS software) 4) MySQL (Database Software) 5) Microsoft PowerPoint (Presentation Software) 6) Adobe Photoshop (Graphics Software) 7 InteractioGenerally, users do not interact Users always interact with n: with system software as it works in application software while doing the background. different activities. Depende System software can run Application software cannot run ncy: independently of the without the application software. presence of the system software. Unit of Measurements Storage measurements: The basic unit used in computer data storage is called a bit (binary digit). Computers use these little bits, which are composed of ones and zeros, to do things and talk to other computers. All your files, for instance, are kept in the computer as binary files and translated into words and pictures by the software (which is also ones and zeros). This two number system, is called a “binary number system” since it has only two numbers in it. The decimal number system in contrast has ten unique digits,zero through nine. Computer Storage units Bit BIT 0 or 1 Kilobyte KB 1024 bytes Megabyte MB 1024 kilobytes Gigabyte GB 1024 megabytes Terabyte TB 1024 gigabytes Size example 1 bit - answer to yes/no question 1 byte - a number from 0 to 255. 90 bytes: enough to store a typical line of text from a book. 4 KB: about one page of text. 120 KB: the text of a typical pocketbook. 3 MB - a three-minute song (128k bitrate) 650-900 MB - a CD-ROM 1 GB -114 minutes of uncompressed CD-quality audio at 1.4 Mbit/s 8-16 GB - the size of a normal flash drive Speed measurement: The speed of the Central Processing Unit (CPU) is measured by Hertz (Hz), Which represents a CPU cycle. The speed of the CPU is known as Computer Speed. CPU SPEED MEASURES 1 hertz or Hz 1 cycle per second 1 MHz 1 million cycles per second or 1000 Hz 1 GHz 1 billion cycles per second or 1000 MHz 8 Computers classification*** Computers can be generally classified by size and power as follows, though there is considerable overlap: Personal computer: A small, single-user computer based on a microprocessor. In addition to the microprocessor, a personal computer has a keyboard for entering data, a monitor for displaying information, and a storage device for saving data. workstation: A powerful, single-user computer. A workstation is like a personal computer, but it has a more powerful microprocessor and a higher-quality monitor. minicomputer: A multi-user computer capable of supporting from 10 to hundreds of users simultaneously. mainframe: A powerful multi-user computer capable of supporting many hundreds or thousands of users simultaneously. supercomputer: An extremely fast computer that can perform hundreds of millions of instructions per second. Laptop and Smartphone Computers LAPTOP: A laptop is a battery or AC-powered personal computer that can be easily carried and used in a variety of locations. Many laptops are designed to have all of the functionality of a desktop computer, which means they can generally run the same software and open the same types of files. However,some laptops, such as netbooks, sacrifice some functionality in order to beeven more portable. Netbook: A netbook is a type of laptop that is designed to be even more portable. Netbooks are often cheaper than laptops or desktops. They are generally lesspowerful than other types of computers, but they provide enough power for email and internet access, which is where the name "netbook" comes from. Mobile Device: A mobile device is basically any handheld computer. It is designed tobe extremely portable, often fitting in the palm of your hand or in your pocket. Some mobile devices are more powerful, and they allow you to do many of the same things you can do with a desktop or laptop computer. These include tablet computers, e-readers, and smartphones. Tablet Computers: Like laptops, tablet computers are designed to be portable. However, they provide a very different computing experience. The most obvious difference is that tablet computers don't have keyboards or touchpads.Instead, the entire screen is touch-sensitive, allowing you to type on a virtual keyboard and use your finger as a mouse pointer. Tablet computers are mostlydesigned for consuming media, and they are optimized for tasks like web browsing, watching videos, reading e-books, and playing games. For many people, a "regular" computer like a desktop or laptop is still needed in order to use some programs. However, the convenience of a tablet computer means that it may be ideal as a second computer. Smartphones: A smartphone is a powerful mobile phone that is designed to run a variety of applications in addition to phone service. They are basically small tablet computers, and they can be used for web browsing, watching videos, reading e-books, playing games and more. 9 1.4 Data, Information and Knowledge Data: Facts and figures which relay something specific, but which are not organized in any way and which provide no further information regarding patterns, context, etc. So data means "unstructured facts and figures that have the least impact on the typical manager." Information: For data to become information, it must be contextualized, categorized, calculated and condensed. Information thus paints a bigger picture; it is data with relevance and purpose. It may convey a trend in the environment, or perhaps indicate a pattern of sales for a given period of time. Essentially information is found "in answers to questions that begin with such words as who, what, where, when, and how many". Knowledge: Knowledge is closely linked to doing and implies know-how and understanding. The knowledge possessed by each individual is a product of his experience, and encompasses the norms by which he evaluates new inputs from his surroundings. The content of the human mind can be classified into four categories: 1. Data: symbols 2. Information: data that are processed to be useful; provides answers to "who", "what", "where", and "when" questions 3. Knowledge: application of data and information; answers "how" questions 4. Wisdom: evaluated understanding. We need to understand that processing data produced Information and process Information produces Knowledge and so on Characteristics of Computer Speed, accuracy, diligence, storage capability and versatility are some of the key characteristics of a computer. A brief overview of these characteristics are Speed: The computer can process data very fast, at the rate of millions of instructionsper second. Some calculations that would have taken hours and days tocomplete otherwise, can be completed in a few seconds using the computer. For example, calculation and generation of salary slips of thousands of employees of an organization, weather forecasting that requires analysis of a large amount of data related to temperature, pressure and humidity of various places, etc. Accuracy: Computer provides a high degree of accuracy. For example, the computer can accurately give the result of division of any two numbers up to 10 decimal places. Diligence: When used for a longer period of time, the computer does not get tired or fatigued. It can perform long and complex calculations with the same speed andaccuracy from the start till the end. Storage Capability: Large volumes of data and information can be stored in the computer and also retrieved whenever required. A limited amount of data can be stored, temporarily, in the primary memory. Secondary storage devices likefloppy disk and compact disk can store a large amount of data permanently. Versatility: Computer is versatile in nature. It can perform different types of tasks with the same ease. At one moment you can use the computer to prepare a letterdocument and in the next moment you may play music or print a document. Computers have several limitations too. Computer can only perform tasks thatit has been programmed to do. 10 Computer cannot do any work without instructions from the user. It executes instructions as specified by the user and does not take its own decisions. Computer Viruses* Viruses: A virus is a small piece of software that piggybacks on real programs. For example, a virus might attach itself to a program such as a spreadsheet program.Each time the spreadsheet program runs, the virus runs, too, and it has the chance to reproduce (by attaching to other programs) or wreak havoc. E-mail viruses: An e-mail virus travels as an attachment to e-mail messages, and usually replicates itself by automatically mailing itself to dozens of people in the victim's e-mail address book. Some e-mail viruses don't even require a double-click -- they launch when you view the infected message in the preview pane of your e-mail software [source: Johnson]. Trojan horses: A Trojan horse is simply a computer program. The program claims to do one thing (it may claim to be a game) but instead does damage when yourun it (it may erase your hard disk). Trojan horses have no way to replicate automatically. Worms: A worm is a small piece of software that uses computer networks and security holes to replicate itself. A copy of the worm scans the network for another machine that has a specific security hole. It copies itself to the new machine using the security hole, and then starts replicating from there, as well. What are some tips to avoid viruses and lessen their impact? * Install anti-virus software from a reputable vendor. Update it and use it regularly. In addition to scanning for viruses on a regular basis, install an "on access" scanner (included in most anti-virus software packages) and configure it to start each time you start up your computer. This will protect your system by checking for viruses each time you run an executable file. Use a virus scan before you open any new programs or files that may contain executable code. This includes packaged software that you buy from the store as well as any program you might download from the Internet. If you are a member of an online community or chat room, be very careful about accepting files or clicking links that you find or that people send you within the community. Make sure you back up your data (documents, bookmark files, important email messages, etc.) on disc so that in the event of a virus infection, you do not lose valuable work 1.5 COMPUTER GENERATIONS 1. First Generation (1940-56) : Vacuum Tube First generation computer were vacuum tubes/thermionic value based machines these computers used vacuum tubes for circuitry and magnetic drums for memory. A magnetic drum is a metal cylinder coated with magnetic iron-oxide material on which data and programs can be stored. 11 Input was based on punched cards and paper tape and output was in the form of printouts. For example: ENIAC, EDVAC AND UNIVAC. Characteristics of First Generation Computers. These computers were based on vacuum tube technology. These were the fastest computing devices of their time. These computers were very large, and required a lot of space for installation. These were non-portable and very slow equipments. 2. Second Generations (1956-63): Transistors A transistor is made up of semiconductor materials like germanium and silicon. It usually had three leads and performed electrical functions such as voltage, current or power amplification with low power requirements. Since the transistor is a small device, the physical size of computers was greatly reduced. Computers became smaller, faster, cheaper, energy-efficient and more reliable than their predecessors. Magnetic cores- were used as primary memory and magnetic disks as secondary storage devices. However, they still relied on punched cards for input and printouts for output. For example: PDP – 8 , IBM 1401 and IBM 7090 Characterstics of Second Generation Computer. These machines were based on transistor technology These were smaller as compared to the first generation computers. These were more portable and generated less amount of heat. 3. Third Generation (1964 – Early 1970), Integrated Circuits The development of the integrated circuit was a trait of the third-generation computer. Also called an IC, an integrated circuit consists of a single chip with many components such as transistors and resistors fabricated on it. Integrated circuit replaced several individually wired transistors. This development made computers smaller in size, reliable and efficient. Instead of punched cards and printouts, users interacted with third-generation computers through keyboards and monitors and interfaced with the operating system. For example: NCR 395 and B6500 Characteristics of Third-Generation Computer These computers were based on integrated circuit (ic) technology. They were able to reduce computational time from microseconds to nanoseconds. Extensive use of high–level language became possible 12 4. Fourth Generation (Early (1970 – Till Date) Microprocessors) The technology of this generation was still based on the integrated circuit, these have been made readily available to use because of the development of the microprocessor. The fourth- generation computers led to an era of large-scale integration (LSI) and very large-scale integration (VLSI) technology. LSI technology allowed thousands of transistors to be constructed on one small slice of silicon material whereas VLSI squeezed hundreds of thousands of components onto a single ewp. ULTRA – large scale integration (ULSI) increased that number into millions the fourth generation computer became more powerful compact, reliable and affordable. For example apple ii, attair 8800 and CRAY-1 Characteristics of Fourth Generation Computers a. Fourth generation computers are microprocessor-based systems b. These computers are very small c. GUI and pointing devices enable users to learn to use the computer quickly d. Interconnection of computers leads to better communication and resource sharing 5. Fifth Generation (Present and Beyond): Artificial Intelligence A computer would learn from its mistakes and possess the skills of experts the starting point for the fifth generation of computers was set in the early 1990s. The expert system it defined as a computer information system that attempts to mimic the thought process and reasoning of experts in specific areas three characteristics can be identified with the fifth- generation computer these are. Mega chips Fifth-generation computers will use super large-scale integrated (SLSI) chips, which will result in the production of microprocessors having millions of electronic components on a single chip Parallel processing A computer using parallel processing accesses several instructions at once and works on them at the same time through use of multiple central processing units. Artificial intelligence: (AI) AI comprises a group of related technologies expert systems (ES), natural language processing (NLP) speech recognition, vision recognition and robotics. 13 Chapter 2 DATA REPRESENTATION 2.1 Introduction A number represents a thought that refers to a precise amount of something. Numbers can be expressed in words, gestures and symbols. When expressed in words, numbers are spoken out. Numbers are expressed through gestures using (usually) our hands. Numbers are expressed in symbols that can be written down. A number symbol is known as a numeral. Hence, a number is a precise idea about an amount, which you form in your minds when you look at a numeral, hear it when it is spoken or see it when it is signalled by hands. On hearing the word number, you immediately think of the familiar decimal number system with its 10 digits; 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. These numerals are called Arabic numerals. Your present number system provides modern mathematicians and scientists with great advantages over those of previous civilizations and is an important factor in our advancement. Since fingers are the most convenient tools nature has provided, human beings use them in counting. So, the decimal number system followed naturally from this usage. A number of base or radix r is a system that uses distinct symbols of r digits. Numbers are represented by a string of digit symbols. To determine the quantity that the number represents, it is necessary to multiply each digit by an integer power of r, and then form the sum of all the weighted digits. To develop a number system, you can choose any whole number greater than 1 as the base of the system. The base of a number system refers to the number of digits used in that system. There are four systems of arithmetic, which are often used in digital systems. These systems are: 1. Decimal 2. Binary 3. Octal 4. Hexadecimal The decimal number system has ten digits (0, 1, 2,……9), the octal system has eight digits (0,1,2,….7) the hexadecimal system has sixteen digits (0,1,2,…..9, A,B,C,D,E,F), the binary number system has only two (0,1) The number of digits in a system is called radix or base. Thus the decimal system may be called as radix-10 system, the binary system as radix – 2, system. The number system is basically two types (i) Non – positioning number system (ii) Positioning number system. (i) Non –positional number system Using this system, the symbols i.e, I for 1, II for 2, III for 3, IIII for 4, iiiii for 5 etc, are 14 used. In a non-positioning number system each symbol represents the same values regardless of its position in the number. The symbols are simply added to find out the value of a particular number. (ii) Positional number system The positional number user only a few symbols called digits Example: The decimal number 3977.39(10) 3×103 + 9×102 + 7×101 + 7×100 + 3×10-1 * 9×10-2 1000th 100th 10th Unit 1/10th 1/100th position position position position position position The following four positional number systems are commonly used. (1) Decimal number system (2) Binary number system (3) Octal number system (4) Hexadecimal system (1) Decimal number system In this number system, the base or radix is 10 and there are altogether ten numbers i.e., 0,1,2,3,4,5,6,7,8,9. A number in a radix system would be written as (an an-1 an-2 ……… a0.a-1 a-2 ……… a-m) In this representation an is called the ‘Most-Significant Digit’ (MSD) of the number and a- m is called the ‘Least Significant Digit’ (LSD). Example: In the decimal number system, 3967(10) or 3967 consists of the digits : 7 in the unit position (7×100) 6 in the unit position (6×101) 9 in the unit position (9×102) 3 in the unit position (3×103) It values can be written as 3×103+9×102+6×101+7×100 3×1000+9×100+6×10+7×1 3000+900+60+7 3967 3967(10) = 3967 15 (2) Binary number system The binary system uses only two digits i.e., 0’s and 1’s the base or radix of the binary number system is 2 because it contains only two numbers. User The circuits in the computer have to be handled by two binary digits or bits rather than the decimal number The computer only identifies signals in the form of digital pulses, which represent either high or low voltage. Everything that can be done with decimal numbers can also be done using binary numbers. Example: Convert the binary number 100111(2) to decimal numbers. Solution: 100111(2) =? (10) 6th 5th 4th 3rd 2nd 1st Position 1 0 0 1 1 1 Given Binary Number ×2 ×24 ×23 ×22 ×21 ×2 0 Weights 5 1×32 +0×16 + 0×8 + 1×4 + 1×2 + 1×1 32 + 0 + 0 + 4 + 2 + 1 = 39(10) 100111(2) = 39(10) Decimal Binary number equivalent 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 16 (3) Octal number system The number system with base or radix digit (8) is known as the octal number system. There are only eight digits i.e. 0,1,2,3,4,5,6,7 Each position in this number system represents a power of the base(8) The decimal equivalent of the octal number 3077(8) is (8) 3077 = 3×83+0×82+7×81+7×80 = 3×512 +0×64 +7×8+7×1 =1536+0+56+7 =1599(10) 3077(8) =1599(10) Decimal Octal Binary Equivalent 0 0 000 1 1 001 2 2 010 3 3 011 4 4 100 5 5 101 6 6 110 7 7 111 (4) Hexadecimal number system The base 16 suggests choices of 16 single character digits or symbol The first 10 digits are digits of the decimal system (0 to 9) and the remaining 6 digits are denoted by (A to F) representing decimal value (10 to 15) where a = 10, B = 11, C = 12, D = 13, E=14 and F = 16. The largest single digit is F or 15 ( one less than the base). Since numbers (0 to 9) and alphabets (A to F) are used to represent the digit in the hexadecimal numbers system, it is also called the alphanumeric number system. Decimal Hexadecim Binary al Equivalent 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 17 6 6 0110 7 7 0111 8 8 1000 9 9 1001 10 A 1010 11 B 1011 12 C 1100 13 D 1101 14 E 1110 15 F 1111 Example: Convert the hexadecimal number 39A (16) to decimal number Solution 39A(16) = ?(10) = 3×162+9×161+A×160 = 3×256 +9×16 +A×1 = 3×256 +9×16 +10×1 =768+144+10 =922(10) 39A(16)= 922(10) CONVERSION OF NUMBER SYSTEM Conversion of Decimal Number System Conversion of Binary Conversion of Octal Conversion of Hexadecimal CONVERSION OF DECIMAL NUMBER SYSTEM Decimal to binary system Decimal to octal Decimal to hexadecimal (1) Conversion of Decimal to Binary System Example: 18 Convert the 37.8125(10) decimal number to its binary equivalent Number Radix Result Residual 37 /2 =18 1 18 /2 =9 0 9 /2 =4 1 4 /2 =2 0 2 /2 =1 0 1 /2 =0 1 Therefore, 37(10) = 100101(2) Fraction Radix Result 0.8125 *2 =1.625 =0.625 with carry as 1 0.625 *2 =1.25 =0.25 with carry as 1 0.25 *2 =0.5 =0.50 with carry as 0 0.5 *2 =1.0 =0.00 with carry as 1 0.8125(10) = 0.1101 Therefore 37.8125(10) = 100101.1101(2) Exercise: Convert (68)10 to binary Answer = (1000100)2 (2) Conversion of Decimal to-Octal System Example: Convert the 35.45(10) decimal number to its octal equivalent Number Radix Result Residual 35 /8 =4 3 4 /8 =0 4 Therefore, 35(10)=43(8) Fraction Radix Result 0.45 *8 =3.6 = 0.6 with carry as 3 0.6 *8 =4.8 = 0.8 with carry as 4 0.8 *8 =6.4 = 0.4 with carry as 6 0.4 *8 =3.2 = 0.2 with carry as 3 0.2 *8 =1.6 = 0.6 with carry as 1 0.45(10) = 0.34631(8) Therefore, 35.45(10) = 43.34631(8) Exercise: Convert decimal number 214 to its octal equivalent Answer = 326 19 (3) Conversion of Decimal to Hexadecimal System Example: Convert the 22.64(10) decimal number to its hexadecimal equivalent. Number Radix Result Residual 22 /16 =1 6 1 /16 =0 1 Therefore, 22(10) = 16(16) Fraction Radix Result 0.64 *16 =10.24 = 0.24 with carry as 10=A 0.24 *16 =3.84 = 0.84 with carry as 3 0.84 *16 =13.44 = 0.44 with carry as 13=D 0.44 *16 =7.04 = 0.04 with carry as 7 0.44 *16 =13.44 = 0.44 with carry as 13=D 0.64(10) = 0.A3D7(16) Therefore, 22.64(10) =16.A3D7(16) Exercise: Convert decimal number 3509 to its hexadecimal equivalent Answer = 13115 =DB5(16) Conversion of Binary System Binary to decimal conversion Binary to octal Binary to hexadecimal (1) Binary to Decimal Conversion Example: Convert 1101.101(2) to its decimal equivalent = 1×2³+1×2²+0×2¹+1×2+1+1×2-1×0×2-2+1×2-3 = 8+4+0+1+0.5+0+0.125 = 13.625(10) Exercise: Convert (1000100)2 to its decimal equivalent Answer = (68)10 (2) Binary to Octal Conversion Example: Convert the 111101100(2) to its octal equivalent. Group the number by 3 111 101 100 Specify the octal equivalent 20 111 101 100 7 5 4 Therefore, the octal number is 754(8) Exercise: Convert 111 01 111 0 (2) to its equivalent octal number Answer = 735(8) (3) Binary to Hexadecimal Conversion Example: Convert the 1101100010011011(2) to its hexadecimal equivalent. Group the number by 4 1101 1000 1001 1011 Specify the hexadecimal equivalent 1101 1000 1001 1011 D 8 9 B Therefore, the octal number is D89B(16) Exercise: Convert 11111101. 0001 0011(2) to its equivalent hexadecimal number. Answer = FD13(16) Conversion of Octal Number System Octal to Decimal Conversion Octal to Binary Conversion Octal to Hexadecimal (1) Octal to Decimal Conversion Example: Convert the 51.63(8) to its decimal equivalent. =5×81+1×80+0.6×8-1×0.3×8-2 =40+1+(0.075+0.0046875) =41.0796875(10) Therefore, 51.63(8) = 41.0796875(10) Exercise: 516(8) = 324 (2) Octal to Binary Conversion Example: Convert the 51.63(8) to its binary equivalent. 21 5 1 6 3 ↓ ↓ ↓ ↓ 101 001 110 011 101001.110011(2) 51.63(8)=101001.110011(2) Therefore, the binary number is 101001.110011(2) Exercise: convert 5613 to its binary equivalent Answer = 1010011110011(2) Conversion of Hexadecimal Number System Hexadecimal to Decimal Conversion Hexadecimal to Binary Hexadecimal to Octal Hexadecimal to Decimal Conversion (1) Hexadecimal to Decimal Conversion Example: Convert the 5B.2E(10) to its decimal equivalent. =5×161+B×160+2×16-1×E×16-2 =80+11+(0.125+0.0546875) =91.1796875(10) 5B.2E(16)=91.1796875(10) Exercise 5B2(16) Answer = 1458 (2) Hexadecimal to Binary Conversion Convert the 8B2F.9A(16) to its binary equivalent. 8 B 2 F 9 A ↓ ↓ ↓ ↓ ↓ ↓ 1000 1011 0011 1111 1001 1010 8B2F.9A(16)=1000101100111111.10011010(2) Therefore, the binary number is 1000101100111111.10011010(2) Exercise 8B2F Answer = 1000101100101111(2) 22 LOGIC OPERATIONS 23 24 Chapter 3 COMPUTER SOFTWARE Definition Software is a generic term for an organized collection of computer data and instructions. It is responsible for controlling integrating and managing the hardware components of a computer and accomplishing specific tasks. For example: Software instructs the hardware what to display on the user’s screen, what kinds of input to take from the user and what kinds of output to generate. 2.1 Types of Software Software can be categorized as system software and application software. SYSTEM SOFTWARE System software as interface system software consists of several programs which one directly responsible for controlling, integrating and managing the individual hardware components of a computer system. This software provider a programming environment in which programmers can create applications to accommodate their needs system software acts as an interface between the hardware of the computer and the software applications 25 System software makes the computer functional they provide basic functionality like file management visual display and keyboard input and are used by application software to accomplish these functions. Some examples of system software are operating systems, device drivers language translators and system utilities. Operating system The operating system is the first layer of software loaded into computer memory when it starts up as the first software layer, all other software that gets loaded after it depends on it for various common care services. These common core services include disk access, memory management task scheduling and user interfacing. The operating system organizes and controls the hardware. Examples of operating systems are Windows XP, UNIX and LINUX. Device Drivers Device drivers are system programs, which are responsible for proper functioning of devices every device, whether it is a printer, monitor, mouse or keyboard, has a driver associated with it per its proper functioning In modern operating systems, most hardware drivers, such as the keyboard drivers, come with the operating system. Language Translators Computers only understand a language consisting of os and ls called machine language. Depending on the programming language used language translators are divided into three major categories. Computer interpreser and assembles Language Description Translators Compiler The programs written in any high-level programming language (C or Pascal) are converted into machine language using a compiler. 26 Interpreter An interpreter analyses and executes the source code in a line-by-line Manner, without looking at the entire program. Assembler Compared to all the types of programming languages, assembly Language is closest to the machine code. An assembler converts the assembly codes into machine codes, making the assembly program ready for execution. System Utility System utility programs perform day-to-day tasks related to the maintenance of the computer system they are used to support enhance, and secure existing programs and data in the computer system. APPLICATION SOFTWARE Application software may consist of a single program, such as Microsoft Notepad it may also consist of a collection of programs often called a software package which work together to accomplish a task, such as database management software. Application software ranges from games, calculators and word processors document creating programs to programs that “paint” images on screen (image editors) some of the most commonly used application software are discussed below. Word processors A word processor is a software used to compose, format, edit and print electronic documents. It involves not only typing but also checking the spelling and grammar of the text and arranging it correctly on a page. It is possible to include pictures, graphs, charts fonts and colour. Nowadays, virtually all personal computers are equipped with the word or other documents and 27 printing Examples of some well-known word processors are Microsoft Word and Word Perfect. Spreadsheets One of the first commercial uses of computers was in processing payroll and other financial records. A spreadsheet application is a rectangular grid, which allows text, numbers and complex functions to be entered into a matrix of thousands of individual cells. The spreadsheet provides sheets containing calls each of which may contain text and/ or a number of cells may also contain equations that calculate results from data placed in other cells or series of cells. Microsoft Excel and Lotus 1-2-3 are examples of spreadsheet applications. Image Editors 28 Image editor programs are designed specifically for capturing, creating, editing and manipulating images. These graphics programs provide a variety of special features per creating and altering images. In addition to offering a host of filters and image transformation algorithms, some editors also enable the user to credit and superimpose layers. With image editing software, one can darken or lighten an image, rotate it, adjust its contrast, crop out extraneous detail and much more. Examples of these programs are Adobe Photoshop, Adobe illustrator and Corel Draw. Database management systems Database management software is a collection of computer programs that allow storage modification and extraction of information from a database in an efficient manner. It provides tools for data input, verification storage, retrieval, query and manipulation. New categories of data can be added to the database without disrupting the existing system. Forpro and Oracle are database management systems. Presentation applications A presentation is a means of assessment which requires presentation providers 29 to present their work orally in the presence of an audience. It combines both visual and verbal elements presentation software allows the user to create presentations by producing slides or windows per presentation of projects. Microsoft PowerPoint is one of the most famous presentation applications. Desktop publishing software The term desktop publishing is usually used to describe the creation of printed documents using a desktop computer. It is a technique of using a personal computer to design images and pages, and assemble type and graphics, then using a laser printer or imagesetter to output the assembled pages onto paper, film or printing plate. Quark Express and Adobe Page Maker are desktop publishing software. SOFTWARE DEVELOPMENT STEPS Software development is the set of activities that results in software produces. Software development may include research, new development, modification, reuse, re-engineering, maintenance or any other activities that result in software product Software development life cycle (SDLC) The various phases of software development involves the performance of many people. User The user is a person who will use the software. System Analyst A system analyst is the person who meets the users and gathers the information System Designer System design is the specialist who designs the system or software. Programs 30 A programmer is a person who writes the code that implements the user requirements. Project manager Project manager is a person who manager the entire team Testing team Testing the software is done by this testing team. Bugs are identified and reported. The following are the flow of software development life cycle. Requirement – Analysis The objective of the requirement analysis is to identify and document he user requirements for the proposed system. The main objective of the requirements analysis is to produce a document that property specifies all requirements of the customers. That is called the Software Requirement Specifications (SRS) document is the primary output of this place. This process involves analysis which meets with interviews and observe knowledge, a n d users to understand what the requirements are, in addition existing systems, processes, documents and procedures are also reviewed. Design Process It defines specifically how the software is to be written including an object model with properties and methods for each object, analysis and design are very crucial in the whole development cycle. Development or Coding The design must be translated into machine-readable form. The coding or development step performs this task. Different high-level languages like C, C++, JAVA, COBOL etc. are used for 31 coding, with respect to the type of application, the right programming language is chosen. Testing Testing is the process of executing the proposed software with sample or test data and put it into regular use. Once the code is generated, the program testing begins. Different testing tools and methodologies are already own testing tools that are tailor-made per their own development operations. Implementation and Maintenance It involves installation and initial training and may involve training and may involve hardware and network upgrades. Software will definitely undergo changes once it is delivered to the customer. In addition, the changes in the system could directly affect the software operations. The software should be developed to accommodate changes that could happen during the post-implementation period. The maintenance phase of the project is the last component and it continues as long as a warranty, extended warranty or support contract is in place. 32 Chapter 4 PROBLEM-SOLVING AND OFFICE APPLICATION SOFTWARE 4.1 PLANNING THE COMPUTER PROGRAM Program Definition A program is a set of instructions written to carry out a particular task so that a computer can follow them To solve the problem using computers we must follow the steps below. (a) The problem must be analyzed thoroughly, (b) The solution method is broken down into a sequence of small tasks. (c) Based on this analysis an algorithm must be prepared to solve the problem (d) The algorithm must be expressed in a precise notation (e) In viewing algorithms, design a computer program in any high-level language. (f) The computer program is fed into the computer. (g) The instruction in the program, executes one after another and outputs the expert result. Calculate the sum of two numbers, A and B and store the sum in c, where a and b are the input addition is the process and c is the output of the program 4.2 PROBLEM SOLVING TECHNIQUES Algorithms An algorithm is defined as a finite sequence of explicit instructions that, when provided with a set of input values, produces an output and then terminates. In the algorithm, after a finite number of steps, a solution to the problem is achieved. Algorithms can have steps that repeat (iterate) or require a decision (logic and comparison) until the task is completed. For example, to determine the largest number out of three numbers A,B and C the following algorithm may be used.Step 1: start Step 1: Start Step 2: Read three numbers say A, B, C Step 3: Read the larger number between A and B and store it in MAX_AB. Step 4: Find the larger number between MAX_AB, and C and store it in MAX. Step 5: Display MAX. Step 6: Stop. 33 Algorithm properties (1) There must be no ambiguity in any instruction (2) There should not be any uncertainty about which instruction is to be executed next. (3) The algorithm should conclude after a finite number of steps an algorithm cannot be open-ended (4) The algorithm must be general enough to deal with any contingency. 4.3 FLOWCHART A flowchart is a pictorial representation of an algorithm in which the steps are drawn in the form of different shapes of boxes and the logical flow is indicated by an interconnecting arrow. The boxes represent operations and the arrows represent the sequence in which the operation are implemented. The primary purpose of the flowchart is to help the programs in understanding the logic of the program. Standard flowchart symbols prescribed by the American nations standard institute (ANSI) Flowchart symbols Symbol Symbol name Description Flow lines Flow lines are used to connect symbols. These lines indicate the sequence of steps and the direction of flow of control. Terminal This symbol is used to represent the beginning (star), the termination (end) or halt (pause) in the program logic. Input / Output It represents information entering or leaving the system, such as customer order(input) and servicing(output) Processing Process symbol is used for representing arithmetic and data movement instructions. Decision Decision symbol denotes a decision (or branch). The program should continue along one the two routes (IF/ELSE). This symbol has one entry and two exit paths. The path chosen depends on whether answer to a question is yes or no. 34 Connector Connector symbol is used to join different flow lines. Off-page This symbol is used to indicate that connector the flowchart continues on the next page. Document Document is used to represent a paper document produced during the flowchart process. Annotation It is used to provide additional information about another flowchart symbol. the content may be in the form of descriptive comments remarks or explanatory notes. Manual Input Manual input sysmbol representes input to be given by a developer programmer Manual Input It represents input to be given by a developer/ programmer Online storage This symbol represents the online data storage such as hard disk, magnetic drums, or other storage. Offline storage This symbol represents the offline data storage such as sales on OCR and data on punched cards Communication Communication link symbol is used to Link represent data received or to be transmitted from an external system. Magnetic Disk This symbol is used to represent data input or output from and to a magnetic disk. 35 Guidelines for preparing flowcharts The flowchart should be clear, neat and easy to follow The flowchart must have a logical start and finish In drawing a proper flowchart, all requirements should be listed in logical order. Only one flow line should come out from a process symbol (or) Only one flow line should enter a decision symbol. However, two or three flow lines may leave the decision symbol Only one flow line is used with a terminal symbol (or) Within the standard symbol write briefly necessary, and use the annotation symbol to describe data or process more clearly In the case of complex flowcharts, connector symbols are used to reduce 36 the number of flowlines 37 Intersection of flow lines should be avoided to make it a more effective and better way of representing communication It is useful to test the validity of the flowchart with normal/ unusual test data. Benefit of Flowchart Makes Logic Clear The main advantage of using a flowchart to plan a task is that it provides a pictorial representation of the basics which makes the logic easier to follow Communication Being a graphical representation of problem–solving logic, flowcharts are a better way of communicating the logic of a system to all conserved. Effective Analysis With the help of a flowchart, the problem can be analyzed effectively. Useful in Coding The flowcharts act as a guide or blueprint during the analysis and program development phase. Proper Testing and Debugging By nature, a flowchart helps in detecting the errors in a program, as the developers know exactly what the logic should do. Appropriate Documentation Flow charts serve as a good program documentation tool. Limitations of Flowcharts Complex The major disadvantage of using flowcharts is that when a program is very large, the flowcharts may continue per many pages, making them hard to follow. Costly Drawing flowcharts is viable only if the problem-solving logic is straightforward and not very lengthy. Difficult to Modify Due to its symbolic nature, any changes or modifications to a flowchart usually require redrawing the entire logic again and redrawing a complex flowchart is not a simple basic. 38 No Update Usually, programs are updated regularly 4.4 PSEUDOCODE Pseudocode is made up of two words pseudo and code. Pseudo means limitation and code refers to instructions, written in a programming language. The pseudocode used plain English statements rather than symbols to represent the processes of a computer program. It is also known as PDL (Program Design Language) For example, the pseudocode given below calculated the area of a rectangle. PROMT the user to enter the height of the rectangle PROMT the user to the enter the width of the rectangle COMPUTE the area by multiplying the height with width DISPLAY the area STOP Pseudocode uses some keywords to denote programming processes. Some of them are: Input: READ, OBTAIN, GET and PROMPT Output: PRINT, DISPLAY AND SHOW Compute: XOMPUTE, CALCULATE AND DETERMINE Initialize: SET AND INITIALISE Add One: INCREMENT Pseudocode Guideline Statements should be written in simple English and should be programming language independent. Steps must be understandable and when the steps ……. Are followed the must produce a solution to the specified problem Pseudocodes should be concise. Each instruction should be written in a separate line and each statement in pseudocode should express just one action per the computer. Capitalize keywords such as READ, PRINT and so on. Each set of instructions is written from top to bottom, with only one entry and one exit. It should allow for an easy transition from design to coding in the programming language Benefits of Pseudocode 39 Since it is language-independent, it can be used by most programmes, it allows the developer to express the design in plain natural language. It is easier to develop a program from a pseudocode than with a flowchart Often, it is easy to translate pseudocode into a programming language a step which can be accomplished by less experienced programmes. The use of words and phrases in pseudocode, which are in line with basic computer operations, simplifier the translation from the pseudocode algorithm to a specific programming language. Its simple structure and readability make it easier to modify. Limitations of Pseudocode The main disadvantage of using pseudocode is that it does not provide a visual representation of the program’s logic Pseudocode can not be complied with nor executed and more are not real formatting or syntax rules Problem-solving through Algorithms, Flowcharts and Pseudocode 1. Write a program to convert the Celsius into Fahrenheit. Algorithm: Step 1: Start Step 2: Read the Celsius value Step 3: Calculate the Fahrenheit value by using the formula: Fahrenheit (1.8* Celsius) + 32 Step 4: Print the Fahrenheit value Step 5: Stop Flowchart: 40 Pseudocode: Set initial Celsius READ the value of Celsius Calculate faren = (1.8*Celsius) +32 Write the output Fahrenheit Stop 2. Write a program to find areas of the triangle Flowchart Algorithm: Step 1: Start Step 2: Read the value of A,B,C Step3: To calculate three sides of the triangle using the formula S ← (A+B+C)/2 Step 4: To Find the area of a triangle apply the formula Area sqrt (S*(S – A)*(S–B)*(S–C)) Step 5: Print the area Step 6: Stop Pseudocode: Set initial A,B,C Read the value of A,B,C To calculate three sides of the triangle using formula s = (A+B+C)/2 To find the area of a triangle using the formula Area sqrt (S*(S – A)*(S–B)*(S– C)) WRITE the output area Stop 41 3. Write a program to find the largest of three numbers. Flowchart: Algorithm: Step1 : Start Step2: READ A, B, C Step 3: IF (A>B) and (A>C) Then print ‘A is Big’. Step 4: Else, IF (B>C) Then print ‘B is Big’ Step 5: Else print ‘C is Big’ Step 6: Stop. Pseudo code: Set initial a, b, c READ the value for a, b, c IF (a>b) and (a>c) THEN WRITE ‘A is Big’ Else, IF (b>c) THEN WRITE ‘B is Big’ ELSE WRITE ‘C is Big’ END IF Stop. 4. Write a program to find if the given year is a leap year or not. Flowchart 42 Algorithm: Step 1: Start. Step 2: Read the value of the year. Step 3: if ((year mod 4) = 0) then print “It is a Leap Year”. ELSE print “It is not Leap Year” Step 4: Stop. Pseudo code: Set initial value of the year. READ the value of the year. IF (year % 4 == 0) Then WRITE the year is a leap year ELSE WRITE the year is not a leap year ENDIF STOP. 43 Chapter 5 INTRODUCTION TO C++ 5.1 OVERVIEW OF C++ C++ is an object–oriented programming language C++ was developed by Bjarne Stroustrup at AT & T Bell Laboratories in Murray Hill, New Jersey, USA The idea of C++ comes from the c increment operator ++, thereby suggesting that C++ is an incremented version of C Most of what we already know about applies to C++ also Therefore, almost all c programs are also C++ programs The three most important facilities that C++ adds onto C are classes, function overloading and operator overloading 5.2 APPLICATIONS OF C++ C++ is a versatile language for handling very large programs. It is suitable for virtually any programming task including the development of editors, compilers, databases, communication systems and any complex real-life application system Since C++ allows us to create hierarchy-related objects, we can build special object-oriented libraries which can be used later by many programmers While C++ is able to map the real-world problem property, the c part of C++ gives the language the ability to get close to the machine–level details When new features need to be implemented, it is very easy to add to the existing structure of an object. A simple C++ program Example: Printing a string #include // include header file main() { count0; n--) { cout