You are on page 1of 46

NOTES ON FUNDAMENTALS OF COMPUTER AND PROGRAMMING ON UNIT I AND UNIT II SYLLABUS AS PER UTTRAKHAND TECHNICAL UNIVERSITY UNIT-I Introduction

to Computer Systems; Data representation: Number systems, character representation codes, Binary, hex, octal codes and their inter conversions. Binary arithmetic, Floating point arithmetic, signed and unsigned numbers IEEE standards, CPU organization, ALU, registers, memory, the idea of program execution at micro level. Concept of computing, contemporary Operating Systems such as DOS, Windows, UNIX etc. (only brief user level description). Introduction to organization and architecture of mainframe, mini and micro systems. UNIT-II Concept of flow chart and algorithm; Algorithms to programs: specification, top-down development and stepwise refinement ,Introduction to the design and implementation of correct, efficient and maintainable programs, structured Programming, Use of high level programming language for the systematic development of programs, programmability and programming languages, Object codes, compilers. Introduction to the Editing tools such as vi or MS-VC editors. (Possible Theoritical Questions and Answers From Unit 1 & 2)

Question No: (1) Define computers? Why computer is known as data processing system? What are the basic operations of Computer?
Answer: Computer: A computer is a programmable machine or device that performs pre-defined or programmed computations or controls operations that are expressible in numerical or logical terms at high speed and with great accuracy. Computer is a fast operating electronic device, which automatically accepts and store input data, processes them and produces results under the direction of step by step program. Any Process that uses a computer program will enter data and summarize, analyze or otherwise convert data into usable information. The process may be automated and run on a computer. It involves recording, analyzing, sorting, summarizing, calculating, disseminating and storing data. Thus Computer is known as data processing system. Its various operations are: 1) It accepts data or instructions by way of input. 2) It stores data. 3) It can process data as required by the user. 4) It gives results in the form of output. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 1

5) It controls all operations inside a computer.

QuestionNo:(2). What is Data and Information? Give the applications of computer? What are the characteristics of computers?
Answer: Data -Data is the fact or raw material for the information processing. Information The processed data is called information. Applications of computer Word Processing Internet Desktop publishing Digital video or audio composition Mathematical Calculations Robotics Weather analysis Characteristics of computers Speed Accuracy. Automation. Endurance. Versatility. Storage. Cost Reduction. Question No: (3). How will you classify computer systems? Answer: Based on physical size, performance and application areas, we can generally divide computers into four major categories: 1. Micro computer 2. Mini Computer 3. Mainframe computer and 4. Super Computer Personal computers/Micro computers: A small, relatively inexpensive computer designed for an individual user. In price, personal computers range anywhere from a few hundred dollars to thousands of dollars. All are based on the microprocessor technology that enables manufacturers to put an entire CPU on one chip. Example: B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 2

Businesses use personal computers forward processing, accounting, desktop publishing, and for running spreadsheet and database management applications. At home, the most popular use for personal computers is for playing games. Mainframe computer Mainframes are computers used mainly by large organizations for critical applications, typically bulk data processing such as census, industry and consumer statistics, enterprise resource planning, and financial processing. The term probably had originated from the early mainframes, as they were housed in enormous, room-sized metal boxes or frames. Mini computers: A mini computer is a multi-user or time-sharing system. It is used for medium scale data processing such as Bank account processing, Payroll processing etc., Mini computer process greater storage capacity and larger memories as compared to micro computer. Super computer The fastest type of computer. Supercomputers are very expensive and are employed for specialized applications that require immense amounts of mathematical calculations. For example, weather forecasting requires a supercomputer. Other uses of supercomputers include animated graphics, fluid dynamic calculations, nuclear energy research, and petroleum exploration.

Question No: (4). Explain the fundamental units of a computer with a block diagram? Explain the basic computer organization in detail?
Answer: A computer can process data, pictures, sound and graphics. They can solve highly Complicated problems quickly and accurately.

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 3

Input Unit: Computers need to receive data and instruction in order to solve any problem. Therefore we need to input the data and instructions into the computers. The input unit consists of one or more input devices. Keyboard is the one of the most commonly used input device. Other commonly used input devices are the mouse, floppy disk drive, magnetic tape, etc. All the input devices perform the following functions. Accept the data and instructions from the outside world. Convert it to a form that the computer can understand. Supply the converted data to the computer system for further processing. e.g. Keyboard, Scanner, Mouse, Joystick, Mike etc Storage Unit: The storage unit of the computer holds data and instructions that are entered through the input unit, before they are processed. It preserves the intermediate and final results before these are sent to the output devices. It also saves the data for the later use. Types of Storage Devices: (A) Primary Storage: 1. Stores and provides very fast. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 4

2. This memory is generally used to hold the program being currently executed in the computer, the data being received from the input unit, the intermediate and final results of the program. 3. The primary memory is temporary in nature. The data is lost, when the computer is switched off. 4. In order to store the data permanently, the data has to be transferred to the secondary memory. The cost of the primary storage is more compared to the secondary storage. e.g. RAM, ROM etc (B) Secondary Storage: 1. It stores several programs, documents, data bases etc. 2. The programs that run on the computer are first transferred to the primary memory before it is actually run. 3. Whenever the results are saved, again they get stored in the secondary memory. 4. The secondary memory is slower and cheaper than the primary memory. Some of the commonly used secondary memory devices are Hard disk, CD, etc., e.g. CD-ROM, HDD, FLOPPY DRIVE etc Memory Size: All digital computers use the binary system, i.e. 0s and 1s. Each character or a number is represented by an 8 bit code. The set of 8 bits is called a byte. A Character occupies 1 byte space. A numeric occupies 2 byte space. Byte is the space occupied in the memory. The size of the primary storage is specified in KB (Kilobytes) or MB (Megabyte). One KB is equal to 1024 bytes and one MB is equal to 1000KB. The size of the primary storage in a typical PC usually starts at 16MB. PCs having 32 MB, 48MB, 128 MB, 256MB memory are quite common. Output Unit: The output unit of a computer provides the information and results of a computation to outside world. Printers, Visual Display Unit (VDU) are the commonly used output devices. Other commonly used output devices are floppy disk drive, hard disk drive, and magnetic tape drive. Arithmetic Logical Unit: All calculations are performed in the Arithmetic Logic Unit (ALU) of the computer. It also does comparison and takes decision. The ALU can perform basic operations such as addition, subtraction, multiplication, division, etc and does logic operations viz, >, <, =, etc. Whenever calculations are required, the control unit transfers the data from storage unit to ALU once the computations are done, the results are transferred to the storage unit by the control unit and then it is send to the output unit for displaying results. Control Unit:

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 5

It controls all other units in the computer. The control unit instructs the input unit, where to store the data after receiving it from the user. It controls the flow of data and instructions from the storage unit to ALU. It also controls the flow of results from the ALU to the storage unit. The control unit is generally referred as the central nervous system of the computer that control and synchronizes its working. Central Processing Unit: The control unit and ALU of the computer are together known as the Central Processing Unit (CPU). The CPU is like brain performs the following functions: It performs all calculations. It takes all decisions. It controls all units of the computer. A PC may have CPU-IC such as Intel 8088, 80286, 80386, 80486, Celeron, Pentium, Pentium Pro, Pentium II, Pentium III, Pentium IV, Dual Core, and AMD etc.

QuestionNo:(5). With suitable examples, explain about Number systems?


Answer: A number system is a set of rules and symbols used to represent a number. There are several different number systems. Some examples of number systems are as follows: Binary (base 2) Octal (base 8) Decimal (base 10) Hexadecimal (base 16) Decimal and Hexadecimal numbers can each be represented using binary values. This enables decimal, hexadecimal, and other number systems to be represented on a computer which is based around binary (0 or 1 / off or on). The base (or radix) of a number system is the number of units that is equivalent to a single unit in the next higher counting space. In the decimal number system, the symbols 0-9 are used in combination to represent a number of any sizes. For example, the number 423 can be viewed as the following string of calculations: (4 x 100) + (2 x 10) + (3 x 1) = 400 + 20 + 3 = 423

QuestionNo:(6). Explain various generations of computers with features?


Answer: Generation of Computers: Each phase of computer development is known as a separate generation of computers. The computer can be classified into four generations according to their type of electronic circuits such as vacuum tube, transistor, IC etc. (a) The First Generation Computers (1949-55) B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 6

Main Features: 1) The computers of this generation used vacuum tubes. 2) These computers used machine language for giving instructions. 3) They used the concept of stored program. 4) These computers were 5000 times faster than the MARK-I. 5) The first generation computers were welcomed by Government and Universities. Limitations: 1)These computers were very big in size. The ENIAC machine was 30 x 50 feet in size and 30 tons in weight. So, these machines required very large space for their workings. 2)Their power consumption was very high. 3)These computers had slow operating speed and small computing capacity. 4)These computers had a very small memory. (b) The Second Generation Computers (1956-65) MainFeatures: 1) The computers of this generation replaced vacuum tubes with transistors. 2) Magnetic cores were invented for storage. 3) Different magnetic storage devices were developed in this generation. 4) Commercial applications were developed during this period. Eighty percent of these computers were used in business and industries. (c) Third Generation Computers (1966-75) MainFeatures: The third generation computers replaced transistors with Integrated Circuits. These Integrated Circuits are also known as chips. The size of main memory was increased and reached about 4 megabytes. Magnetic disk technology had been improved and drive having capacity upto 100 MBPS came into existence. The CPU becomes more powerful with the capacity of carrying out 1 million instructions per second. This generation computers were relatively inexpensive and faster. The application area also increased in this generation. The computers were used in other areas like education, small businesses survey, analysis along with their previous usage areas. (d) The Fourth Generation Computers (1976-Present) MainFeatures: i.The fourth generation computers replaced small scale integrated circuits and medium scale integrated circuits with the microprocessors chip. ii. Semiconductor memories replaced magnetic core memories. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 7

iii. The hard-disks are available of the sizes upto 200 GB. The RAID technology (Redundant Array of Inexpensive Disks) gives storage upto thousands of GB. iv. Computer cost came down rapidly in this generation. v. Application of computers is increased in various areas like visualization, parallel computing, multimedia etc. (e) The Fifth Generation Computers Mankind along with the advancement in science and technology is working hard to bring the Vth Generation of computer. These computers will have the capability of thinking on their own like an man with the help of Artificial Intelligence (AI). the 21st century will be better, faster, smaller and smarter computers.

QuestionNo:(6). Explain the classification of computers?


Answer: CLASSIFICATION OF COMPUTERS Personal Computers: A personal computer (PC) is a self-contained computer capable of input, processing, output, and storage. A personal computer is designed to be a single-user computer and must have at least one input device, one output device, a processor, and memory. The three major groups of PCs are desktop computers, portable computers, and handheld computers. Desktop Computers: A desktop computer is a PC designed to allow the system unit, input devices, output devices, and other connected devices to fit on top of, beside, or under a users desk or table. This type of computer may be used in the home, a home office, a library, or a corporate setting. Portable Computers: A portable computer is a PC small enough to be moved around easily. As the name suggests, a laptop computer fits comfortably on the lap. As laptop computers have decreased in size, this type of computer is now more commonly referred to as a notebook computer. Manufacturers recently began introducing a new type of computer called the tablet PC, which has a liquid crystal display (LCD) screen on which the user can write using a special-purpose pen, or stylus. Tablet PCs rely on digital ink technology that allows the user to write on the screen. Another type of portable computer, called a wearable computer, is worn somewhere on the body, thereby providing a user with access to mobile computing capabilities and information via the Internet. Handheld Computers: An even smaller type of personal computer that can fit into the hand is known as a handheld computer (also called simply handheld, pocket PC, or Palmtop). In recent years, a type of handheld computer called a personal digital assistant (PDA) has become widely used for performing calculations, keeping track of schedules, making appointments, and writing memos. Some B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 8

handheld computers are Internet-enabled, meaning they can access the Internet without wire connections. For example, a smart phone is a cell phone that connects to the Internet to allow users to transmit and receive e-mail messages, send text messages and pictures, and browse through Web sites on the phone display screen. Workstations: A workstation is a high-performance single-user computer with advanced input, output, and storage components that can be networked with other workstations and larger computers. Workstations are typically used for complex applications that require considerable computing power and highquality graphics resolution, such as computer-aided design (CAD), computer-assisted manufacturing (CAM), desktop publishing, and software development. Midrange Servers/Minicomputers: Linked computers and terminals are typically connected to a larger and more powerful computer called a network server, sometimes referred to as a host computer. Although the size and capacity of network servers vary considerably, most are midrange rather than large mainframe computers. (i) Midrange server formerly known as a minicomputer, a midrange server is a powerful computer capable of accommodating hundreds of client computers or terminals (users) at the same time. (ii) Terminal a device consisting of only a monitor and keyboard, with no processing capability of its own. Mainframe Computers: Larger, more powerful, and more expensive than midrange servers, a mainframe computer is capable of accommodating hundreds of network users performing different computing tasks. These computers are useful for dealing with large, ever-changing collections of data that can be accessed by many users simultaneously. Government agencies, banks, universities, and insurance companies use mainframes to handle millions of transactions each day.

Supercomputers: A supercomputer is the fastest, most powerful, and most expensive of all computers. Many are capable of performing trillions of calculations in a single second. Primary applications include weather forecasting, comparing DNA sequences, creating artificially intelligent robots, and performing financial analyses.

QuestionNo:(7). Explain Second Memory in detail?


B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 9

Answer: Secondary storage devices, as indicated by the name, save data after it has been saved by the primary storage device, usually referred to as RAM (Random Access Memory). From the moment we start typing a letter in Microsoft Word, for example, and until we click on "Save," your entire work is stored in RAM. However, once you power off your machine, that work is completely erased, and the only copy remaining is on the secondary storage device where we saved it, such as internal or external hard disk drive, optical drives for CDs or DVDs, or USB flash drive. Internal Hard Disk Drive The internal hard disk drive is the main secondary storage device that stores all of your data magnetically, including operating system files and folders, documents, music and video. The hard disk drive is a stack of disks mounted one on top of the other and placed in a sturdy case. They are spinning at high speeds to provide easy and fast access to stored data anywhere on a disk. External Hard Disk Drive External hard disk drives are used when the internal drive does not have any free space and you need to store more data. In addition, it is recommended to always back up all of our data and an external hard drive can be very useful, as they can safely store large amounts of information. They can be connected by either USB connection to a computer and can even be connected with each other in case you need several additional hard drives at the same time. Optical Drive An optical drive uses lasers to store and read data on CDs and DVDs. It basically burns a series of bumps and dips on a disc, which are associated with ones and zeros. Then, this same drive can interpret the series of ones and zeros into data that can be displayed on your monitors. There are a few different types of both CD and DVD disks, but the main two types include R and RW, which stand for Recordable (but you can write information on it just once) and Rewritable (meaning you can record data on it over and over again). USB Flash Drive USB flash memory storage device is also portable and can be carried around on a key chain. This type of a secondary storage device has become incredibly popular due to the very small size of device compared to the amount of data it can store (in most cases, more than CDs or DVDs). Data can be easily read using the USB (Universal Serial Bus) interface that now comes standard with most of the computers.

Question No: (8). Explain about memory in Computer System?(or) Write short notes on memory of a computer?
Answer: The Role of Memory: The term "memory" applies to any electronic component capable of temporarily storing data. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 10

There are two main categories of memories: Internal memory that temporarily memorizes data while programs are running. Internal memory uses micro conductors, i.e. fast specialized electronic circuits. Internal memory corresponds to what we call random access memory (RAM). Auxiliary memory (also called physical memory or external memory) that stores information over the long term, including after the computer is turned off. Auxiliary memory corresponds to magnetic storage devices such as the hard drive, optical storage devices such as CD-ROMs and DVD-ROMs, as well as read-only memories. Technical Characteristics (a) Capacity, representing the global volume of information (in bits) that the memory can store (b) Access time, corresponding to the time interval between the read/write request and the availability of the data (c) Cycle time, representing the minimum time interval between two successive accesses (d) Throughput, which defines the volume of information exchanged per unit of time, expressed in bits per second (e) Non-volatility, which characterizes the ability of a memory to store data when it is not being supplied with electricity The ideal memory has a large capacity with restricted access time and cycle time, a high throughput and is non-volatile. However, fast memories are also the most expensive. This is why memories that use different technologies are used in a computer, interfaced with each other and organized hierarchically. The fastest memories are located in small numbers close to the processor. Auxiliary memories, which are not as fast, are used to store information permanently. Types of Memories

Random Access Memory Random access memory, generally called RAM is the system's main memory, i.e. it is a space that allows you to temporarily store data when a program is running. Unlike data storage on an auxiliary memory such as a hard drive, RAM is volatile, meaning that it only stores data as long as it supplied with electricity. Thus, each time the computer is turned off, all the data in the memory are irremediably erased. Read-Only Memory Read-only memory, called ROM, is a type of memory that allows you to keep the information contained on it even when the memory is no longer receiving electricity. Basically, this type of memory only has read-only access. However, it is possible to save information in some types of ROM memory. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 11

Flash Memory Flash memory is a compromise between RAM-type memories and ROM memories. Flash memory possesses the non-volatility of ROM memories while providing both read and writes access However, the access times of flash memories are longer than the access times of RAM.

QuestionNo:(9). Elaborate the various Peripheral (Input and Output) Devices?


Answer: Input/Output devices are required for users to communicate with the computer. In simple terms, input devices bring information INTO the computer and output devices bring information OUT of a computer system. These input/output devices are also known as peripherals since they surround the CPU and memory of a computer system. Some commonly used Input/Output devices are listed in table below. (a)Keyboard It is a text base input device that allows the user to input alphabets, numbers and other characters. It consists of a set of keys mounted on a board. AlphanumericKeypad: It consists of keys for English alphabets, 0 to 9 numbers, and special characters like + / * ( ) etc. FunctionKeys: There are twelve function keys labeled F1, F2, F3 F12. The functions assigned to these keys differ from one software package to another. These keys are also user programmable keys. Special-functionKeys These keys have special functions assigned to them and can be used only for those specific purposes. Functions of some of the important keys are defined below. Enter-It is similar to the return key of the typewriter and is used to execute a command or program. Spacebar-It is used to enter a space at the current cursor location. Backspace-This key is used to move the cursor one position to the left and also delete the character in that position. Delete-It is used to delete the character at the cursor position. Insert-Insert key is used to toggle between insert and overwrite mode during data entry. Shift-This key is used to type capital letters when pressed along with an alphabet key. Also used to type the special characters located on the upper-side of a key that has two characters defined on the same key. Caps Lock-Cap Lock is used to toggle between the capital lock features. When on, it locks the alphanumeric keypad for capital letters input only. Tab-Tab is used to move the cursor to the next tab position defined in the document. Also,it is used to insert indentation into a document. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 12

Ctrl-Control key is used in conjunction with other keys to provide additional functionality on the keyboard. Alt-Also like the control key, Alt key is always used in combination with other keys to perform specific tasks. Esc-This key is usually used to negate a command. Also used to cancel or abort executing programs. Numeric Keypad Numeric keypad is located on the right side of the keyboard and consists of keys having numbers (0 to 9) and mathematical operators (+ * /) dened on them. This keypad is provided to support quick entry for numeric data. Cursor Movement Keys These are arrow keys and are used to move the cursor in the direction indicated by the arrow (up, down, left, right). (b) Mouse The mouse is a small device used to point to a particular place on the screen and select in order to perform one or more actions. It can be used to select menu commands, size windows, start programs etc. The most conventional kind of mouse has two buttons on top: the left one being used most frequently. Mouse Actions Left Click :Used to select an item. Double Click : Used to start a program or open a file. Right Click : Usually used to display a set of commands. Drag and Drop : It allows you to select and move an item from one location to another. To achieve this place the cursor over an item on the screen, click the left mouse button and while holding the button down move the cursor to where you want to place the item, and then release it. (c) Joystick The joystick is a vertical stick which moves the graphic cursor in a direction the stick is moved. It typically has a button on top that is used to select the option pointed by the cursor. Joystick is used as an input device primarily used with video games, training simulators and controlling robots (d)Scanner Scanner is an input device used for direct data entry from the source document into the computer system. It converts the document image into digital form so that it can be fed into the computer. Capturing information like this reduces the possibility of errors typically experienced during large data entry. Hand-held scanners are commonly seen in big stores to scan codes and price information for each of the items. They are also termed the bar code readers.

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 13

(e) Bar code Reader: A bar code is a set of lines of different thicknesses that represent a number. Bar Code Readers are used to input data from bar codes. Most products in shops have bar codes on them. Bar code readers work by shining a beam of light on the lines that make up the bar code and detecting the amount of light that is reflected back (f) Light Pen: It is a pen shaped device used to select objects on a display screen. It is quite like the mouse (in its functionality) but uses a light pen to move the pointer and select any object on the screen by pointing to the object. Users of Computer Aided Design (CAD) applications commonly use the light pens to directly draw on screen. (g) Touch Screen: It allows the user to operate/make selections by simply touching the display screen. Common examples of touch screen include information kiosks, and bank ATMs. (h)Digital camera: A digital camera can store many more pictures than an ordinary camera. Pictures taken using a digital camera are stored inside its memory and can be transferred to a computer by connecting the camera to it. A digital camera takes pictures by converting the light passing through the lens at the front into a digital image. (i) The Speech Input Device The Microphones - Speech Recognition is a speech Input device. To operate it we require using a microphone to talk to the computer. Also we need to add a sound card to the computer. The Sound card digitizes audio input into 0/1s .A speech recognition program can process the input and convert it into machine-recognized commands or input. Output Devices (a) Monitor Monitor is an output device that resembles the television screen and uses a Cathode Ray Tube (CRT) to display information. The monitor is associated with a keyboard for manual input of characters and displays the information as it is keyed in. It also displays the program or application output. Like the television, monitors are also available in different sizes. (b) Liquid Crystal Display (LCD) LCD was introduced in the 1970s and is now applied to display terminals also. Its advantages like low energy consumption, smaller and lighter have paved its way for usage in portable computers (laptops). (c) Printer Printers are used to produce paper (commonly known as hardcopy) output. Based on the technology used, they can be classified as Impact or Non-impact printers. Impact printers use the typewriting printing mechanism wherein a hammer strikes the paper through a ribbon in order to produce B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 14

output. Dot-matrix and Character printers fall under this category. Non-impact printers do not touch the paper while printing. They use chemical, heat or electrical signals to etch the symbols on paper. Inkjet, Deskjet, Laser, Thermal printers fall under this category of printers. When we talk about printers we refer to two basic qualities associated with printers: resolution, and speed. Print resolution is measured in terms of number of dots per inch (dpi). Print speed is measured in terms of number of characters printed in a unit of time and is represented as characters-per-second (cps), lines-perminute (lpm), or pages-per-minute (ppm). (d) Plotter Plotters are used to print graphical makes line drawings on paper using graphs, drawings, charts, maps etc. (Computer Aided Design) and CAM plotters.

output on paper. It interprets computer commands and multicolored automated pens. It is capable of producing Computer Aided Engineering (CAE) applications like CAD (Computer Aided Manufacturing) are typical usage areas for

(e) Audio Output: Sound Cards and Speakers: The Audio output is the ability of the computer to output sound. Two components are needed: Sound card Plays contents of digitized recordings, Speakers Attached to sound card.

QuestionNo(10):Define Software & Hardware? What is an instruction? What are registers?


Answer: (10): Software:- Computer instructions or data, anything that can be stored electronically is software. Computer software or just software is a general term used to describe the role that computer programs, procedures and documentation in a computer system. Hardware - (computer science) the mechanical, magnetic, electronic, and electrical components making up a computer systemhardware. Hardware includes not only the computer proper but also the cables, connectors, power supply units, and peripheral devices such as the keyboard, mouse, audio speakers, and printers. Instruction: An instruction is a basiccommand. The term instruction is often used to describe the most rudimentaryprogramming commands. For example, a computer'sinstruction set is the list of all the basic commands in the computer's machine language. Register: A special, high-speed storage area within the CPU. All data must be represented in a register before it can be processed. For example, if two numbers are to be multiplied, both numbers must be in registers, and the result is also placed in a register.

QuestionNo:-(9): Give the categories of Software with example?


B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 15

Answer: SOFTWARE TYPES (A).Application Software: Application Software is a set of programs for a specific application. Application software is useful for word processing, accounting, and producing statistical report, Graphics, Excel and Data Base. Programming languages COBOL, FORTRAN, C++,VB, VC, Java Types of Application Software Application software enables users to perform the activities and work that computers were designed for. The specific type of application used depends on the intended purpose, and there are application programs for almost every need. (a) Individual application software refers to programs individuals use at work or at home. Examples include word processing, spreadsheet, database management, and desktop publishing programs. (b) Collaboration software (also called groupware) enables people at separate PC workstations to work together on a single document or project, such as designing a new automobile engine. (c) Vertical applicationsoftware is a complete package of programs that work together to perform core business functions for a large organization. For example, a bank might have a mainframe computer at its corporate headquarters connected to conventional terminals in branch offices, where they are used by managers, tellers, loan officers, and other employees. All financial transactions are fed to the central computer for processing. The system then generates managers reports, account statements, and other essential documents. Other Application Software Models Shareware: Shareware is software developed by an individual or software publisher who retains ownership of the product and makes it available for a small contribution fee. The voluntary fee normally entitles users to receive online or written product documentation and technical help. Freeware: Freeware is software that is provided free of charge to anyone wanting to use it. Hundreds of freeware programs are available, many written by college students and professors who create programs as class projects or as part of their research. Open Source Software: An open source software program is software whose programming code is owned by the original developer but made available free to the general public, who is encouraged to experiment with the software, make improvements, and share the improvements with the user community Question No (10): What do you understand by the compiler? What are various phases of compiler?

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 16

Answer: Compiler: A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). Various Phases of Compiler: Following are various phases of Compiler: A common division into phases is described below. In some compilers, the ordering of phases may differ slightly, some phases may be combined or split into several phases or some extra phases may be inserted between those mentioned below. Lexical analysis This is the initial part of reading and analysing the program text: The text is read and divided into tokens, each of which corresponds to a symbol in the programming language, e.g., a variable name, keyword or number. Syntax analysis This phase takes the list of tokens produced by the lexical analysis and arranges these in a tree-structure (called the syntax tree) that reects the structure of the program. This phase is often called parsing. Type checking This phase analyses the syntax tree to determine if the program violates certain consistency requirements, e.g., if a variable is used but not declared or if it is used in a context that does not make sense given the type of the variable, such as trying to use a boolean value as a function pointer. Intermediate code generation The program is translated to a simple machine independent intermediate language. Register allocation The symbolic variable names used in the intermediate code are translated to numbers, each of which corresponds to a register in the target machine code. Machine code generation The intermediate language is translated to assembly language (a textual representation of machine code) for a specic machine architecture. Assembly and linking- The assembly-language code is translated into binary representation and addresses of variables, functions, etc., are determined. The rst three phases are collectively called the frontend of the compiler and the last three phases are collectively called the backend. The middle part of the compiler is in this context only the intermediate code generation, but this often includes various optimizations and transformations on the intermediate code. Each phase, through checking and transformation, establishes stronger invariants on the things it passes on to the next, so that writing each subsequent phase is easier than if these have to take all the preceding into account. For example, the type checker can assume absence of syntax errors and the code generation can assume absence of type errors. Assembly and linking are typically done by programs supplied by the machine or operating system vendor,

Question No (11): Explain working of Loader, Linker, Interpreter and Assembler?

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 17

Answer: Loader: In a computer operating system, a loader is a component that locates a given program (which can be an application or, in some cases, part of the operating system itself) in offline storage (such as a hard disk), loads it into main storage (in a personal computer, it's called random access memory), and gives that program control of the computer (allows it to execute its instruction s). A program that is loaded may itself contain components that are not initially loaded into main storage, but can be loaded if and when their logic is needed. In a multitasking operating system, a program that is sometimes called a dispatcher juggles the computer processor's time among different tasks and calls the loader when a program associated with a task is not already in main storage. Linker: Also called link editor and binder, a linker is a program tha t combines object modules to form an executable program. Many programming languages allow you to write different pieces of code, called modules, separately. This simplifies the programming task because you can break a large program into small, more manageable pieces. Eventually, though, you need to put all the modules together. This is the job of the linker. In addition to combining modules, a linker also replaces symbolic addresses with real addresses. Therefore, you may need to link a program even if it contains only one module. The linkage editor accepts two major types of input: Primary input, consisting of object decks and linkage editor control statements. Additional user-specified input, which can contain both object decks and control statements, or load modules. This input is either specified by you as input, or is incorporated automatically by the linkage editor from a call library. Output of the linkage editor is of two types: A load module placed in a library (a partitioned data set) as a named member Diagnostic output produced as a sequential data set. The loader prepares the executable program in storage and passes control to it directly.

Interpreter: An interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language. An interpreter may be a program that either executes the source code directly translates source code into some efficient intermediate representation (code) and immediately executes this explicitly executes stored precompiled code made by a compiler which is part of the interpreter system Assembler: An assembler translates an assembly language source program into machine codes. Though the assembly language is the symbolic representation of machine codes, a computer cannot understand it. After translating the assembly language program into machine codes by the assembler, the program becomes ready for the execution. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 18

Question No (12): Explain in detail the steps involved in Software Development Process?
Answer: Software development life cycle model is also called as waterfall model which is followed by majority of systems. This software development life cycle process has the following seven stages in it namely 1. System Requirements Analysis 2. Feasibility study 3. Systems Analysis and Design 4. Code Generation 5. Testing 6. Maintenance 7. Implementation 1. System Requirements Analysis: The first essential or vital thing required for any software development is system. Also the system requirement may vary based on the software product that is going to get developed. So a careful analysis has to be made about the system requirement needed for the development of the product. After the analysis and design of the system requirement phase the system required for the development would be complete and the concentration can be on the software development process. 2. Feasibility study: After making an analysis in the system requirement the next step is to make analysis of the software requirement. In other words feasibility study is also called as software requirement analysis. In this phase development team has to make communication with customers and make analysis of their requirement and analyze the system. By making analysis this way it would be possible to make a report of identified area of problem. By making a detailed analysis on this area a detailed document or report is prepared in this phase which has details like project plan or schedule of the project, the cost estimated for developing and executing the system, target dates for each phase of delivery of system developed and so on. This phase is the base of software development process since further steps taken in software development life cycle would be based on the analysis made on this phase and so careful analysis has to be made in this phase. 3. Systems Analysis and Design: This is an important phase in system development .Here analysis is made on the design of the system that is going to be developed. In other words database design, the design of the architecture chosen, functional specification design, low level design documents, high level design documents and so on takes place. Care must be taken to prepare these design documents because the next phases namely the development phase is based on these design documents. If a well structured and analyzed design document is prepared it would reduce the time taken in the coming steps namely development and testing phases of the software development life cycle.

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 19

4. Code Generation: This is the phase where actual development of the system takes place. That is based on the design documents prepared in the earlier phase code is written in the programming technology chosen. After the code is developed generation of code also takes place in this phase. In other words the code is converted into executables in this phase after code generation. 5. Testing: A software or system which is not tested would be of poor quality. This is because this is the phase where system developed would be tested and reports are prepared about bugs or errors in system. To do this testing phase there are different levels and methods of testing like unit testing, system test and so on. Based on the need the testing methods are chosen and reports are prepared about bugs. After this process the system again goes to development phase for correction of errors and again tested. This process continues until the system is found to be error free. To ease the testing process debuggers or testing tools are also available. To develop reliable and good quality Program/Software we need to follow the following 5 steps : 1. Requirement Specification. 2. Analysis. 3. Design. 4. Implementation. 5. Verification and testing.

Question No (13): Explain the steps involved about planning the computer program?
Answer: The Programming Process Purpose 1. Understand the problem Read the problem statement Question users Inputs required Outputs required Special formulas Talk to users 2. Plan the logic (a) Visual Design Tools Input record chart

in developing

a program? (or) Brief

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 20

Printer spacing chart Hierarchy chart Flowchart (b) Verbal Design Tools Narrative Description Pseudocode 3. Code the program Select an appropriate programming language Convert flowchart and/or Pseudocode instructions into programming language statements 4. Test the program 1. Syntax errors 2. Runtime errors 3. Logic errors 4. Test Data Set 5. Implement the program Buy hardware Publish software Train users 6. Maintain the program Maintenance programmers Legacy systems Up to 85% of IT department budget

Question No (14): Explain flowchart in detail?


Answer:A flowchart is a schematic representation of an algorithm or a stepwise process, showing the steps as boxes of various kinds, and their order by connecting these with arrows. Flowcharts are used in designing or documenting a process or program. A flow chart, or flow diagram, is a graphical representation of a process or system that details the sequencing of steps required to create output. A flowchart is a picture of the separate steps of a process in sequential order. The benefits of flowcharts are as follows: a. Communication: Flowcharts are better way of communicating the logic of a system to all concerned. b. Effective analysis: With the help of flowchart, problem can be analyzed in more effective way. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 21

c. Proper documentation: Program flowcharts serve as a good program documentation, which is needed for various purposes. d. Efficient Coding: The flowcharts act as a guide or blueprint during the systems analysis and program development phase. e. Proper Debugging: The flowchart helps in debugging process. f. Efficient Program Maintenance: The maintenance of operating program becomes easy with the help of flowchart. It helps the programmer to put efforts more efficiently on that part. Advantages Logic Flowcharts are easy to understand. They provide a graphical representation of actions to be taken. Logic Flowcharts are well suited for representing logic where there is intermingling among many actions. Disadvantages Logic Flowcharts may encourage the use of GoTo statements leading to software design that is unstructured with logic that is difficult to decipher. Without an automated tool, it is time-consuming to maintain Logic Flowcharts. Logic Flowcharts may be used during detailed logic design to specify a module. However, the presence of decision boxes may encourage the use of GoTo statements, resulting in software that is not structured. For this reason, Logic Flowcharts may be better used during Structural Design. LIMITATIONS OF USING FLOWCHARTS Complex logic: Sometimes, the program logic is quite complicated. In that case, flowchart becomes complex and clumsy. Alterations and Modifications:If alterations are required the flowchart may require re-drawing completely. Reproduction:As the flowchart symbols cannot be typed, 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. GUIDELINES FOR DRAWING A FLOWCHART a. In drawing a proper flowchart, all necessary requirements should be listed out in logical order. b. The flowchart should be clear, neat and easy to follow. There should not be any room for ambiguity in understanding the flowchart. c. The usual direction of the flow of a procedure or system is from left to right or top to bottom. d. Only one flow line should come out from a process symbol. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 22

e. Only one flow line should enter a decision symbol, but two or three flow lines, one for each possible answer, should leave the decision symbol. f. Only one flow line is used in conjunction with terminal symbol. g. Write within standard symbols briefly. As necessary, you can use the annotation symbol to describe data or computational steps more clearly. h. If the flowchart becomes complex, it is better to use connector symbols to reduce the number of flow lines. Avoid the intersection of flow lines if you want to make it more effective and better way of communication. i. Ensure that the flowchart has a logical start and finish. j. It is useful to test the validity of the flowchart by passing through it with a simple test data.

Question No (15): Describe in detail about algorithm? Give example


Answer: An algorithm is a description of a procedure which terminates with a result. Simple algorithms can be implemented within a function. Properties of an algorithm No ambiguity There should not be any uncertainty about which instruction to execute next. The algorithm should conclude after a finite number of steps. The algorithm should be general. Example: Biggest among two numbers Addition of N numbers Finding Factorial of a number Finding Fibonacci series. Guidelines Statements should be in simple English Must produce a solution for the specified problem It should be concise Each instruction should be written in separate line and express one action. Capitalize keywords such as READ, PRINT and so on. Instruction should be written from top to bottom, with one entry and one exit. Should allow easy transition from design to coding in programming language. Benefits: Language Independent. Easy to develop a program from pseudo code than flowchart. Easy to translate into programming language. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 23

It is compact. Limitations: No visual representation of program logic No accepted standards for writing pseudo codes. Cannot be compiled or executed. No real form or syntax rules. Examples: Finding a number is prime or not QuestionNo(16): Define Operating System? What are functions and typesof operating System? Answer: OPERATING SYSTEM: Operating System is a software that can be defined as: An interface between users and hardware - an environment "architecture Allows convenient usage; hides the tedious stuff Allows efficient usage; parallel activity, avoids wasted cycles Provides information protection Gives each user a slice of the resources Acts as a control program.

Functions of operating System:


An operting system manages hardware, runs applications, provides an interface for users, and stores, retrieves, and manipulates files. It manages the hardware and software resources of the system. It provides a stable, consistent way for applications to deal with the hardware without having to know all the details of the hardware. System tool (programs) used to monitor computer performance,debug,problems, or maintain parts of the system. A set of libraries or functions which may use to perform specific tasks especially relating to interfacing with computer system components. It avoids the situation of deadlock. It is responsible for resource and performance optimization. It manages process management and memory management

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 24

Types of Operating System


Type Batch Processing System Definition Data or programs are collected grouped and processed at a later date. Inputs immediately affect the outputs. Timing is critical i.e. they are capable of influencing the source of the data e.g. control where data from sensors is processed immediately and affect the outputs controlling some device. Timing is critical and the term real-time control system. Example of Use Payroll, stock control and billing systems. e.g. control ofnuclear power plants, oil refining, chemical processing and air traffic control systems.

Real-time Systems

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 25

Real-time transaction

- ------ Inputs immediately affect the outputs but timing is not critical. Each transaction is completed online as it arises e.g. booking systems- each book ing is online and a database of book ings can be amended interactively and very quick ly whilst another user is locked out so cannot double book or alter that record at the same time.
Processing performed under the direct control of the CPU whilst the user remains in communication with the computer. Processing which is done away from CPU. Provides for interaction between the job and the user, which may influence the course of processing.

Holiday and airline booking system. Difference between realtime and real-time transactions. In real time, time is criticlll and delays can be catastrophic but in real-time transactions systems there is no time criticality. E.g. poor speeds in airline control would be dangerous but poor booking speeds would not be so crucial.

Online processing

Offline processing

e.g. hatching together of clock cards, filling in OMR forms. Word processing

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 26

Question No(17): What are various Internal and External DOS Commands? Answer: Internal Commands: The internal commands reside in COMMAND.COM, which loads into memory when the computer system is started; these commands do not reside on disk. e.g. (a) (b) (c) TIME- Displays current time and allows it to be changed. Syntax: TIME DATE- Displays current date and allows it to be changed. Syntax: DATE CLS- Clears the screen. Syntax: CLS

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 27

(d)

DIR- Shows directory information of a diskette: name, size, and the date and time stamp of files. Syntax: DIR [d:][path]

Optionalswitches: /p Display dir info and pauses display when the screen is full /w Display names and extensions only in five columns To display a file directory listing for D:\LET\ANNUAL D:\LET\ANNUAL>DIR (from D:\LET\ANNUAL) D:\DATA>DIR \LET\ANNUAL (from D:\DATA) C:\WINDOWS>DIR D:\LET\ANNUAL (from C:\WINDOWS)

COPY- Copies a file. Name of copy may be the same as original, or different. Syntax: COPY [d:][path][name.ext] [d:][path][name.ext] Optionalswitches: /v Verify, copies the file and compares it with the original /b Binary file To copy a file from D:\BATCH to the root of A: drive (from A: drive) A:\>COPY D:\BATCH\CL.BAT D:\BATCH>COPY CL.BAT A:\ (from D:\BATCH) To copy a file from the root of C: to A: drive and change its name A:\>COPY C:\MSDOS.SYS MSDOSSYS.BAK (from A:) C:\>COPY MSDOS.SYS A:\MSDOSSYS.BAK (from the root of C:) To copy all of the files from the root of A: to D:\CCV\ENGCOMP A:\>COPY *.* D:\CCV\ENGCOMP (from A:) D:\CCV\ENGCOMP>COPY *.* A:\ (from D:\CCV\ENGCOMP) (f) TYPE-Displays the contents of a file. Syntax: TYPE [d:][path][name.ext] To display the contents of the file MY.LET to the screen A:\>TYPE MY.LET DEL- Deletes a file from disk. Syntax: DEL [d:][path][name.ext] To delete one file: A:\>DEL A:\MY.LET To del all files in current directory A:\>DEL *.*

(e)

(g)

(h)

REN- Renames a file. Syntax: REN [d:][path][name.ext] [d:][path][newname.ext] To change the name of the file D:\LET\ANNUAL\99.DOC to 1999.DOC Page 28

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

D:\LET>REN ANNUAL\99.DOC 1999.DOC (from D:\LET) D:\DATA>REN \LET\ANNUAL\99.DOC 1999.DOC (from D:\DATA) C:\WINDOWS>REN D:\LET\ANNUAL\99.DOC 1999.DOC (from C:\WINDOWS) (i) MD- Makes (creates) a new directory. Syntax: MD [d:][path][dirname] To create a directory named HERMIT in the root of D: drive D:\>MD HERMIT (from D:\) C:\>MD D:\HERMIT (from C:\) RD- Removes an existing directory Syntax: RD [d:][path][dirname] To remove the HERMIT sub-directory D:\>RD HERMIT (from D:\) C:\>RD D:\HERMIT (from C:\) (directory must be empty).

(j)

(k)

CD- Changes the current directory. Syntax: CD [path][dirname] To make D:\HERMIT the current directory D:\>CD HERMIT (from D:\) D:\DATA>CD \HERMIT (from D:\DATA) D:\DATA\SOURCE>CD \HERMIT (from D:\DATA\SOURCE) D:\DATA\SOURCE>CD .. (from D:\DATA\SOURCE) PATH-The PATH command is used to help the command interpreter find external commands which are not in the current directory. The command interpretter looks into the DOS environment for "PATH=" and then searches the paths (each separated from the next by a semicolon) that follow. Syntax: PATH=[path;path;...] To set the DOS PATH: PATH=C:\DOS;C:\PCW;\C:\BIN To display the current path: PATH

(l)

(m)

SET PROMPT- Used to specify the appearance of the DOS prompt. Syntax: SET PROMPT= (from the command line) PROMPT= (in a batch file)

To display current drive & current path followed by ">" as prompt SET PROMPT=$P$G To display the current date, time, and drive on separate lines SET PROMPT $D$_$T$_$N$G To redefine F9 to CD\Windows\Start Menu\Programs\Startup SET PROMPT $e[0,67;"'CD\Windows\Start Menu\Programs\Startup'";13p

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 29

External Commands:-The external commands are files that do reside on disk and have an extension of .COM, .EXE, or .BAT. Both command types are executed from the MS-DOS prompt. Instructions for external commands are disk-based. This means the file with the name of the command must be loaded into RAM at the moment when the command is given. Application programs are external commands and some DOS programs are external. The syntax for some of the more useful DOS external commands, including their parameters and switches follow: (a) FORMAT -Prepares a diskette for use by DOS. Syntax: FORMAT [d:] Parameters: [d:] = Drive which is to receive the format. Optionalswitches: /s Include all system files necessary to make disk "bootable" /b Reserve space for system files on diskette. (Formats 320k instead of 360k). /v Volume label of 11 characters Someexamples: To format a diskette in drive B: without system files: FORMAT B: To format a diskette in drive A: with system files: FORMAT A: /s To give the formatted diskette a volume name, include the /v switch: FORMAT A: /V Combine switches to format a boot diskette with a volume label:FORMAT A: /S /V (b) CHKDSK -Analyzes disk or diskette (first and only parameter) and displays disk and memory status report. Syntax: CHKDSK [d:] [/f] [/v] Parameters: [d:] = Drive upon which to perform the checkdisk. Optionalswitches: /f Fix. Writes lost clusters to a disk file and corrects file allocation table. /v Verbose. Lists all files on a disk. Example: To display statistics about the diskette in drive A: CHKSDK A: To display statistics about the first hard disk and fix any lost clusters: CHKSDK A: /f (c) DISKCOPY-Makes an exact copy of a diskette, including hidden system files if they are present. Syntax: DISKCOPY [d1:] [d2:] Parameters:[d1:] = Drive for source diskette, [d2:] = Drive for target diskette. Example: To make an exact copy of a diskette in drive A: to a diskette in B:DISKCOPY A: B: To make an exact copy of a diskette using only drive A: DISKCOPY A: A: B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 30

DISKCOPY asks for a SOURCE diskette (the diskette being copied) and a TARGET diskette (the diskette being copied to). The TARGET diskette need not be formatted, DOS will format it while doing the DISKCOPY. If the SOURCE diskette is bootable, the system will be transferred to the TARGET as well. The two disk drives must always use the same media.

Question No:(19): Explain Architecture of Unix? What are various Unix Commands?

Answer:- UNIXS is named after UNICS (UNiplexed Information and Computing Service). Its architecture
can be shown as below:

(1)UNIX Shell- Shell is an ordinary user program needs the ability to read from and write to the terminal, and execute other programs, Commands may take arguments, which are passed to the called program as character strings B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 31

Shell does not have to open terminal, but it has access automatically to a file standard input (for reading), file standard output (for writing normal output), and file standard error (for writing error messages) Shell can redirect standard input/output to files It can also use Pipe symbol Example: grep ter *.t | sort >out Possible pipeline sequence of pipe symbols Single user can run several programs at once Shell syntax for running a program in the background use & Example: wc l <a >b & Shell scripts refers to the files containing shell command UNIX Utility Programs- refers to standard application available with UNIX. Large number of utility programs Divided into six categories D File and directory manipulation commands Example: cp a b | ls *.* D Filters Example: grep (extracts lines containing patterns), cut, paste, D Program development tools such as editors/compilers Example: cc (C compiler), make (maintain large programs whose source code consists of multiple files) D Text processing Example: vi D System administration Example: mount (mount file system) D Miscellaneous Example: kill 1325 (kill a process), chmod (change privileges of a file)

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 32

UNIX Kernel- is the heart of the operating system with following structure:

All UNIX drivers are classified as either character device drivers (mouse, keyboard) or block device drivers (disk) Network device drivers (possible character devices, but handled very differently) Process dispatching when interrupt happens, context switch happens between processes Editors such as vi/emacs need raw tty Shell is line oriented, hence uses cooked mode and line disciplines B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 33

Networking software is layered with MAC/Routing/Transport layers and Socket interface On top of buffer cache sits file system Most UNIX systems support multiple file systems Berkeley fast file system Log-structured file system Various System V file systems On top of file system comes file naming, directory management, hard link and symbolic link management, etc On top page cache sits virtual memory (VM) All paging logic is here, such as replacement algorithm On top of VM is mapping files onto VM and high level page fault management code Figure out what to do when a page fault occurs On top of process dispatching is process management Process scheduler to choose which process to run next If threads are managed in the kernel, thread management is also here Note in some UNIX systems, threads are managed in user space On top of scheduling we have signal processing and process creation and termination Top layer has the system call interface All system calls are directed to one of the lower modules, depending on the nature of the call Top layer also has entrance to interrupts and traps Entrance to signals, page faults, processor exceptions of all kinds, I/O interrupts Various Commands Of Unix:Directories:File and directory paths in UNIX use the forward slash "/" to separate directory names in a path. examples: / "root" directory /usr directory usr (sub-directory of / "root" directory) /usr/STRIM100 STRIM100 is a subdirectory of /usr Moving around the file system: pwd Show the "present working directory", or current directory. cd Change current directory to your HOME directory. cd .. Change current directory to the parent directory of the current directory. cd $STRMWORK: Change current directory to the directory defined by the environment variable 'STRMWORK'. cd ~bob:Change the current directory to the user bob's home directory (if you have permission). Listing directory contents: ls list a directory Page 34

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

ls -l list a directory in long ( detailed ) format for example: $ ls -l drwxr-xr-x 4 cliff user 1024 Jun 18 09:40 WAITRON_EARNINGS -rw-r--r-- 1 cliff user 767392 Jun 6 14:28 scanlib.tar.gz ^^ ^ ^ ^ ^ ^ ^ ^ ^ ^ || | | | | | | | | | | | | | | owner group size date time name | | | | number of links to file or directory contents | | | permissions for world | | permissions for members of group | permissions for owner of file: r = read, w = write, x = execute -=no permission type of file: - = normal file, d=directory, l = symbolic link, and others... List the current directory including hidden files. Hidden files start with "." ls -ld * List all the file and directory names in the current directory using long format. Without the "d" option, ls would list the contents of any sub-directory of the current. With the "d" option, ls just lists them like regular files. Changing file permissions and attributes chmod 755 file Changes the permissions of file to be rwx for the owner, and rx for the group and the world. (7 = rwx = 111 binary. 5 = r-x = 101 binary) chgrp user file Makes file belong to the group user. chown cliff file Makes cliff the owner of file. chown -R cliff dir Makes cliff the owner of dir and everything in its directory tree. You must be the owner of the file/directory or be root before you can do any of these things. Moving, renaming, and copying files: cp file1 file2 copy a file mv file1 newname move or rename a file mv file1 ~/AAA/ move file1 into sub-directory AAA in your home directory. rm file1 [file2 ...] remove or delete a file rm -r dir1 [dir2...] recursively remove a directory and its contents BE CAREFUL! mkdir dir1 [dir2...] create directories mkdir -p dirpath create the directory dirpath, including all implied directories in the path. rmdir dir1 [dir2...] remove an empty directory Viewing and editing files: B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 35 ls -a

cat filename Dump a file to the screen in ascii. more filename Progressively dump a file to the screen: ENTER = one line down SPACEBAR = page down q=quit less filename Like more, but you can use Page-Up too. Not on all systems. vi filename Edit a file using the vi editor. All UNIX systems will have head filename Show the first few lines of a file. head -n filename Show the first n lines of a file. tail filename Show the last few lines of a file. tail -n filename Show the last n lines of a file. Shells :The behavior of the command line interface will differ slightly depending on the shell program that is being used.Depending on the shell used, some extra behaviors can be quite nifty.You can find out what shell you are using by the command: echo $SHELL Of course you can create a file with a list of shell commands and execute it like a program to perform a task. This is called a shell script. This is in fact the primary purpose of most shells, not the interactive command line behavior. Environment variables You can teach your shell to remember things for later using environment variables.For example under the bash shell: export CASROOT=/usr/local/CAS3.0 Defines the variable CASROOT with the value /usr/local/CAS3.0. export LD_LIBRARY_PATH=$CASROOT/Linux/lib Defines the variable LD_LIBRARY_PATH with the value of CASROOT with /Linux/lib appended, or /usr/local/CAS3.0/Linux/lib By prefixing $ to the variable name, you can evaluate it in any command: cd $CASROOT Changes your present working directory to the value of CASROOT

echo $CASROOT Prints out the value of CASROOT, or /usr/local/CAS3.0 printenv CASROOT Does the same thing in bash and some other shells. Interactive History: A feature of bash and tcsh (and sometimes others) you can use the up-arrow keys to access your previous commands, edit them, and re-execute them.

Redirection: B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 36

grep string filename > newfile Redirects the output of the above grep command to a file 'newfile'. grep string filename >> existfile Appends the output of the grep command to the end of 'existfile'. The redirection directives, > and >> can be used on the output of most commands to direct their output to a file. Pipes: The pipe symbol "|" is used to direct the output of one command to the input of another. For example: ls -l | more This commands takes the output of the long format directory list command "ls -l" and pipes it through the more command (also known as a filter). In this case a very long list of files can be viewed a page at a time. du -sc * | sort -n | tail The command "du -sc" lists the sizes of all files and directories in the current working directory. That is piped through "sort -n" which orders the output from smallest to largest size. Finally, that output is piped through "tail" which displays only the last few (which just happen to be the largest) results. Command Substitution You can use the output of one command as an input to another command in another way called command substitution. Command substitution is invoked when by enclosing the substituted command in backwards single quotes. For example: cat `find . -name aaa.txt` which will cat ( dump to the screen ) all the files named aaa.txt that exist in the current directory or in any subdirectory tree. Searching for strings in files: The grep command grep string filename prints all the lines in a file that contain the string Searching for files : The findcommand find search_path -name filename find . -name aaa.txt Finds all the files named aaa.txt in the current directory or any subdirectory tree. find / -name vimrc Find all the files named 'vimrc' anywhere on the system. find /usr/local/games -name "*xpilot*" Find all files whose names contain the string 'xpilot' which exist within the '/usr/local/games' directory tree. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 37

Reading and writing tapes, backups, and archives: The tarcommand The tar command stands for "tape archive". It is the "standard" way to read and write archives (collections of files and whole directory trees). Often you will find archives of stuff with names like stuff.tar, or stuff.tar.gz. This is stuff in a tar archive, and stuff in a tar archive which has been compressed using the gzip compression program respectivly. Chances are that if someone gives you a tape written on a UNIX system, it will be in tar format, and you will use tar (and your tape drive) to read it. Likewise, if you want to write a tape to give to someone else, you should probably use tar as well. Tar examples: Extracts (x) files from the default tape drive while listing (v = verbose) the file names to the screen. tar tv Lists the files from the default tape device without extracting them. tar cv file1 file2 Write files 'file1' and 'file2' to the default tape device. tar cvf archive.tar file1 [file2...] Create a tar archive as a file "archive.tar" containing file1, file2...etc. tar xvf archive.tar extract from the archive file tar cvfz archive.tar.gz dname Create a gzip compressed tar archive containing everything in the directory 'dname'. This does not work with all versions of tar. tar xvfz archive.tar.gz Extract a gzip compressed tar archive. Does not work with all versions of tar. tar cvfI archive.tar.bz2 dname Create a bz2 compressed tar archive. Does not work with all versions of tar File compression: compress, gzip, and bzip2 The standard UNIX compression commands are compress and uncompress. Compressed files have a suffix .Z added to their name. For example: compress part.igs Creates a compressed file part.igs.Z uncompress part.igs Uncompresseis part.igs from the compressed file part.igs.Z. is not required. Another common compression utility is gzip (and gunzip). These are the GNU compress and uncompress utilities. gzip usually gives better compression than standard compress, B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 38 Note the .Z tar xv

but may not be installed on all systems. The suffix for gzipped files is .gz gzip part.igs Creates a compressed file part.igs.gz gunzip part.igs Extracts the original file from part.igs.gz The bzip2 utility has (in general) even better compression than gzip, but at the cost of longer times to compress and uncompress the files. It is not as common a utility as gzip, but is becoming more generally available. bzip2 part.igs Create a compressed Iges file part.igs.bz2 bunzip2 part.igs.bz2 Uncompress the compressed iges file.

Looking for help: The man and apropos commands Most of the commands have a manual page which give sometimes useful, often more or less detailed, sometimes cryptic and unfathomable descriptions of their usage. Some say they are called man pages because they are only for real men. Example: man ls Shows the manual page for the ls command You can search through the man pages using apropos Example: apropos build Shows a list of all the man pages whose descriptions contain the word "build"

Do a man apropos for detailed help on apropos.

Basics of the vieditor Opening a file vi filename Creating text Edit modes: These keys enter editing modes and type in the text of your document. i Insert before current cursor position I Insert at beginning of current line a Insert (append) after current cursor position B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 39

A Append to end of line r Replace 1 character R Replace mode <ESC> Terminate insertion or overwrite mode Deletion of text x Delete single character dd Delete current line and put in buffer ndd Delete n lines (n is a number) and put them in buffer J Attaches the next line to the end of the current line (deletes carriage return). Oops u Undo last command

cut and paste yy Yank current line into buffer nyy Yank n lines into buffer p Put the contents of the buffer after the current line P Put the contents of the buffer before the current line cursor positioning ^d Page down ^u Page up :n Position cursor at line n :$ Position cursor at end of file ^g Display current line number h,j,k,l Left,Down,Up, and Right respectivly. Your arrow keys should also work if if your keyboard mappings are anywhere near sane. string substitution :n1,n2:s/string1/string2/[g] Substitute string2 for string1 on lines n1 to n2. If g is included (meaning global), all instances of string1 on each line are substituted. If g is not included, only the first instance per matching line is substituted. ^ matches start of line . matches any single character $ matches end of line These and other "special characters" (like the forward slash) can be "escaped" with \ i.e to match the string "/usr/STRIM100/SOFT" say "\/usr\/STRIM100\/SOFT" B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 40

Examples: :1,$:s/dog/cat/g :23,25:/frog/bird/ Substitute 'cat' for 'dog', every instance for the entire file - lines 1 to $ (end of file) Substitute 'bird' for 'frog' on lines 23 through 25. Only the first instance on each line is substituted.

Saving and quitting and other "ex" commands These commands are all prefixed by pressing colon (:) and then entered in the lower left corner of the window. They are called "ex" commands because they are commands of the ex text editor - the precursor line editor to the screen editor vi. You cannot enter an "ex" command when you are in an edit mode (typing text onto the screen) Press <ESC> to exit from an editing mode. :w Write the current file. :w new.file Write the file to the name 'new.file'. :w! existing.file Overwrite an existing file with the file currently being edited. :wq Write the file and quit. :q Quit. :q! Quit with no changes. :e filename Open the file 'filename' for editing.

:set number Turns on line numbering :set nonumber Turns off line numbering QuestionNo:(20) What are the characteristics of structure programming? Answer:-Structured programming (sometimes known as modular programming) is a subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. Certain languages such as Ada, Pascal, and dBASE are designed with features that encourage or enforce a logical program structure. Structured programming frequently employs a top-down design model, in which developers map out the overall program structure into separate subsections. A defined function or set of similar functions is coded in a separate module or submodule, which means that code can be loaded into memory more efficiently and that modules can be reused in other programs. After a module has been tested individually, it is then integrated with other modules into the overall program structure. B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI Page 41

Program flow follows a simple hierarchical model that employs looping constructs such as "for," "repeat," and "while." Use of the "Go To" statement is discouraged. Structured programming was first suggested by Corrado Bohm and Guiseppe Jacopini. The two mathematicians demonstrated that any computer program can be written with just three structures: decisions, sequences, and loops. Question No:(21) What is Top-Down and bottom up approach of programming? Answer:-Top-down and bottom-up are strategies of information processing and knowledge ordering, mostly involving software, but also other humanistic and scientific theories. In practice, they can be seen as a style of thinking and teaching. In many cases top-down is used as a synonym of analysis or decomposition, and bottom-up of synthesis. A top-down approach (also known as stepwise design) is essentially the breaking down of a system to gain insight into its compositional sub-systems. In a top-down approach an overview of the system is formulated, specifying but not detailing any first-level subsystems. Each subsystem is then refined in yet greater detail, sometimes in many additional subsystem levels, until the entire specification is reduced to base elements. A top-down model is often specified with the assistance of "black boxes", these make it easier to manipulate. However, black boxes may fail to elucidate elementary mechanisms or be detailed enough to realistically validate the model. A bottom-up approach is the piecing together of systems to give rise to grander systems, thus making the original systems sub-systems of the emergent system. Bottom-up processing is a type of information processing based on incoming data from the environment to form a perception. Information enters the eyes in one direction (input), and is then turned into an image by the brain that can be interpreted and recognized as a perception (output). In a bottom-up approach the individual base elements of the system are first specified in great detail. These elements are then linked together to form larger subsystems, which then in turn are linked, sometimes in many levels, until a complete top-level system is formed. This strategy often resembles a "seed" model, whereby the beginnings are small but eventually grow in complexity and completeness. However, "organic strategies" may result in a tangle of elements and subsystems, developed in isolation and subject to local optimization as opposed to meeting a global purpose. Question No:(22) What is IEEE- floating point notation? Answer:-The IEEE standard for floating point arithmetic:The IEEE (Institute of Electrical and Electronics Engineers) has produced a standard for floating point arithmetic. This standard specifies how single precision (32 bit) and double precision (64 bit) floating point numbers are to be represented, as well as how arithmetic should be carried out on them. The differences in the formats also affect the accuracy of floating point computations.

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 42

Summary: Single Precision: The IEEE single precision floating point standard representation requires a 32 bit word, which may be represented as numbered from 0 to 31, left to right. The first bit is the sign bit, S, the next eight bits are the exponent bits, 'E', and the final 23 bits are the fraction 'F': S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF 01 89 31 The value V represented by the word may be determined as follows: If E=255 and F is nonzero, then V=NaN ("Not a number") If E=255 and F is zero and S is 1, then V=-Infinity If E=255 and F is zero and S is 0, then V=Infinity If 0<E<255 then V=(-1)**S * 2 ** (E-127) * (1.F) where "1.F" is intended to represent the binary number created by prefixing F with an implicit leading 1 and a binary point. If E=0 and F is nonzero, then V=(-1)**S * 2 ** (-126) * (0.F) These are "unnormalized" values. If E=0 and F is zero and S is 1, then V=-0 If E=0 and F is zero and S is 0, then V=0 In particular, 0 00000000 00000000000000000000000 = 0 1 00000000 00000000000000000000000 = -0 0 11111111 00000000000000000000000 = Infinity 1 11111111 00000000000000000000000 = -Infinity 0 11111111 00000100000000000000000 = NaN 1 11111111 00100010001001010101010 = NaN 0 10000000 00000000000000000000000 = +1 * 2**(128-127) * 1.0 = 2 0 10000001 10100000000000000000000 = +1 * 2**(129-127) * 1.101 = 6.5 1 10000001 10100000000000000000000 = -1 * 2**(129-127) * 1.101 = -6.5 0 00000001 00000000000000000000000 = +1 * 2**(1-127) * 1.0 = 2**(-126) 0 00000000 10000000000000000000000 = +1 * 2**(-126) * 0.1 = 2**(-127) 0 00000000 00000000000000000000001 = +1 * 2**(-126) * 0.00000000000000000000001 = 2**(-149) (Smallest positive value)

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 43

Double Precision The IEEE double precision floating point standard representation requires a 64 bit word, which may be represented as numbered from 0 to 63, left to right. The first bit is the sign bit, S, the next eleven bits are the exponent bits, 'E', and the final 52 bits are the fraction 'F': S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 01 11 12 63 The value V represented by the word may be determined as follows: If E=2047 and F is nonzero, then V=NaN ("Not a number") If E=2047 and F is zero and S is 1, then V=-Infinity If E=2047 and F is zero and S is 0, then V=Infinity If 0<E<2047 then V=(-1)**S * 2 ** (E-1023) * (1.F) where "1.F" is intended to represent the binary number created by prefixing F with an implicit leading 1 and a binary point. If E=0 and F is nonzero, then V=(-1)**S * 2 ** (-1022) * (0.F) These are "unnormalized" values. If E=0 and F is zero and S is 1, then V=-0 If E=0 and F is zero and S is 0, then V=0

Question No:(18): Explain working of MS-VC editor? How you may run C program in MSVC? Answer:-Microsoft Visual Studio C/C++ (MSVC), which has an integrated, colour coded editor, in the IDE (Integrated Development Environment). This is editor-of-choice for generating C/C++ code ... since one can make quick changes in the code, compile, and link the result, and quickly load it back into the debugger for testing ... recently, it even allows code changes, while still in the debugger, and MSVC will re-compile the particular module, and re-link the application. There are two methods to write and compile a C program in MSVC. You can compile a C program using command line or you can compile a C program using the Integrated Development Environment (IDE) from Microsoft Visual C++. Using Command Line to Compile C Program 1. Select [Start >> All Programs >> Microsoft Visual C++ 2010 Express Edition >> Visual Studio Tools >> Visual Studio 2010 Command Prompt]. Run with administrator privileges. 2. Once you are in the command line, you can use any editor such as edit to write a C program. C:> edit myprogram.c 3. After written the program, to compile it, issue the command cl

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 44

C:> cl myprogram.c 4. During the compilation and linking, myprogram.obj and myprogram.exe will be created.To run the program: C:> myprogram Using Visual C++ 2010 IDE 1. Create an empty project by select [File >> New >> Project]. Select [General >> Empty Project] and type in the project name. Alternatively, you can select [File >> New >> Project], follow by [Win32 >> Win32 Console Application]. Type in the project name. 2. If you use Win32 Console Application, you can skip this step. Under [Solution Explorer], right click the project name, and select [Properties]. Select [Configuration Properties >> Linker >> System]. Under [SubSystem], select [Console (/SUBSYSTEM:CONSOLE)]. 3. Under [Solution Explorer, Source File], right-click and select [Add >> New Item]. 4. Under Code, Select C++ File (.cpp), however, when you type in the name use a program name with extension .c, such as myprog.c and click [Add]. 5. You can proceed to type your C program. Click [Save] icon to save your file. 6. To compile the program, under [Solution Explorer, Source File], right click the source file and select [Compile or (Ctrl+F7)]. 7. Please note that you cannot run the program until you have build solution. 8. To build solution select [Debug >> Build Solution or (F7)] 9. To run the program without debugging, select [Debug >> Start without debugging or (Ctrl+F5)]. (Note: If you do not have this option, you need to add the command manually under Tools >> Customize. You may add a menu option or a button in the Debug toolbar.) 10. For any runtime error, you can debug the program as follows; Select [Debug >> Start debugging (F5)]. 11. Please note that during debugging, the program will show and close the console display immediately. 12. To see the console display, you must run without debugging. Note:

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 45

The problem using Visual Studio is that many files will be created even for a very simple program. All files are created inside the project folder. Under the project name of your program, the source code and object file is located at sub folder similar to your project name, the executable file is under sub folder <Debug>. It is simpler to use the command line to compile and run a C program, however, you could use the IDE for writing a properly formatted C program.

[In addition to above students must exhaustively practice on the Exercises given in the classroom on Flow Charts, Algorithms and NumberConversions] [Also practice first 2 questions from all FOC question papers of last three years of UTU]

B.TECH-I SEM/FOC/THEORITICAL NOTES ON UNIT-I AND II BY DHEERAJ MURARI

Page 46

You might also like