fcpc notes



Comments



Description

UNIT 1Lecture: 1 An Overview of Computer System and Operating Systems: Fundamentals. Contents 1. 2. 3. 4. 5. Introduction to Computer System Functions of Computer System Introduction to Operating System Functions of Operating System Types of Operating System 1. Introduction We should keep in mind that a computer is a programmable machine. The two main characteristics of a computer are: (i) it responds to a specific set of instructions in a well-defined manner. (ii) It can execute a pre-recorded list of instructions (a program). Modern computers are electronic and digital. The actual machinery - wires, transistors and circuits is called hardware; the instructions and data are called software. 2. Functions of Computer System The Computer System needs both hardware and software. Hardware consists of the mechanical and electronic devices, which we can see and touch. The software consists of programs, the operating system and the data that reside in the memory and storage devices. A computer does mainly the following four functions: 1. Receive input —Accept data/information from outside through various input devices like the keyboard, mouse, scanner, etc. 2. Process information—Perform arithmetic or logical operations on data/ information. 3. Produce output—Communicate information to the outside world through output devices like monitor, printer, etc. 4. Store information—Store the information in storage devices like hard disk, floppy disks, CD, etc. These four basic functions are responsible for everything that computers do. 3. Introduction to Operating System World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in UNIT 1 The operating system is the core software component of your computer. It performs many functions and is, in very basic terms, an interface between your computer and the outside world. In the section about hardware, a computer is described as consisting of several component parts including your monitor, keyboard, mouse, and other parts. The operating system provides an interface to these parts using what is referred to as "drivers". This is why sometimes when you install a new printer or other piece of hardware, your system will ask you to install more software called a driver. 4. Functions of Operating System The operating system provides for several other functions including: • • System tools (programs) used to monitor computer performance, debug problems, or maintain parts of the system. A set of libraries or functions which programs may use to perform specific tasks especially relating to interfacing with computer system components. The operating system makes these interfacing functions along with its other functions operate smoothly and these functions are mostly transparent to the user. 5. Types of Operating System There are many types of operating systems. The most common is the Microsoft suite of operating systems. They include from most recent to the oldest: • • • • • • • Windows XP Professional Edition - A version used by many businesses on workstations. It has the ability to become a member of a corporate domain. Windows XP Home Edition - A lower cost version of Windows XP which is for home use only and should not be used at a business. Windows 2000 - A better version of the Windows NT operating system which works well both at home and as a workstation at a business. It includes technologies which allow hardware to be automatically detected and other enhancements over Windows NT. Windows ME - A upgraded version from windows 98 but it has been historically plagued with programming errors which may be frustrating for home users. Windows 98 - This was produced in two main versions. The first Windows 98 version was plagued with programming errors but the Windows 98 Second Edition which came out later was much better with many errors resolved. Windows NT - A version of Windows made specifically for businesses offering better control over workstation capabilities to help network administrators. Windows 95 - The first version of Windows after the older Windows 3.x versions offering a better interface and better library functions for programs. World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in UNIT 1 There are other worthwhile types of operating systems not made by Microsoft. The greatest problem with these operating systems lies in the fact that not as many application programs are written for them. However if you can get the type of application programs you are looking for, one of the systems listed below may be a good choice. • • • Unix - A system that has been around for many years and it is very stable. It is primary used to be a server rather than a workstation and should not be used by anyone who does not understand the system. It can be difficult to learn. Unix must normally run an a computer made by the same company that produces the software. Linux - Linux is similar to Unix in operation but it is free. It also should not be used by anyone who does not understand the system and can be difficult to learn. Apple MacIntosh - Most recent versions are based on Unix but it has a good graphical interface so it is both stable (does not crash often or have as many software problems as other systems may have) and easy to learn. One drawback to this system is that it can only be run on Apple produced hardware. World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in net. I have mentioned some important history in the evolution of computers. Evolution of Computers The need for a device to do calculations along with growth in commerce and other human activities explain the evolution of computers. In 1642.net. The real beginning computer was made by an English mathematician Charles Babbage in 1822. The only problem with this device that it lacked mechanical precision in its construction and was not reliable.in . With the passage of time. However. Hardware organization of a computers.Haryana. He proposed a engine to perform difference equations.in Website : www. used eight movable dials to add sums and eight figures only. many computing devices such as Napier bones and slide rule were invented. people in Asia minor built a counting device called ABACUS. Babbage never quite made a fully functional difference engine. division and to find square root. Evolution of Computers Hardware organization of a computers Input Device Output Device CPU Memory Unit Control Unit ALU 1. 7. It would print results automatically. Having the right tool to perform right has always been important for human beings. a French mathematician. E-mail : info@wit. extended Pascal’s design to perform multiplication. Gurgaon . called a difference engine. the device allowed users to do calculations using a system of sliding beads arranged on a rack. 2. Contents 1. 3. NH-71 B .wit.UNIT 1 Lecture: 2 Evaluation of Computers. In the beginning. This machine is known as stepped reckoner. when the task was simply counting or adding. 4. In this post. 6. In 1694.Sohna . people used either their fingers or pebbles along lines in the sand in order to simply the process of counting. Blaise Pascal invented the first functional automatic calculator. german mathematician Gotfried Wilhemvoz Leibniz. The brass rectangular box also called Pascaline. It took many centuries for the advancement in computing devices. 8. World Institute Of Technology 8km milestone . 5.Sohna Palwal Road . in Website : www. These are: 1) It accepts data or instructions by way of input 2) It stores data 3) It can process data as required by the user World Institute Of Technology 8km milestone .UNIT 1 and in 1833. A computer as shown in Fig.Haryana.Sohna . NH-71 B .in . output device to produce printed results. performs basically five major operations or functions irrespective of their size and make. It also contained a controlled unit that allowed processing instructions at any sequence. The basic design of the engine included input devices in the form of perforated cards containing operating system as a store for memory of 1.net. he quit working on it to concentrate on analytical engine.Sohna Palwal Road . Babbage borrowed the idea of punch cards to encode the instructions in the machine from the Joseph Marie jacquard’s loom.000 numbers up to 50 decimal digits long.net. E-mail : [email protected]. Gurgaon . E-mail : info@wit. 4. that lets you see what the computer has accomplished. at least temporarily. (iv) Output device: A display screen. Output devices include display screen.in Website : www.Haryana. plotters. loudspeakers. (v) Mass storage device: It allows a computer to permanently store large amounts of data. (iii) Input device : Usually a keyboard or mouse is used to read data and programs into the computer. (ii) Memory : It enables a computer to store. the component that actually executes instructions. Magnetic Ink Character Recognition (MICR).Sohna Palwal Road . etc.wit. Output Device Output devices receive information from the CPU and present it to the user in the desired form. many others make it possible for the basic components of a computer to work together efficiently. printers. a system may also support various other input devices such as Optical Character Recognition (OCR).in . • explain the importance of various units of a computer . Objectives After going through this lesson. 3. mark sense reader.UNIT 1 4) It gives results in the form of output 5) It controls all operations inside a computer.net. Input Device An input device presents data to the processing unit in a machine-readable form. printer. Gurgaon . NH-71 B . Although the keyboard is a common input device for a small computer.Sohna . etc. World Institute Of Technology 8km milestone . Common mass storage devices include disk drive and tape drive.net. In addition to these components. Hardware Organization of Computer All general purpose computers require the following hardware components: (i) Central Processing Unit (CPU): The ‘brain’ of the computer. • learn how these units work together to accomplish a given job . etc. you will be in a position to: • identify the basic components of a computer and their working. 2. data and programs. performs two types of operations arithmetical and logical. multiplication and division.wit.UNIT 1 5. When you turn the machine off. or greater than the other. Arithmetical operations are the fundamental mathematical operations consisting of addition.Sohna Palwal Road . the CPU is based on a single electronic component. But modern microcomputers can hold millions or even billions of characters in their memory.net. both are on a single microprocessor chip.. The CPU has two parts —The Control Unit (CU) and the Arithmetic Logic Unit (ALU). The original IBM PC could hold approximately several thousand characters of data or instructions only.Haryana. In a microcomputer. but these are considered separate from the CPU. NH-71 B . 8. A microcomputer’s system cabinet will also house disk drives. That is two pieces of data are compared to see whether one is equal to. less than. It also directs these control signals between the CPU and input/output devices. the contents are lost.is a part of the microcomputer that holds data and instructions.Sohna . Part of the contents of the memory is held only temporarily. The capacity of the memory to hold data and program instructions varies in different computers. 6. it is stored only as long as the microcomputer is turned on. The system unit also includes circuit boards. World Institute Of Technology 8km milestone . 7. Gurgaon . memory chips. E-mail : [email protected] Website : www. the microprocessor chip.net. that is. In a microcomputer. Control Unit The control unit tells the rest of the computer system how to carry out a program’s instructions.in . CPU This part of the computer that executes program instructions is known as the processor or Central Processing Unit (CPU).also known as the primary storage or main memory . ALU Arithmetic Logic Unit. It directs the movement of electronic signals between memory .which temporarily holds data. within the system unit or system cabinet. etc.and the ALU. Logical operations consist of comparisons. instructions and processes information . subtraction. Memory Unit Memory . usually called the ALU. ports and other components. hard disks. Introduction to Microprocessor 7.. The first microprocessors emerged in the early 1970s and were used for electronic calculators. E-mail : info@wit. using binary-coded decimal (BCD) arithmetic on 4-bit words. the first general-purpose.UNIT 1 Lecture: 3 Introduction to Microprocessor. or microchip). World Institute Of Technology 8km milestone . Generation of Microprocessor Contents 6.in Website : www. printers.in . Introduction to Microprocessor Intel 4004.wit. followed soon after. such as terminals.Haryana. Other embedded uses of 4-bit and 8-bit microprocessors.Sohna .net.net. commercial microprocessor Microprocessor incorporates most or all of the functions of a computer's central processing unit (CPU) on a single integrated circuit (IC. Gurgaon . various kinds of automation etc. Affordable 8-bit microprocessors with 16-bit addressing also led to the first general-purpose microcomputers from the mid-1970s on. Generation of Microprocessor P1 (086) First-Generation Processors 8088 and 8086 Processors 80186 and 80188 Processors 8087 Coprocessor 6. NH-71 B .Sohna Palwal Road . more powerful and more efficient and reliable devices. with one or more microprocessors used in everything from the smallest embedded systems and handheld devices to the largest mainframes and supercomputers. The integration of a whole CPU onto a single chip greatly reduced the cost of processing power. cheaper.UNIT 1 During the 1960s.Haryana.Sohna Palwal Road . as the architect of the PC at the time.in Website : www. The board and circuit designs at the time were largely 8-bit as well. Gurgaon . and a 16-bit address bus allowing a maximum of only 64KB of RAM (216). and slow sales of the 8086 indicated to Intel that people weren't willing to pay for the extra performance of the full 16-bit design. IBM. P1 (086) First-Generation Processors The first generation of processors represents the series of chips from Intel that were found in the first PCs. Since the early 1970s. 7. Moore later refined the period to two years.net.Sohna . In response. which suggests that the number of transistors that can be fitted onto a chip doubles every two years.in . computer processors were often constructed out of small and medium-scale ICs containing from tens to a few hundred transistors. chose Intel processors and support chips to build the PC motherboard. an 8-bit external data bus.wit. Building a full 16-bit motherboard and memory system would be costly. meaning that the 8086 could address a full 1MB (220) of memory. at the time virtually all other processors were 8-bit designs. setting a standard that would hold for many subsequent processor generations to come 8088 and 8086 Processors Intel introduced a revolutionary new processor called the 8086 back in June of 1978. Systems available at that time were 8-bit. which meant it could transfer data to memory 16 bits at a time. continued increases in microprocessor capacity have rendered other forms of computers almost completely obsolete (see history of computing hardware). Generation of Microprocessor Each generation of computer is characterized by a major technological development that fundamentally changed the way computers operate. This was in stark contrast to most other chips of that time that had 8-bit internal registers. It is often incorrectly quoted as a doubling of transistors every 18 months. It also had a 16-bit external data path. which ran 8-bit CP/M (Control Program for Microprocessors) operating systems and software. resulting in increasingly smaller. The 8086 had 16-bit internal registers and could run a new class of software using 16-bit instructions. The 8086 was one of the first 16-bit processor chips on the market. Unfortunately.net. The cost was high because the 8086 needed a 16-bit data bus rather than a less expensive 8-bit bus. the increase in capacity of microprocessors has been a consequence of Moore's Law. World Institute Of Technology 8km milestone . most of the personal computer world at the time was using 8-bit processors. NH-71 B . pricing such a computer out of the market. Although originally calculated as a doubling every year. From these humble beginnings. The address bus was 20 bits wide. E-mail : info@wit. called the 8088. 80186 and 80188 Processors After Intel produced the 8086 and 8088 chips. but the IBM PC did not appear until August 1981. However. the Apple II. The advantage of the 80186 and 80188 is that they combine on a single chip 15 to 20 of the 8086–8088 series system components—a fact that can greatly reduce the number of components in a computer design. Computer users sometimes wonder why a 640KB conventional-memory barrier exists if the 8088 chip can address 1MB of memory. one is a slightly more advanced version of the other. The 8088 in the IBM PC ran at 4. while retaining a much less expensive 8-bit design for the hardware. The 80186 and 80188 chips were used for highly intelligent peripheral adapter cards of that age. The company's first efforts along this line—the 80186 and 80188—were unsuccessful. The 80188 (like the 8088) is a hybrid chip that compromises the 16-bit design with an 8-bit external communications interface.in . the 8088 ran 16-bit software and was capable of addressing a full 1MB of RAM. Compared CPU to CPU. The 8088 essentially deleted 8 of the 16 bits on the data bus. Each cycle represents a unit of time to the system.265 and included only 16KB of RAM.in Website : www.wit. better chips. the IBM PC was actually priced less at its introduction than the most popular PC of the time.024KB (1MB) address space of the 8088 for use by adapter cards and system BIOS.770. such as the 286. programmers universally thought of the 8088 as a 16-bit chip because there was virtually no way a program could distinguish an 8088 from an 8086. because it retained the full 16-bit internal registers and the 20bit address bus.77MHz. IBM selected the 8-bit 8088 chip for the original IBM PC. The average instruction on the 8088 took 12 cycles to complete. while a similarly configured Apple II cost $1. it turned its sights toward producing a more powerful chip with an increased instruction set. For these reasons. when new processors and systems using them are often released on the same day. The 8088 was introduced in June 1979. NH-71 B . E-mail : info@wit. just a little more slowly. the IBM PC listed for $1.Haryana.000 cycles (essentially computer heartbeats) per second. with different instructions or operations requiring one or more cycles to complete.Sohna . In retrospect. The conventional-memory barrier exists because IBM reserved 384KB of the upper portion of the 1. it was a very wise decision. But incorporating system components into the CPU chip was an important idea for Intel because it led to faster. 8087 Coprocessor World Institute Of Technology 8km milestone ." IBM could say that because the 8088 still ran the same powerful 16-bit software the 8086 ran. IBM even covered up the physical design in its ads.net. making the 8088 an 8-bit chip as far as data input and output were concerned.Sohna Palwal Road .355. The lower 640KB is the conventional memory in which DOS and software applications execute. Because of this. or 4. That is unlike today. there was often a significant lag time between the introduction of a new processor and systems that incorporated it. For the trivia buffs out there. which at the time indicated its new PC had a "high-speed 16-bit microprocessor. The relationship between the 80186 and 80188 is the same as that of the 8086 and 8088. Gurgaon . Back then. such as network adapters. IBM was criticized for using the 8-bit 8088 instead of the 16-bit 8086. In fact.UNIT 1 Intel introduced a kind of crippled version of the 8086. Years later.net. the 80186 is almost the same as the 8088 and has a full 16-bit design. The original IBM PC used the Intel 8088. This allowed IBM to deliver a PC capable of running a new generation of 16-bit software. The math coprocessor that was paired with the chip—the 8087—often was called the numeric data processor (NDP). Input Devices 12. The primary advantage of using this chip is the increased execution speed in number-crunching programs. The central processing unit carries out each instruction of the program in sequence. Introduction to CPU The central processing unit (CPU) is the portion of a computer system that carries out the instructions of a computer program. E-mail : [email protected] 1 Intel introduced the 8086 processor in 1976. or simply the math chip.Haryana.net. and is the primary element carrying out the computer's functions. Introduction to CPU 10.in . The 8087 is designed to perform high-level math operations at many times the speed of the main processor. the math coprocessor.Sohna Palwal Road .Sohna .net. NH-71 B . Contents 9. Gurgaon .in Website : www. Input/output devices. Lecture: 4 Commonly used CPUs. such as spreadsheet applications. CPU Registers 11. to World Institute Of Technology 8km milestone .wit. Output Devices 9. However.in Website : www. CPU Registers EAX: Arithmetic operations. Both the miniaturization and standardization of CPUs have increased the presence of these digital devices in modern life far beyond the limited application of dedicated computing machines. EBP: Base/Frame pointer. design and implementation of CPUs have changed dramatically since the earliest examples.[1] The form. 11.Sohna . translating the digitized signals into a form intelligible to the user. I/O port access and interrupt call EDX: Arithmetic operations. This term has been in use in the computer industry at least since the early 1960s. Modern microprocessors appear in everything from automobiles to cell phones and children's toys.net. Also used for "this" pointer for a class EIP: Instruction pointer. If you have a multiplication operation which results in more than what a single register can handle. but their fundamental operation remains much the same. An output device reverses the process. I/O port access and interrupt call. sometimes one-of-a-kind. ESP: Stack pointer. This standardization trend generally began in the era of discrete transistor mainframes and minicomputers and has rapidly accelerated with the popularization of the integrated circuit (IC). computer. Early CPUs were custom-designed as a part of a larger. World Institute Of Technology 8km milestone . this costly method of designing custom CPUs for a particular application has largely given way to the development of mass-produced processors that are made for one or many purposes. NH-71 B .net. logical.UNIT 1 perform the basic arithmetical. Input Devices Input device converts incoming data and instructions into a pattern of electrical signals in binary code that are comprehensible to a digital computer.Sohna Palwal Road . but these have now been supplanted by more efficient devices. E-mail : info@wit. then the most significant 16 numbers are stored in EDX and least significant ones are stored in EAX EBX: Holds return values ECX: Used for loop counters. and input/output operations of the system. 10.Haryana. At one time punched-card and paper-tape readers were extensively used for inputting. This points to the top of the stack.in . Gurgaon . The IC has allowed increasingly complex CPUs to be designed and manufactured to tolerances on the order of nanometers. Points to the next instruction to execute.wit. Most auxiliary storage devices—as. Since a laptop may be used in a confined space.net. ink-jet and laser printers. trackball. Other examples are devices that enable the transmission and reception of data between computers—e. and certain types of optical compact discs—also double as input/output devices Various standards for connecting peripherals to computers exist. touchpad.in .Sohna . Touch screens can be found at an ATM or a kiosk. Serial connections. joystick. scanners used with point-of-sale terminals in retail stores) that can read bar-coded data or optical character fonts.. integrated drive electronics (IDE) and enhanced integrated drive electronics (EIDE) are common interfaces. magnetic disk drives. hand-held devices such as the mouse. may provide both input and output. which use relatively few wires. and so forth— to a computer.net. are generally simpler and slower than parallel connections. Universal serial bus (USB) is a common serial bus.g. and special pen with pressure-sensitive pad. For example. provided there is a clear line of sight between the device and the infrared port on the computer. often in response to computer processing of sensor input data.g. and devices such as flow valves that control machinery. modems and network interfaces. magnetic tape. depending on whether the data path carries one bit at a time (serial) or many at once (parallel). bus. Some devices. or pointing stick are usually provided. for magnetic disk drives. However. Wireless versions can be connected to the computer by using infrared beams. some users prefer to connect an external mouse to their laptop computers. A bus (also known as a port) can be either serial or parallel.Haryana. They also include sensors that provide information about their environment—temperature.UNIT 1 Input devices include typewriter-like keyboards. NH-71 B . and microphones.Sohna Palwal Road . for example. Keyboards and mice no longer have to be wired to the computer..wit. loudspeakers. Gurgaon . or buses. such as video display terminals.in Website : www. A common example of a parallel bus is the small computer systems interface. thereby bypassing these alternatives. alternate pointing devices such as a trackball. Even some computer display screens can be used as input devices. and a stylus or electronic pen can be used to input data into a PDA or small hand-held computer World Institute Of Technology 8km milestone . Another direct-entry mechanism is the optical laser scanner (e. pressure. E-mail : info@wit. Output equipment includes video display terminals (either cathode-ray tubes or liquid crystal displays). or SCSI. and retail store salespeople use handheld wand readers to read sales tags on store merchandise. Using a microphone and appropriate software. An MICR scans and reads the magnetic markings at the bottom of a check that represents information about the bank. The United States Postal Service has funded millions of dollars in grants in an attempt to develop systems that can read cursive handwriting. We will now turn our attention to output devices. Some cameras have an LCD on which pictures can be previewed. selected by pointing or clicking. each book in my campus library contains a bar code and so does each faculty/staff/students' identification card. There are several different types of scanners. Most likely.UNIT 1 There is an assortment of optical devices. and visualized by scanners and cameras. they had to briefly pause between each word as they spoke. Several years ago the food industry began to use unique bar codes called the UPC (Universal Product Code) to identify specific products. They can easily be posted to a Web site or e-mailed to friend or relative. the check number. she uses her voice to command the computer. know as continuous word systems. an artist. Digital images do not have to be printed. the prices for personal computer scanners have decreased dramatically over the past few years. Gurgaon . 12. Many states are using optical recognition to read and process handwritten income tax forms. or scanned and converted text from a page into a word processing document using OCR software. and a designer and uses a computer for her professional and creative activities.Haryana. Although physically challenged. One of the challenges to voice input is speech recognition. NH-71 B . E-mail : info@wit. the account. State-of-the-art digital cameras now store pictures internally in chips. Early speech recognition software required users to speak discrete words. Librarians check out books by using a small pen-like scanner and "wanding" the bar codes on the book and identification card So far we have examined devices where information is entered by typing. Once image files have been transferred to a computer by a wire connection or by disk. Although the codes are different from those used in supermarkets. Users are able to speak at a faster rate due to software advances and increased processor speeds that interpret what is being spoken. you have used a pencil to take a test or to complete a form that is then scanned and interpreted by an optical scanner. One no longer has to wait for film to be developed. One of my colleagues is a professor. and once written. There is one final method of inputting data. Output Devices World Institute Of Technology 8km milestone . and draw pictures.net. or on disks. Some of the images used in these Lecture Notes were taken with a digital camera.in . you can use your voice to enter commands or dictate words. on special memory strips. allow users to speak at a natural pace.Sohna Palwal Road . they can be edited and printed.net. Other "industries" also use bar codes. dictate documents. The quality of the final picture depends on both the quality of the paper and printer.Sohna . and that is by voice. Newer speech recognition software. Digital cameras are replacing conventional film cameras.wit. Like other peripheral devices.in Website : www. Perhaps you have scanned an image into a computer and used it as wallpaper. That is. the amount of the check. which refers to the number of colors.7 million colors. 3. the size of a monitor is determined by a diagonal measurement of the screen. Typically this can range from 256 colors to 16.15 mm to . The number of horizontal and vertical pixels.Haryana. As shown below. This can vary from . Like televisions. NH-71 B . 2. E-mail : info@wit. Quality of the display is determined by several factors. The color depth. while a high resolution can be 1600 by 1200.in Website : www. The dot pitch. several computer companies were sued because of misleading advertisements.Sohna . Originally they were only available in monochrome. printers. 1. which is the distance between pixels. loudspeakers. a higher quality video card and monitor will correspondingly have a higher price. but today most monitors are now color.Sohna Palwal Road . so a typical advertisement will mention a 17" monitor with 16" viewable. plotters. Gurgaon .in .UNIT 1 Output devices receive information from the CPU and present it to the user in the desired form. As one would expect. descriptions now include the "viewable" measurement.net. They measured from corner to corner of the screen instead of the portion of the screen that could actually be used. Typical low resolution would be 640 by 480. A few years ago. The size and quality of the display are a function of the monitor and video adapter to which they are connected. Softcopy The traditional output device for personal computers has been the CRT monitor. if you are using a Windows-based computer. you can find (and change) World Institute Of Technology 8km milestone . Subsequently.30 m. etc.net. Output devices include display screen.wit. Consequently. 14372 is spoken as "one-four-three-seven-two" instead of "fourteen thousand three hundred seventy-two.) is stored as a file.Sohna . a human voice can be recorded and then played back. or synthesized instrumental music. MIDI files can be thought of as a recording of the sheet music instead of the actual instrument playing. Gurgaon . selecting Properties.in . When played back. the musical sound of the instrument is synthesized by the sound card and sent to the speakers. NH-71 B ." When large numbers of words are needed. these voices range from nearly perfect speaking to mechanical robot-like speech. Unfortunately. These printers had a small print head that contained an arrangement (matrix) of one or more columns of small wires or pins. MIDI files are considerably smaller than recorded ones.Haryana.in Website : www. These instrumental sounds are not recorded. instrumental musical sounds can be created and stored. then a human voice is synthesized. With the proper hardware and software. how many words are needed to speak all of the zip codes used in the United States? Since we "spell" zip codes. etc. Depending on the system. An example of such a system would be a speaker used in conjunction with "vocalizer" software. E-mail : info@wit. As previously mentioned. A visually impaired user could use this software to read the text that appears in a document that is displayed on a monitor. recorded vocal/ instrumental music. and then select the Settings tab Obviously a CRT monitor is not a good choice for a portable computer display device. better visual quality carries a higher price tag. speakers require an audio card to create and produce auditory output. the traditional hardcopy output device for personal and large-scale computers was a dot-matrix printer. saxophone. When microcomputers were first available. Using a MIDI device. Using the same flat-panel technology that is typically found in wristwatches and calculators. Only recently have flat-panel displays been available for both Wintel and Macintosh desktop computers. and like their CRT "cousins". this small footprint carries a large price tag. most often in the form of a musical keyboard connected to a computer.wit.Sohna Palwal Road . recorded sound effects. Just as human words can be synthesized. Hardcopy Printers are subdivided into impact and non-impact categories. Unlike CRT monitors that get deeper as they get wider. duration. laptop computers use an LCD. These pins would form the various printable World Institute Of Technology 8km milestone . only ten words are needed! That is. LCD panels remain very thin. For example. so can instrumental music.UNIT 1 information about your graphics card and monitor settings by right-clicking on the background. and they will be discussed in a later chapter. There are some additional input and output devices that are used in the production and presentation of multimedia.net. sound played through speakers is another example of softcopy output. Just as monitors require a video card to create and display visual output. This sound can be previously recorded or a synthesized voice. but information such as the note. and "voice" (piano. This is useful if the number of spoken words is small.net. they tend to be noisy. The two most popular non-impact printers for personal computers are the laser and inkjet printers. are available in both black and white and color models.wit.Haryana. Inkjet printers. Although laser printers have a higher initial cost than inkjet printers.000 ppm. they re still popular with businesses that need the ability to produce multiple copies of forms or similar output. Shown below is a one-column 7-pin head (the pins are much closer than indicated in the figure). they have much slower print rates typically 2-6 ppm and lower resolution 300-600 dpi.Sohna Palwal Road .in . NH-71 B . Although rarely used with new personal computers. Low cost black and white laser printers for use with personal computers can be purchased for a few hundred dollars. a printed letter.in Website : www. high-volume laser printer that prints 1.Sohna . Because of its ability to print in color. Although most of today's inkjets are capable of printing in color. Since dot-matrix printers are impact printers (small pins striking a ribbon and paper). the inkjet is still the most popular printer used with personal computers.net.UNIT 1 characters. and a magnified view of the letter showing the dots that created it. which spray ink from multiple nozzles. they cost less per page to print hardcopies. World Institute Of Technology 8km milestone . The printer speed of laser printers used with home computers generally print around 8 to 10 ppm. and a large organization may have an expensive. E-mail : [email protected]. and despite the lesser speed and quality and higher printing cost. For comparison. a dot matrix printer prints at 75-100 dpi. Gurgaon . and the quality of print is between 600 and 1200 dpi. and their quality is marginal. NH-71 B .Sohna . Gurgaon . Types of Connectors World Institute Of Technology 8km milestone .UNIT 1 Lecture: 5 Input/output ports and connectors. Input/output Ports 2.net.net.Sohna Palwal Road . Connectors 3.Haryana.in . Contents 1.in Website : www. E-mail : [email protected]. and the procedures used to operate on the port. multicast networks. and whatever you write to the default output port appears on your screen. Use only the port manipulation routines described below. current-input-port and current-output-port allow you to find out what the current input and output ports are. Default input and output ports default-input-port default-output-port # the default input port (stdin) # the default output port (stdout) (current-input-port) # return the current input port (current-output-port) # return the current output port (set-input-port port) # change the current input port (set-output-port port) # change the current output port The default input and output ports are usually your keyboard and your terminal on your screen.Sohna Palwal Road . the default input port and output ports refer to the "standard input" and "standard output" files of the Isis process. or serial ports.in . and of course.wit.in Website : www. internet sites. Input/output Ports This is the standard input and output facilities in Isis. internal identity information. just to name a few. The current input and output ports indicate the places Isis will read and write data to when no particular port is specified in the routines described later (for example. Whatever you type on your keyboard is available for reading from the default input port. regardless of where the data is coming from or going to. NH-71 B . It will usually not be necessary to look at anything in this list. In Isis.net. You can create ports that connect to disk files. nothing in the list should ever be modified manually. the print function prints messages to the current output port). a port is represented as a list of several items. the current input and output ports are the same as the default input and output ports. and other operations.Haryana. which allows the same procedures to be used for reading.UNIT 1 1. Input from and output to any endpoint is handled using the same mechanism known as a port. Gurgaon .net. E-mail : info@wit. writing. but you can change them using set-input-port and set-output-port. When Isis is started. memory buffers. Opening ports (open-input filename) # open a disk file for input World Institute Of Technology 8km milestone . which includes the port type.Sohna . Technically. it should be closed so that resources associated with the port may be reclaimed. Closing ports (close port) # close port and deallocate associated resources When a port is no longer needed. and new-memory-port creates a port that points directly to a buffer in memory.dat")) new-string-port creates a port that points to a specified string (which is copied into a memory buffer).Sohna . E-mail : [email protected] Palwal Road . and other devices. multicast networks. Gurgaon . you may open ports to TCP connections.dat")) (set oport (open-output "outputfile. (set iport (open-input "inputfile. (set size 32768) (set buf (allocate-memory size)) (set mport (new-memory-port "mybuf" size buf False)) In addition to disk files and memory buffers. newmemory-port expects the size of the memory buffer in bytes.in . A port is returned. serial ports. Reading and writing data (read-string port) # read string up to a newline character (read port) # read CODED Isis values (read-raw port numbytes address) # read raw bytes to memory address (write-string port val val . writing. valid for reading or writing.) # write CODED Isis values (write-raw port numbytes address) # write raw bytes from memory address World Institute Of Technology 8km milestone .. and open-update open a disk file for reading.) # write values in human readable format (write port val val . or Null if there was a problem accessing the file.Haryana. Both routines return the newly created port. the address of the buffer. and a boolean freeflag indicating whether the buffer should be automatically freed when the port is closed. NH-71 B .net. or both..wit..net.UNIT 1 (open-output filename) # open a disk file for output (open-update filename) # open a disk file for input and output (new-string-port name string) # create new port connected to a string (new-memory-port name size address freeflag) # create new port connected to memory buffer open-input. unix pipes. A string name is expected for each. open-output. Descriptions of these ports appears in other sections of the documentation.in Website : www.. to be used for identification and in error messages. characters. If data is written in one format.net.) # same as read-string from the current input port # same as write-string to current output port Isis allows you to read and write data on ports in three different formats: strings.Sohna Palwal Road . and raw bytes. and a newline character must be given explicitly if it is desired. A description of the protocol used in coding values can be obtained from Stefan.Sohna . read reads one value from the given port and returns it. or Null if no more data is available. it should usually be read back with the corresponding read function for the same format. and other Isis values in a human-readable format. write-string writes one or more strings.data")) (print "The three secret numbers are: " (read iport) (read iport) (read iport) newline) (close iport) World Institute Of Technology 8km milestone .net.UNIT 1 (read-string) (print val val . write writes one or more values to the given port. There is a separate pair of read and write functions for each format. and returns the total number of bytes written.data")) (write oport (random) (random) (random)) (close oport) (set iport (open-input "test. and returns the total number of bytes written to the port. (set oport (open-output "test.in . read-string reads characters from the port up to the next newline character and returns a string (without the newline in it).. Read-string and write-string read and write human-readable strings.wit." newline) (close oport) (set iport (open-input "test. E-mail : info@wit. These routines are most useful for sending and receiving Isis values over a network or in disk files.Haryana. (set oport (open-output "test. Gurgaon . NH-71 B . coded Isis values. where other programs will not have to access the data.in Website : www. Any type of value except procedures and addresses may be read or written. or Null if no more data is available. or Null if an error occurred. Values are written exactly as they would be displayed in Isis. except that strings and characters are written without their quotes.txt")) (while (!= Null (set aline (read-string iport))) (print aline newline)) (close iport) Plain read and write receive and transmit Isis values in a compact coded form that is not readable by humans.txt")) (write-string oport "The number of the day is: " (random) newline) (write-string oport "Thank you and goodbye.. or Null if an error occurred. or Null if an error occurred. it reads a string from the current input port (usually the keyboard).raw")) (write-raw oport 50 outbuf) # write the entire buffer (close oport) (set inbuf (allocate-memory 50)) # allocate a second buffer (set iport (open-input "test. See above for more information about how to query or change the current input and output ports. Each expects the port.in . Each also returns the total number of bytes read or written.net. These functions are most useful as a way of requesting a line of input from the user and writing messages that the user will see on the screen. seek sets the current read/write position. or Null if it is not known or if there is an error.net. (while True (begin (print "Please enter a number: ") (set numstr (read-string)) (print "The square root of your number is: " (sqrt (eval numstr)) newline))) Port position (tell port) # return the current position in port (seek port pos) # seek to a particular position in port tell returns the current read/write position in the port in bytes relative to the beginning of the file.Sohna . It returns True if successful. NH-71 B .Haryana. These functions are most useful for transfering large blocks of raw data.raw")) (read-raw iport 50 inbuf) # read 50 bytes into it (close iport) (display (inbuf [c-byte 50])) # display the contents When read-string is called with no argument.wit. and the address of the memory buffer. Gurgaon .UNIT 1 Read-raw and write-raw receive and transmit blocks of raw data in memory buffers. in the most time and space efficient manner. and False if not. an integer number of bytes. the print function prints values to the current output port (usually the screen). (set outbuf (allocate-memory 50)) # allocate a memory buffer (outbuf c-byte (make-series 0 50 1)) # put something in the buffer (set oport (open-output "test.Sohna Palwal Road . World Institute Of Technology 8km milestone . like images or audio. Similarly. E-mail : [email protected] Website : www. return string (read-data port numbytes) (read-all-data port) # read up to numbytes. read-ready is exactly the same as pending.Haryana. It returns True if the port is ready to accept data. write-ready performs the converse operation for writing.net.in . return [buf len] World Institute Of Technology 8km milestone . Gurgaon .wit.Sohna .net. return string # read entire port. The result is either True or False. -> (input-port? (current-input-port)) True -> (output-port? (current-input-port)) False Port utilities (read-text port numchars) (read-all-text port) # read up to numchars. E-mail : info@wit. a outgoing connection is hung and momentarily cannot accept more data. Port queries (input-port? port) # return True if port supports input (output-port? port) # return True if port supports output These routines check if the given port supports input or output.Sohna Palwal Road .in Website : www. or False if not or if the optional time limit has been reached. return [buf len] # read entire port. If a second argument is given. and returns immediately with True if data is pending. This routine is typically useful to prevent a program from blocking when.UNIT 1 Port status (pending port) # return True if data is waiting to be read at port (pending port microsecs) # return True if data pending or False if time limit reached (read-ready port) # same as pending (read-ready port microsecs) # same as pending (write-ready port) # return True if data may be written to port (write-ready port microsecs) # return True if data may be written or False if time limit reached pending returns True if data is waiting to be read from the specified port. or False if the time limit was reached. NH-71 B . in TCP networking applications for example. or False otherwise. the function waits up to the specified number of microseconds. the returned number of bytes will be 0. You are responsible for deallocating the memory buffer when you no longer need it.in Website : www. E-mail : info@wit. except they read raw data. transfer-data and transfer-all-data read bytes from one port and write them to another.net.Sohna .wit. port name port-type # string. and an integer indicating the number of bytes stored in that buffer (which may be smaller than the number of bytes requested). or 0 if there was an error. output enabled on port? port-internal-id # internal id of port.UNIT 1 (transfer-data inport outport numbytes) # transfer numbytes from inport to outport (transfer-all-data inport outport) # transfer entire inport to outport read-text reads up to the specified number of characters from the given port and returns a string. read-all-text reads as many characters as possible from the port and returns a string. Gurgaon . (set copy-file (proc (inname outname) (local (infile outfile) (begin (set infile (open-input inname)) (set outfile (open-output outname)) (if (and infile outfile) (transfer-all-data infile outfile)) (close infile) (close outfile))))) Port list internals port-name # string. input enabled on port? port-outflag # boolean. NH-71 B . or Null if not needed port-close-proc # procedures for manipulating this port port-read-proc port-readline-proc port-write-proc port-tell-proc port-seek-proc port-read-ready-proc port-write-ready-proc port-configure-proc World Institute Of Technology 8km milestone . Both functions return Null if there is an error. If there is an error. port type port-inflag # boolean. read-data and read-all-data are similar. The return value is a list of two items: the address of a newly-allocated memory buffer. The number of bytes actually transferred is returned.in .Haryana.Sohna Palwal Road .net. Haryana.. Gurgaon . -> ((current-input-port) port-name) "Standard Input" -> ((current-output-port) port-name) "Standard Output" Creating new kinds of ports (new-port name type inflag outflag internal-id close-proc read-proc readline-proc write-proc tell-proc seek-proc read-ready-proc write-ready-proc configure-proc) # create a new port new-port creates a new port. return True if successful (read-ready id microsecs) # return True if data can be read or False if time limit reached (write-ready id microsecs) # return True if data can be written or False if time limit reached (configure id arg arg . (set new-memory-port (proc (name buflen membuf freeflag) (local (bufpos) (begin (set bufpos 0) (new-port name "MEMORY" [ buflen membuf freeflag ] True True World Institute Of Technology 8km milestone . where id will be the internal-id that you specify in new-port: (close id) # close and free resources. internal-id can be any value that you want to use as an internal identifier to the port. return num bytes actually read (readline id n addr stopval) # read n bytes or up to stopval. Talk to Stefan for more information on creating new types of ports.) # perform user-defined operations For example. NH-71 B . The rest of the arguments will be the procedures that are used to manipulate the port.. return True if successful (read id n addr) # read n bytes into addr.Sohna Palwal Road . which uses new-port to create a new port. return num bytes actually read (write id n addr) # write n bytes from addr. The procedures that you design for the port should be defined in the following way. The procedures for manipulating the port are defined within the scope of a local environment that includes bindings needed for the internal operations of the port.UNIT 1 These constants represent indices in the port descriptor list that you can use to get certain information about a port.Sohna . inflag and outflag should be booleans that indicate whether the port will support input or output or both. below is the definition of new-memory-port.net. The most useful item to most users is the probably the name of the port. name and type should be strings. which you can obtain by indexing into the port list with port-name. or Null if N/A (seek id pos) # set current read/write position. return num bytes actually written (tell id) # return current read/write position.wit.net.in .in Website : www. E-mail : info@wit. in . E-mail : [email protected] Palwal Road .Sohna . Gurgaon .buflen bufpos))) (if readsize (copy-memory readsize (+ membuf bufpos) ptr)) (set bufpos (+ bufpos readsize)) readsize))) # readline function (proc (id size ptr endval) (local (readsize val going) (begin (set readsize 0) (set going True) (while (and (< bufpos buflen) going) (begin (set val ((+ membuf bufpos) c-byte)) ((+ ptr readsize) c-byte val) (set readsize (+ readsize 1)) (set bufpos (+ bufpos 1)) (if (= val endval) (set going False)))) readsize))) # write function (proc (id size ptr) (local (writesize) (begin (set writesize (min size (.net. NH-71 B .Haryana.net.in Website : www.wit.UNIT 1 # close function (proc (id) (begin (if freeflag (free membuf)) True)) # read function (proc (id size ptr) (local (readsize) (begin (set readsize (min size (.buflen bufpos))) (if writesize (copy-memory writesize ptr (+ membuf bufpos))) (set bufpos (+ bufpos writesize)) writesize))) # tell function (proc (id) bufpos) # seek function (proc (id pos) (set bufpos pos)) World Institute Of Technology 8km milestone . UNIT 1 # read-ready function (proc (id time) (not (= bufpos buflen))) # write-ready function (proc (id time) (= bufpos buflen)) # configure function (proc args Null) ))))) 2. Connectors The part of a cable that plugs into a port or interface to connect one device to another. Most connectors are either male (containing one or more exposed pins) or female (containing holes in which the male connector can be inserted). Every house or office today is equipped with a multitude of connectors. Connectors are devices used for mating and de-mating electrical power connections.Connectors are responsible for power transfers and information transfers among machines and people that are spread over different locations. This is usually a mechanical or optical coupling device that provides a demountable connection between two fibers or a fiber and a source or detector. This component connects conductors of one circuit with those of another circuit. It is used to provide rapid connection or disconnection mating with a personal computer board or another connector. A housing becomes a connector when it contains the specified number of contacts (with conductors) to make it functional. A connector is different from a splice. A splice is a device that joins conducting or transmitting media permanently; it is used to join physical media that conduct or transmit power or a communication signal. Connectors join things temporarily, while splices are only done when wires are to be permanently joined. World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in UNIT 1 Different electrical and electronic equipments have different set of wires and every wire has a different set of connectors. There are so many different types of connectors that it is often difficult to understand where it is to be fitted. Even worse, one may buy a replacement cable that simply has the wrong connectors. If the connectors don't fit, it is often possible to just replace the connector rather then returning the entire piece of equipment. Advice from a good hardware installation expert is recommended while troubleshooting any issues pertaining to connectors. When one buys a connector, one should enquire about its cost, its compatibility with other connectors, ease of use, the energy saving factor and the total number of connections possible. Connector technology is constantly expanding and laying new trends in the market and a buyer is advised to always check these trends prior to choosing a conductor for specific equipment. Connector provides detailed information on Connectors, Electrical Connectors, Fiber Optic Connectors, USB Connectors and more. 3. Types of Connectors All electronic devices require a constant source of power to function and like all electronics even computers require power to function. Computer PSU is a term given to any the wires that that convert lethal electricity into usable and safe electricity. Each PSU requires connectors to function and this article is going to elaborate on the connectors used in these power supplies. The first one used in computer power supply is the P1 or the PC main connector. This connector goes right inside the mother board to supply it with electric power. This particular one has 20 pins but some connectors have up to 24 pins. The PC main connector is the largest and most important of all the computer's connectors. The 4 P Peripheral computer power supply connector is often called the Molex connector. These connectors go into various drives located in the computer and most of these connectors have 4 wires of black, red and yellow color. The 4P Peripheral is also used to supply additional power to Fire Wire 800 and similar PCI cards. The serial ATA computer PSU connector is 15 pins and this connector is used for components that use SATA power plugs. This is different from the rest since it supplies power at 3 different voltages with +12 volts being the highest and +3.3 volts being the lowest. World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in UNIT 1 Auxiliary computer power supply connectors provide additional power only when required and these are often kept aside in case of an emergency. There are many types of Auxiliary power supply connectors and depending on the requirement a person can choose from these different connectors. Other power supply connectors include the 6 pin, 6+2 pin, ATX12V, 4 pin berg and Ac 14 connectors Lecture: 6 World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in Introduction to Operating System The operating system is the core software component of your computer. The operating system provides an interface to these parts using what is referred to as "drivers". 2. NH-71 B . or user. Contents 1. sound card or CD ROM drive. In the section about hardware. mouse. E-mail : [email protected] . 5. application program. 2.in Website : www. your system will ask you to install more software called a driver. World Institute Of Technology 8km milestone .Haryana. It translates commands from the operating system or user into commands understood by the the component computer part it interfaces with. 4. It also translates responses from the component computer part back to responses that can be understood by the operating system.net.Sohna Palwal Road . and other parts. in very basic terms. What does a Driver do of an Operating System A driver is a specially written program which understands the operation of the device it interfaces to. It performs many functions and is. a computer is described as consisting of several component parts including your monitor. video card. Types of an Operating Systems. Introduction to Operating System What does a Driver do of an Operating System Functions of an Operating System Operating System Concerns Types of an Operating System Windows XP Professional Edition Windows XP Home Edition Windows 2000 Windows ME Windows 98 Windows NT Windows 95 1. Functions of an Operating system. 3.UNIT 1 Operating System Basics: Introduction to Operating system.net. keyboard. The below diagram gives a graphical depiction of the interfaces between the operating system and the computer component. an interface between your computer and the outside world.wit. such as a printer.in . This is why sometimes when you install a new printer or other piece of hardware. Gurgaon . Operating systems are written by human programmers who make mistakes.Sohna . Functions of an Operating System The operating system provides for several other functions including: • • System tools (programs) used to monitor computer performance. Therefore there can be errors in the code even though there may be some testing before the product is released.net. an operating system is a computer program.net. Some companies have better software quality control and testing than others so you may notice varying levels of quality from operating system to operating system.Sohna Palwal Road . E-mail : info@wit. NH-71 B .in Website : www. or maintain parts of the system. 4. The operating system makes these interfacing functions along with its other functions operate smoothly and these functions are mostly transparent to the user. Errors in operating systems cause three main types of problems: World Institute Of Technology 8km milestone .UNIT 1 3. debug problems. Gurgaon . Operating System Concerns As mentioned previously.in . A set of libraries or functions which programs may use to perform specific tasks especially relating to interfacing with computer system components.wit.Haryana. Sohna Palwal Road .A better version of the Windows NT operating system which works well both at home and as a workstation at a business. This varies depending on the type of operating system. Types of an Operating System There are many types of operating systems. E-mail : info@wit. Windows 2000 . It includes technologies which allow hardware to be automatically detected and other enhancements over Windows NT.wit.in . Windows ME .in Website : www.Haryana.These can happen due to a software bug typically in the operating system.net.Sohna . 5.A version of Windows made specifically for businesses offering better control over workstation capabilities to help network administrators. Sometimes errors in the operating system will cause the computer not to work correctly with some peripheral devices such as printers. Windows NT . unauthorized intruders may try to use these to gain illegal access to your system. Gurgaon .A version used by many businesses on workstations. Security flaws . Windows XP Home Edition . A system crash is the act of a system freezing and becoming unresponsive which would cause the user to need to reboot.The first version of Windows after the older Windows 3.This was produced in two main versions. Windows 95 . although computer programs being run on the operating system can make the system more unstable or may even crash the system by themselves.An upgraded version from windows 98 but it has been historically plagued with programming errors which may be frustrating for home users. The most common is the Microsoft suite of operating systems. The first Windows 98 version was plagued with programming errors but the Windows 98 Second Edition which came out later was much better with many errors resolved.Some software errors leave a door open for the system to be broken into by unauthorized intruders.x versions offering a better interface and better library functions for programs World Institute Of Technology 8km milestone . Windows 98 . As these flaws are discovered.UNIT 1 • • • System crashes and instabilities . Patching these flaws often will help keep your computer system secure. NH-71 B . They include from most recent to the oldest: • • • • • • • Windows XP Professional Edition . It has the ability to become a member of a corporate domain.net.A lower cost version of Windows XP which is for home use only and should not be used at a business. How this is done will be explained later. non-x86 microcomputer disk operating systems had "DOS" in their name.in Website : www. and Millennium Edition. give the command: A>dir World Institute Of Technology 8km milestone .in . DOS will respond with a prompt that gives the desired drive as the default. 5. Windows XP. 2.Sohna Palwal Road . E-mail : info@wit. ROM-DOS. PC-DOS.wit. FreeDOS.Sohna . short for "Disk Operating System". AMSDOS. PTS-DOS. Directories To obtain a listing of the files on the default drive (a directory). Introduction to DOS Basic DOS Commands Introduction to UNIX OS Introduction to LINUX OS Basic UNIX/LINUX Commands Introduction to Windows XP 1. ANDOS. Commodore DOS.g. DR-DOS. Contents 1. While providing many of the same operating system functions for their respective computer systems.net. Introduction to DOS This is about the family of operating systems for IBM PC-compatible computers. and several others. AmigaDOS. A number of unrelated. Gurgaon . Atari DOS. see DOS (disambiguation). In spite of the common usage. Related systems include MSDOS. programs running under any one of these operating systems would not run under others. Apple DOS. 6.UNIT 1 Lecture: 7 Basic introduction to DOS. and TRS-DOS). type the desired drive letter followed by a carriage return. none of these systems were simply named "DOS" (a name given only to an unrelated IBM mainframe operating system in the 1960s). UNIX/LINUX OS. 2. and are often referred to simply as "DOS" when discussing machines that use them (e. ProDOS. DOS. For other uses. CSI-DOS. 98. or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95.net.Haryana. JM-OS. is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995. 4. NH-71 B . Basic DOS Commands Changing the default drive To change the default drive. 3. UNIT 1 To a listing of the files on another drive, type: A>dir a: to see, for example, which files are on the A disk. You could, of course, first make A the default drive and then give the previous command, but this is more cumbersome. This example illustrates a general feature of DOS. Unless you specify otherwise, DOS assumes that it will be dealing with the default drive. You can perform most operations without changing the default drive by specifing another drive letter at the appropriate spot. Specifying a filename Most DOS commands require you to specify one or more filenames. Valid filenames are composed of up to eight characters and are optionally followed by an extension of up to three characters. The filename and extension are separated by a period. Some examples of DOS filenames are: sst.exe demo.cmd junk Extensions can be used to remind you what the file contains. SST uses the extension `.cmd' for files of SST commands and the extension `.sav' for SST system files. Copying files Frequently you will want to make a copy of a file. To copy a file (named oldfile) to a new file named newfile, enter: A>copy oldfile newfile The file newfile will have exactly the same contents as the file oldfile. As always, DOS assumes oldfile is on the default drive and also places newfile on the default drive. The syntax of DOS commands when two filenames are required is usually "from to", i.e. the first filename is the source (or "from") file and the second is the destination (or "to") file. To copy a file from one disk to another, it is only necessary to precede the filename by a drive designation. If you are copying files between disks, then the copy can have the same filename as the original. In fact, if you do not supply a filename for the destination, DOS assumes that you want to use the same filename as the source. For example, if B is the default drive, the following command makes a copy of the file oldfile from the A disk on the B disk with the same name: B>copy a:oldfile On the other hand, if oldfile is on B (the default drive) and you would like a copy on the A disk, type: World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in UNIT 1 A>copy oldfile a: (It is not necessary to precede oldfile with a drive designation since it is on the default drive.) If there is already a file named oldfile on A (the destination drive), it will be overwritten. Abbreviating filenames in DOS DOS allows you to use a simple scheme of wild cards to refer to multiple filenames without having to type out the entire list of filenames that you want. There are two wild cards, the question mark and the asterisk. A question mark matches any character while an asterisk matches any string of characters. Changing the default drive To change the default drive, type the desired drive letter followed by a carriage return. DOS will respond with a prompt that gives the desired drive as the default. Directories To obtain a listing of the files on the default drive (a directory), give the command: A>dir To a listing of the files on another drive, type: A>dir a: to see, for example, which files are on the A disk. You could, of course, first make A the default drive and then give the previous command, but this is more cumbersome. This example illustrates a general feature of DOS. Unless you specify otherwise, DOS assumes that it will be dealing with the default drive. You can perform most operations without changing the default drive by specifing another drive letter at the appropriate spot. Specifying a filename Most DOS commands require you to specify one or more filenames. Valid filenames are composed of up to eight characters and are optionally followed by an extension of up to three characters. The filename and extension are separated by a period. Some examples of DOS filenames are: sst.exe demo.cmd junk Extensions can be used to remind you what the file contains. SST uses the extension `.cmd' for files of SST commands and the extension `.sav' for SST system files. World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in UNIT 1 Copying files Frequently you will want to make a copy of a file. To copy a file (named oldfile) to a new file named newfile, enter: A>copy oldfile newfile The file newfile will have exactly the same contents as the file oldfile. As always, DOS assumes oldfile is on the default drive and also places newfile on the default drive. The syntax of DOS commands when two filenames are required is usually "from to", i.e. the first filename is the source (or "from") file and the second is the destination (or "to") file. To copy a file from one disk to another, it is only necessary to precede the filename by a drive designation. If you are copying files between disks, then the copy can have the same filename as the original. In fact, if you do not supply a filename for the destination, DOS assumes that you want to use the same filename as the source. For example, if B is the default drive, the following command makes a copy of the file oldfile from the A disk on the B disk with the same name: B>copy a:oldfile On the other hand, if oldfile is on B (the default drive) and you would like a copy on the A disk, type: A>copy oldfile a: (It is not necessary to precede oldfile with a drive designation since it is on the default drive.) If there is already a file named oldfile on A (the destination drive), it will be overwritten. Abbreviating filenames in DOS DOS allows you to use a simple scheme of wild cards to refer to multiple filenames without having to type out the entire list of filenames that you want. There are two wild cards, the question mark and the asterisk. A question mark matches any character while an asterisk matches any string of characters. For example, `s?t' matches `sat', `sst', and `st'. Similarly, `s*t' would match each of the previous names as well as `short', `s123.45t'. The abbreviation `*.sav' would match any filename with the extension `.sav' (i.e., any SST system file), while `*' (or, equivalently, `*.*') would match any filename. To obtain a listing of all the files on the A drive with the extension `.sav', type: B>dir a:*.cmd To copy all files from A to B, you could use the command: C>copy a:*.* b: World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in To type a file on the A drive.wit. type: C>mkdir sst The subdirectory sst now exists. press the <Ctrl> and the <Scroll Lock> keys simultaneously. To stop scrolling.net.in . First.in Website : www. E-mail : info@wit. There are two ways to access files in the subdirectory. To stop printing depress these keys again. This is done by changing directories: C>cd sst World Institute Of Technology 8km milestone .Sohna Palwal Road . and DOS will send a copy of what is on the screen to your printer. NH-71 B . If you want to obtain a printed copy of the rest of your computer session. Files with the extension `. depress the <shift arrow> and <PrtSc> keys simultaneously. Gurgaon . press the <Ctrl> and <Scroll Lock> keys again. To create a subdirectory named sst.exe' or `.UNIT 1 SST uses a similar scheme of wild cards to abbreviate variable names. Further output will be sent to the printer as it appears on the screen.Sohna . Subdirectories DOS allows you to organize disks into subdirectories--groupings of files in a tree structure. DOS assumes the file is on the default drive. you can make the subdirectory the default directory in the same way that you make a disk drive the default drive. For most purposes a subdirectory on a disk is used as if it were a separate disk.Haryana.net. depress the <Ctrl> and <PrtSc> keys simultaneously. Listing the contents of a file on the monitor To display the contents of a text file on the monitor. if the filename is not preceded by a drive specification.com' are executable programs stored in a binary format which cannot be typed. To print what is on the screen If you have a printer connected to your computer and you would like a "hard" copy of what is currently on the screen. To stop scrolling output on the screen If you attempt to type a large file. it is apt to scroll down the screen faster than you are able to read it. To restart output. you can use the DOS type command which has the following syntax: A>type filename As always. use instead: B>type a:filename Not all files in DOS are textfiles. Haryana. The Unix environment and the client–server program model were essential elements in the development of the Internet and the reshaping of computing as centered in networks rather than in individual computers.UNIT 1 You are now located within the sst subdirectory. Both Unix and the C programming language were developed by AT&T and distributed to government and academic institutions. it is not necessary to change directories to access a file in another directory. DOS assumes that you only want a listing of files in the default subdirectory--which is whatever subdirectory you happen to be located in at the time you issue a command.net. workstations. Unix became synonymous with "open systems". We do not recommend this practice if you are a newcomer to DOS. With the above path command. it is possible to execute sst.Sohna . give the command: C>dir Unless you specify otherwise. World Institute Of Technology 8km milestone .wit. Gurgaon . give the command: C>cd \ The backslash (`\') is DOS's symbol for the top directory. without being located in the sst subdirectory.\sst DOS will search the root directory (\) and the sst subdirectory (\sst) when it looks for programs to execute. If you type: C>path \. If you are in the root directory and you would like to see the contents of a file in the sst subdirectory. DOS allows you to create subdirectories in subdirectories so directory structures can become rather complicated. E-mail : [email protected]. NH-71 B . 3. which led to both being ported to a wider variety of machine families than any other operating system.in Website : www. for example. To obtain a listing of files in the sst subdirectory.in . and mobile devices. try: C>type sst\filename Thus. Introduction to UNIX OS Unix operating systems are widely used in servers. The other way to access files in a subdirectory is to provide DOS with a path telling it how to find the file you are interested in. Specifying pathnames can become rather tedious and DOS provides a facility for specifying which directories are to be searched for programs with the path command. To return to the main (or root) directory. As a result.Sohna Palwal Road . For the purposes of this manual we will assume that you do not have subdirectories to subdirectories. leading to the division between user-space and kernelspace. treating devices and certain types of inter-process communication (IPC) as files.UNIT 1 Unix was designed to be portable.wit. Unix systems are characterized by various concepts: the use of plain text for storing data.net. As graphical user interfaces developed. perhaps most importantly. as opposed to using a single monolithic program that includes all of the same functionality. and in the 1980s non-blocking I/O and the set of inter-process communication mechanisms was augmented (sockets. the file model proved inadequate to the task of handling asynchronous events such as those generated by a mouse. The kernel provides services to start and stop programs. and the use of a large number of software tools. Under Unix.in Website : www. schedules access to hardware to avoid conflicts if two programs try to access the same resource or device simultaneously. the "operating system" consists of many of these utilities along with the master control program. Some popular mainstream Linux distributions include Debian (and its derivatives such as Ubuntu). message queues. These concepts are collectively known as the Unix philosophy. and. handles the file system and other common "low level" tasks that most programs share. the kernel was given special rights on the system. and functionalities such as network protocols were moved out of the kernel.net. modern systems include networking and other new devices. the kernel. A distribution oriented toward desktop use may include the X Window System. and redistributed. Introduction to LINUX OS Linux refers to the family of Unix-like computer operating systems using the Linux kernel. Linux distributions include the Linux kernel and supporting utilities and libraries to fulfill the distribution's intended use. to mainframes and supercomputers. 4.Sohna Palwal Road . E-mail : info@wit. shared memory.Haryana. by anyone under licenses such as the GNU General Public License. tablet computers and video game consoles. and runs the 10 fastest supercomputers in the world. ranging from mobile phones. Gurgaon . a hierarchical file system. However. Linux can be installed on a wide variety of computer hardware. Typically Linux is packaged in a format known as a Linux distribution for desktop and server use. semaphores). NH-71 B . the GNOME and KDE Plasma desktop environments. Other distributions may include a less resource intensive desktop such as LXDE or XFCE for use on older or less-powerful computers. The microkernel concept was introduced in an effort to reverse the trend towards larger kernels and return to a system in which most tasks were completed by smaller utilities. The development of Linux is one of the most prominent examples of free and open source software collaboration.Sohna . Linux is a leading server operating system. the Unix file model worked quite well as most I/O was "linear". To mediate such access. typically all the underlying source code can be used.in . multi-tasking and multi-user in a time-sharing configuration. freely modified. both commercially and non-commercially. A World Institute Of Technology 8km milestone . small programs that can be strung together through a command line interpreter using pipes. Fedora and openSUSE. In an era when a "normal" computer consisted of a hard disk for storage and a data terminal for input and output (I/O). cshrc file.in Website : www.gz' appended to the original filename. There are many more options. and when it was last modified. ls -a --.lists all files. NH-71 B . it is possible for anyone to create a distribution for any intended use. originally written in 1991 by Linus Torvalds.moves a file (i. which you do not always want to see.g. World Institute Of Technology 8km milestone . the OpenOffice. emacs filename --.lets you change the read. The name "Linux" comes from the Linux kernel.Sohna Palwal Road . Note that for someone to be able to actually look at the file the directories it is in need to be at least executable. and execute permissions on your files. You can use /pattern to search for a pattern.org office application suite and the GIMP image editor.lists your files ls -l --. recursively etc. Usually text files compress to about half their original size. The default is that only you can look at them and change them. which contains lots of useful information. but you may sometimes want to change these permissions.copies a file rm filename --. Gzip produces files with the ending '. You can make this your default by making an alias in your .net. It is wise to use the option rm -i. See the emacs page. too (e. File Compression o gzip filename --. by date. and chmod o-r filename will make it unreadable for others again.Haryana. just as much as will fit on one screen. Gurgaon . for example to list files by size. Commonly used applications with desktop Linux systems include the Mozilla Firefox web-browser. but it depends very much on the size of the file and the nature of the contents.Sohna .lists your files in 'long format'. including the ones whose filenames begin in a dot.compares files. words. Because Linux is freely redistributable. chmod o+r filename will make the file readable for everyone. There are other tools for this purpose. which will ask you for confirmation before actually deleting anything. diff filename1 filename2 --. 5. and characters there are in a file chmod options filename --.is an editor that lets you create and edit a file. mv filename1 filename2 --. who owns the file and who has the right to look at it. compress). the exact size of the file. e.in . gives it a different name.net.tells you how many lines. See help protection for more details.UNIT 1 distribution intended to run as a server may omit any graphical environment from the standard install and instead include other software such as the Apache HTTP Server and a SSH server like OpenSSH.compresses files. or moves it into a different directory (see below) cp filename1 filename2 --. so that they take up much less space. but gzip usually gives the highest compression rate.removes a file. and shows where they differ wc filename --. E-mail : info@wit. For example. Just hit the space bar to see more or q to quit. Basic UNIX/LINUX Commands Files • • • • • • • • • • ls --.wit. The main supporting user space system tools and libraries from the GNU Project (announced in 1983 by Richard Stallman) are the basis for the Free Software Foundation's preferred name GNU/Linux. more filename --. write.e.shows the first part of a file.g. o o • Directories Directories. and fgrep) and has a lot of very flexible options.in . o lpq --.print. You can even print it directly. or if you're at CSLI. E-mail : [email protected] .looks for the string in the files. if you use ff -p you don't even need the full name.g. just the beginning. using gzcat filename | lpr printing o lpr filename --.change directory. World Institute Of Technology 8km milestone . Check out the man pages if this sounds good to you. pwd --. like folders on a Macintosh.you can make big leaps or avoid walking around by specifying pathnames. o genscript --.g.Sohna Palwal Road . You don't have to walk along step by step .e. e.g.find files anywhere on the system. to get the number needed for removal. 'cd .check out the printer queue. and you can get back there by typing 'cd' without arguments. You always start out in your 'home directory'. grep string filename(s) --.lets you look at a gzipped file without actually having to gunzip it (same as gunzip -c). For example. Finding things • • ff --. This can be useful a lot of purposes. are used to group files together in a hierarchical structure. This can be extremely useful if you've forgotten in which directory you put a file. and you will see the files in that directory when you do 'ls'. Gurgaon .uncompresses files compressed by gzip. Use the -P option to specify the printer name if you want to use a printer other than your default printer. e. and gives you some options for formatting..tells you where you currently are. and even doing serious corpus work. use 'lpr -Pvalkyr-d'. files produced by LaTeX). finding the right file among many. o dvips filename --.Sohna . In fact. but this isn't necessary as long as you use your default printer in the department.wit.net.' will get you one level up from your current position. Consider making an alias like alias ecop 'genscript -2 -r \!* | lpr -h -Pvalkyr' to print two pages on one piece of paper. Theoretically you also have to specify a printer name. You can find the job number by using lpq. You can use dviselect to print only selected pages.make a new directory cd dirname --. but do remember the name.Haryana. This can also be useful for finding other things on the system. gzcat filename --. See 'help printers' for more information about printers and their locations. grep comes in several varieties (grep.UNIT 1 gunzip filename --. NH-71 B . documentation. if you want to print double-sided. You basically 'go' to another directory. figuring out which is the right version of something. • • • mkdir dirname --. See the LaTeX page for more information about how to save paper when printing drafts. or to see how many other files will be printed before yours will come out o lprm jobnumber --.converts plain text files into postscript for printing. e.in Website : www. you may want to use 'lpr Pcord115-d'.net.remove something from the printer queue.dvi files (i. egrep. E-mail : info@wit. don't panic. Be careful not to kill your current shell .lets you send e-mail messages to people around the world (and. It's not the only mailer you can use. Contains lots of information about them. which you should do regularly (at least once a year). in a file called . Try to create a useful . Useful if you're looking for someone who's actually physically in the same building as you. because they're root processes.Sohna Palwal Road . who --.plan' if necessary.net. This information is also displayed by 'finger'. See the elm page.net. Often people put other practical information. Get the ID by using ps.g. and where they're coming from.lets you change your password. finger & .kills (ends) the processes with the ID you gave.plan file soon. and anything you were running. Especially useful: the 'idle' part.lets you have a (typed) conversation with another user write username --. kill PID --.plan files for ideas. finger username --.tells you when the user last logged on and off and from where.plan files of course you can finger yourself. You should realize that this information is accessible from anywhere in the world. Sounds useless. which you need if you have to kill a process. NH-71 B . Without any options. including the process ID. passwd --. of course. and find out about the departmental mailing lists (which you can also find in /user/linguistics/helpfile). Normally. Gurgaon . but the one we recommend.tells you who's logged in.Sohna . The file needs to be readable for everyone in order to be visible through 'finger'. and make sure *you* have logged out. such as phone numbers and addresses. read them).UNIT 1 About other people • • • • • • • w --. This works only for your own processes.lets you exchange one-line messages with another user elm --. too. but isn't.plan.in . You may need to find out who it is who forgot to log out somewhere. This allows you to see whether they're actually sitting there typing away at their keyboards right at the moment.returns your username. Do 'chmod a+r .wit. last will give you a list of everyone's logins. or in some other particular location.g. These will show only when you use ps -efl. as a quick check whether you got new mail. If the process doesn't 'die' properly.tells you who's logged on.in Website : www. Look at other people's . Those may include the shell (tcsh or whatever you're using). not just to other people on turing. for example emacs or elm. ps -u yourusername --. last -1 username --. e.the one with the number closer to the one of the ps command you're currently running. But if it happens. this list will contain the processes you need to kill. That can be useful e. use World Institute Of Technology 8km milestone .Haryana. when you have been kicked out of a dialin session or have otherwise managed to get yourself disconnected abruptly. See the LRB guide and/or look at help password. when they last read their mail and whether they're logged in. About your (electronic) self • • • • • whoami --.gives you lots of information about that user. of course. and what they're doing.lists your processes. talk username --. Just try again :) If you're using an X-display you may have to kill some X processes before you can start them again. 6.show what your disk quota is (i. last yourusername --.in . NH-71 B .Haryana. how long you've been working for. including home and business desktops. It was first released in August 2001. Gurgaon . quota -v --.UNIT 1 • • • the option -9. which was released to volume license customers on November 8. and media centers. Windows XP was the successor to both Windows 2000 and Windows Me.wit. du filename --. or moving them to your own computer). which sometimes happens. The name "XP" is short for "eXPerience”. Introduction to Windows XP Windows XP is an operating system that was produced by Microsoft for use on personal computers.net.in Website : www. World Institute Of Technology 8km milestone . You may need to kill processes for example if your modem connection was interrupted and you didn't get logged out properly. It was succeeded by Windows Vista.e. and was the first consumer-oriented operating system produced by Microsoft to be built on the Windows NT kernel and architecture. and worldwide to the general public on January 30. du -s gives only a total.Sohna Palwal Road . how much you're actually using. Can be a useful memory aid for when you were where.lists your last logins. Windows XP was released for retail sale on October 25. E-mail : info@wit. according to an estimate in that month by an IDC analyst. laptops. because it doesn't give the process a chance to finish possibly important business before dying. and over 400 million copies were in use in January 2006. But attempt without that option first.Sohna . 2006.shows the disk usage of the files and directories in filename (without argument the current directory is used). how much space you have to store files). and is the most popular version of Windows. and in case you've exceeded your quota (which you'll be given an automatic warning about by the system) how much time you have left to sort them out (by deleting or gzipping some. and keeping track of your phonebill if you're making a non-local phonecall for dialling in.net. 2001. based on installed user base. Windows XP Media Center Edition has additional multimedia features enhancing the ability to record and watch TV shows. XP may continue to be available as these sources run through their inventory or by purchasing Windows 7 Ultimate. Windows XP had also been criticized by some users for security vulnerabilities. Windows Vista Ultimate or Windows Vista Business. Service Pack 3. Microsoft continued to sell Windows XP through their System Builders (smaller OEMs who sell assembled computers) program until January 31.Sohna Palwal Road . The NT-based versions of Windows. are known for their improved stability and efficiency over the 9x versions of Microsoft Windows. There is also Windows XP Embedded. and Windows XP Professional.net. view DVD movies. and was targeted at power users.1% in January 2007. and listen to music.wit. and assembly. business and enterprise clients.in Website : www. Windows XP is the most widely used operating system for accessing the Internet in the world with a 47. C++.2% market share. a manufacturer revealed the first Windows XP powered cellular telephone. Later versions with Service Pack 2. Windows XP Tablet PC Edition was designed to run stylus applications built using the Tablet PC platform. Gurgaon .net. 2009. World Institute Of Technology 8km milestone . and for aspects of its default user interface. which offered additional features such as support for Windows Server domains and two physical processors. A new software management facility called Side-by-Side Assembly was introduced to ameliorate the "DLL hell" that plagues 9x versions of Windows. Windows XP was eventually released for two additional architectures. British Columbia. 2008. Windows 7 Pro. a change Microsoft promoted as more user-friendly than previous versions of Windows. after Whistler.UNIT 1 2007. NH-71 B . During development. According to web analytics data generated by W3Schools.Windows XP presented a significantly redesigned graphical user interface. E-mail : [email protected] . and Internet Explorer 8 addressed some of these concerns. which was targeted at home users. and editions for specific markets such as Windows XP Starter Edition. which are programmed in C. having peaked at 76. as of December 2010. Direct OEM and retail sales of Windows XP ceased on June 30. as many Microsoft employees skied at the Whistler-Blackcomb ski resort. a component version of the Windows XP Professional.Haryana. The most common editions of the operating system were Windows XP Home Edition. the project was codenamed "Whistler". By mid 2009. and then downgrading to Windows XP. Windows XP 64-bit Edition for IA-64 (Itanium) processors and Windows XP Professional x64 Edition for x8664. tight integration of applications such as Internet Explorer 6 and Windows Media Player. It is also the first version of Windows to use product activation to combat illegal copying.Sohna . Introduction to Programming Language Characteristics of good Programming Language Machine Language Advantages of Machine language Disadvantages of Machine language 8. 4. C. called machine languages. NH-71 B .net. are more complex than the languages the computer actually understands.Sohna . C++. COBOL. High-level programming languages. Each language has a unique set of keywords (words that it understands) and a special syntax for organizing program instructions. but they are much easier to program in because they allow a programmer to substitute names for numbers. FORTRAN. Each different type of CPU has its own unique machine language. Assembly languages are similar to machine languages. while simple compared to human languages.Haryana.net. E-mail : info@wit. Ada. Machine languages consist of numbers only. such as BASIC. World Institute Of Technology 8km milestone .in Website : www.Sohna Palwal Road .in . 2. 5. and Pascal. Introduction to Programming Language A vocabulary and set of grammatical rules for instructing a computer to perform specific tasks.wit. The term programming language usually refers to high-level languages. Gurgaon .UNIT 1 Lecture: 9 Basic Introduction to System Software and Programs : Machine Language Contents 1. 3. Lying between machine languages and high-level languages are languages called assembly languages. net. and the expertise of the programmer.net. 9. Portability – the extent to which inherent language features support the transfer of a program from one hardware and/or software platform to another. Regardless of what language you use. Real-time support – the extent to which inherent language features support the construction of real-time systems. 4GLs are far removed from machine languages and represent the class of computer languages closest to human languages. Every language has its strengths and weaknesses.wit. 4. 8. 6. what sort of program it is. NH-71 B . World Institute Of Technology 8km milestone . Clarity of source code – the extent to which inherent language features support source code that is readable and understandable and that clearly reflects the underlying logical structure of the program. C++ embodies powerful object-oriented features. but it is not as flexible as the C programming language. 7. but it is complex and difficult to learn.in Website : www. Pascal is very good for writing well-structured and readable programs. 3. E-mail : info@wit. 9. Maintainability – the extent to which inherent language features support the construction of code that can be readily modified to satisfy new requirements or to correct deficiencies. Concurrency support – the extent to which inherent language features support the construction of code with multiple threads of control (also known as parallel processing).Haryana. but it does not lend itself very well to organizing large programs. interface.Sohna Palwal Road .Sohna . FORTRAN is a particularly good language for processing numerical data. Complexity management (architecture support) – the extent to which inherent language features support the management of system complexity. Characteristics of good Programming Language 1. Mixed language support – the extent to which inherent language features support interfacing to other languages. Object-oriented programming support – the extent to which inherent language features support the construction of object-oriented code. 5. in terms of addressing issues of data. you eventually need to convert your program into machine language so that the computer can understand it. There are two ways to do this: • • compile the program interpret the program The question of which language is best is one that consumes a lot of time and energy among computer professionals. The choice of which language to use depends on the type of computer the program is to run on.in . Gurgaon .UNIT 1 Lying above high-level languages are languages called fourth-generation languages (usually abbreviated 4GL). algorithm. 2. For example. Distributed system support – the extent to which inherent language features support the construction of code to be distributed across multiple platforms on a network. and architectural complexity. Machine Language The lowest-level programming language (except for computers that utilize programmable microcode) Machine languages are the only languages understood by computers. Support for modern engineering methods – the extent to which inherent language features support the expression of source code that enforces good software engineering principles. Programmers. Reusability – the extent to which inherent language features support the adaptation of code for use in another application.UNIT 1 10. yielding systems that are fault-tolerant. Rather than writing programming code at this level. Safety – the extent to which inherent language features support the construction of safety-critical systems. NH-71 B . Low Level Language Lower level languages are typically assembly languages that are machine specific. we've developed languages that compile into the zeros and ones that computers understand. This can provide more control and efficiency for the program and can be good for applications which need high speed execution.in Website : www. Standardization – the extent to which the language definition has been formally standardized (by recognized bodies such as ANSI and ISO) and the extent to which it can be reasonably expected that this standard will be followed in a language translator. or robust in the face of systemic failures. interpreting zeros and ones as instructions. It is a most efficient in term of storage area use and execution speed and it also allows programmer to utilize the computer's potential for processing data. 2. E-mail : info@wit. An assembly language contains the same instructions as a machine language. 14.net. 12.Haryana.in . fail-safe. 4. Reliability – the extent to which inherent language features support the construction of components that can be expected to perform their intended functions in a satisfactory manner throughout the expected lifetime of the product. Computers run instructions at the binary level. 13. becoming higher level languages. therefore. they get further and further way from zeros and ones. 11.Sohna . 5. but high level compilers are much better at optimizing for speed now. Advantages of Machine Language 1. As these languages become more robust. While easily understood by computers. Gurgaon . 3.net.Sohna Palwal Road . use either a high-level programming language or an assembly language. World Institute Of Technology 8km milestone . but the instructions and variables have names instead of being just numbers. machine languages are almost impossible for humans to use because they consist entirely of numbers.wit. Low level languages will require more involvement with the actual register and interrupt interfaces to the hardware. The only advantage is that program of machine language run very fast because no translation program is required for the CPU. it may not need a compiler.Haryana. like to where the specific data will be stored.Sohna Palwal Road .net. how operations and functions be carried out. In machine language. 2. 6. E-mail : info@wit. It is difficult to debug the program. Gurgaon . 3. Disadvantages of Machine Language 1.Sohna . The programmer has to know details of hardware to write program. the very basic and specific commands may be used.UNIT 1 3.in .in Website : www. World Institute Of Technology 8km milestone . and since it is in a code the machine can understand. It is very difficult to program in machine language.wit. The programmer has to remember a lot of codes to write a program which results in program errors. NH-71 B .net. but they enable a programmer to use names instead of numbers.in Website : www. NH-71 B . World Institute Of Technology 8km milestone . usually viewed as a sequence of hexadecimal numbers (typically bytes). and the bits represent "instructions" as to what to do next. Each type of CPU has its own machine language and assembly language. 8. Programmers still use assembly language when speed is essential or when they need to perform an operation that isn't possible in a highlevel language. Assembly Language Machine languages consist entirely of numbers and are almost impossible for humans to read and write. 3.net. 4. In the early days of programming. punched tape. 7.Sohna Palwal Road . most programs are written in a high-level language such as FORTRAN or C. Assembly languages have the same structure and set of commands as machine languages.Sohna . 8. Thus machine language provides a way of entering instructions into a computer (whether through switches. Gurgaon . Assembly language Comparison Between Assembly & Machine Language Advantage of Assembly language Disadvantage of Assembly language High Level Language Advantages of High Level Language Disadvantages of High Level Language Types of High Level Language 7.UNIT 1 Lecture: 10 & 11 Assembly Language. E-mail : info@wit. Now. or a binary file). High level Languages.Haryana. Types of high level languages Contents 1.net. 2. so an assembly language program written for one type of CPU won't run on another. all programs were written in assembly language. 5.wit. 6.in . Comparison Between Assembly & Machine Language Machine language is the actual bits used to control the processor in the computer. The processor reads these bits in from program memory. Assembly langauge also has no support of an operating system.wit. 10. nor does it have any complex instructions.net. for example.in . assembly language get very cumbersome. Using machine code allows the programmer to control precisely what the processor does. Finally. Machine language faster than assembly language even than assembly language depend upon machine language. It offers a great deal of power to use all of the features of the processor. or Pascal that enables a programmer to write programs that are more or less independent of a particular type of computer. can be calculated very precisely and program flow is easily controlled. The resulting program is normally very fast and very compact. every processor has its own assembly language. Timings. As programs become larger. A programming language such as C. High Level Language Programs written in high-level languages are translated into assembly language or machine language by a compiler. It is often used for small. E-mail : info@wit. or mnemonics. In small programs it is also very predictable.in Website : www. FORTRAN. Programs must be rewritten or recompiled. assembly needs the whole process to be programmed step by step. to run on different types of computers. A disassembler performs the reverse function (although the comments and the names of labels will have been discarded in the assembler process).Sohna . 11. especially if another programmer is brought in to carry out modifications after the code has been written.Sohna Palwal Road . The main abstractions (apart from the mnemonics) are the use of labels instead of fixed memory addresses. Such languages are considered high-level because they are closer to human languages and further from machine languages.net. Disadvantages of Assembly Languages The programmer needs to have a good understanding of the hardware being used. Use a new processor and you need to learn a new language each time. the instructions and registers are given names (typically abbreviated words. Assembly language programs are translated into machine language by a program called an assembler. Maintenance of assembly language is notoriously difficult. Every CPU has its own unique machine language. real time applications. assembler is very close to the machine language. Unlike a high level language. Mathmatical processes also have to be performed with binary addition and subtraction when using assembly which can get very complex. Instead of representing the machine language as numbers.UNIT 1 Assembly language is a more human readable view of machine language. World Institute Of Technology 8km milestone . Storing and retrieving data is a simple task with high level languages. therefore. NH-71 B . and comments. An assembly language program (ie a text file) is translated to machine language by an assembler. 9. In contrast. eg ld means "load").Haryana. Advantages of Assembly Languages Assembly language is a symbolic representation of a processor's native code. Gurgaon . assembly languages are considered low-level because they are very close to machine languages. and Prolog. But. Net etc. programs written in a high-level language must be translated into machine language by a compiler or interpreter. Disadvantages of High Level Languages Though it is much easier to code in a high level language. It is that easy. This will incredibly save you space and increase speed.Sohna . High level programming languages like C. Algol. 13. Programmer can perform complex task by using high level languages with less efforts. In high level languages programmer needs not to write all steps because computer take cares of all small error. say Java.Sohna Palwal Road . BASIC. VB. PASCAL. first the Java Compiler will compile it to byte code. Advantages of High Level Language In high level languages we can write programs in English like manner and is more convenient to use. C++ and Java give you comfort and a pool of options because they basically use a syntax that is similar to the everyday English we speak. the ability to communicate directly with the compiler and alter code before it gets transferred into machine code is lost. There are different high level languages such as FORTRAN (Formula Instructions). LISP.Haryana.wit. High level languages are very similar to nature language such as English so they are very easy to learn and use. COCOL (Common Business Oriented Language). when you write low level code. For instance. why are low-level programming languages important? Low level programming languages are important because of space and speed. write. C. this byte code is again compiled during run time to assembly code(low level) which in turn is again converted to executable code. High level languages have many advantages. If you write a program in a high level language. Ultimately. E-mail : info@wit. BASIC (Beginners All Purpose Symbolic Instruction Code). COBOL. Pascal. Now.net. including Ada. To make it more easier for the programmer to understand and write code.UNIT 1 The main advantage of high-level languages over low-level languages is that they are easier to read. correct and modify but in high level languages it is very easy to understand and modify when desired. NH-71 B . Now. FORTRAN. For higher level languages programmers needs not to learn about internal structure of the computer. In lower level languages instruction are difficult and very hard to locate. Gurgaon . Visual Basic.in Website : www. and maintain. it is directly converted into executable code avoiding all the other steps. Compilers of high level languages automatically catch and point out the errors made by the programmers. The first high-level programming languages were designed in the 1950s. C++. Coding a computer today is just one step below to talking to a human. That is the reason why Bill World Institute Of Technology 8km milestone .net. 12. Now there are dozens of different languages. High level language programs require less time and efforts that due the preparation cost of the program. C++. High level programs are very easy to maintain than lower level languages.in . oftentimes access to more low-level functionalities are lost. 14. COBOL has many reserved words (over 400).Sohna . Gurgaon . However. or structured programming constructs. called keywords. and any "GOTO X" statements executed after such an ALTER statement have the meaning "GOTO Y" instead. Most compilers still support it.in . at low level. COBOL is one of the oldest programming languages. nearly all use of computers required writing custom software. Support for some or all of these features has been added in later editions of the COBOL standard. It did not support local variables.Sohna Palwal Road . dynamic memory allocation. but it should not be used in new programs.NET as their only language. USA to provide computer access to non-science students. At the time.net. you have to manage everything: memory and everything. The language and its variants became widespread on microcomputers in the late 1970s and 1980s.in Website : www. Self-modifying code The original COBOL specification supported self-modifying code via the infamous "ALTER X TO PROCEED TO Y" statement. As of 2006. defining its primary domain in business.wit. BASIC remains popular to this day in a handful of highly modified dialects and new languages influenced by BASIC such as Microsoft Visual Basic.NET platform used Visual Basic .Haryana. finance. 59% of developers for the . X and Y are paragraph labels. Features COBOL as defined in the original specification included a PICTURE clause for detailed field specification. E-mail : info@wit. The original BASIC was designed in 1964 by John George Kemeny and Thomas Eugene Kurtz at Dartmouth College in New Hampshire. for example ADD YEARS TO AGE The equivalent construct in many procedural languages would be World Institute Of Technology 8km milestone . In computer programming. and administrative systems for companies and governments. BASIC is a family of high-level programming languages.UNIT 1 Gates said that 1MB is the unreachable limit. Because. The COBOL 2002 standard includes support for object-oriented programming and other modern language features. Types of High Level Languages a) BASIC. Its name is an acronym for COmmon Business-Oriented Language.net. Syntactic features COBOL provides an update-in-place syntax. recursion. the time consumed to write a program will be very large. b) COBOL. which was something only scientists and mathematicians tended to do. NH-71 B . World Institute Of Technology 8km milestone . these are chunks of code which can be inserted into a program's code.Sohna Palwal Road . The SET statement can be used to make a named condition TRUE (by assigning the first of its values to the conditional variable).Sohna . Successive versions have added support for processing of character-based data array programming. Fortran is a general-purpose.g. modular programming and object-based programming and object-oriented and generic programming. and is the language used for programs that benchmark and rank the world's fastest supercomputers. each of which evolved to add extensions to the language while usually retaining compatibility with previous versions. imperative programming language that is especially suited to numeric computation and scientific computing. This is done with the COPY statement.net.Haryana. and tests whether the conditional variable is equal to any of the values given in the named condition's VALUE clause.UNIT 1 age = age + years This syntax is similar to the compound assignment operator later adopted by C: age += years The abbreviated conditional expression IF SALARY > 9000 OR SUPERVISOR-SALARY OR = PREV-SALARY is equivalent to IF SALARY > 9000 OR SALARY > SUPERVISOR-SALARY OR SALARY = PREV-SALARY COBOL provides "named conditions" (so-called 88-levels). finite element analysis. computational physics and computational chemistry. When COBOL was introduced. 6 characters for FORTRAN) were prevalent. COBOL allows identifiers to be up to 30 characters long.in Website : www. It was one of the most popular languages in the area of high-performance computing.wit. The concept of copybooks was introduced by COBOL. c) FORTRAN.. California in the 1950s for scientific and engineering applications. FORTRAN encompasses a lineage of versions. Fortran came to dominate this area of programming early on and has been in continual use for over half a century in computationally intensive areas such as numerical weather prediction.net.in . These are declared as sub-items of another item (the conditional variable). computational fluid dynamics. Originally developed by IBM at their campus in south San Jose. much shorter lengths (e. E-mail : info@wit. which also allows parts of the copybook's code to be replaced with other code. The named condition can be used in an IF statement. NH-71 B . procedural. Gurgaon . Contents 6.in Website : www.Sohna . Interpreter. Loader. Gurgaon . Compilers require some time before an executable program emerges. Compiler 7. Loader and Linker. Compiler A program that translate source code into object code. E-mail : [email protected]. programs produced by compilers run much faster than the same programs executed by an interpreter. Relationship between Complier. a compiler differs from an interpreter. However. Assembler. which analyzes and executes each line of source code in succession. looking at the entire piece of source code and collecting and reorganizing the instructions. Interpreter.in .wit.net. Thus. The compiler derives its name from the way it works. World Institute Of Technology 8km milestone . without looking at the entire program. Linker. The advantage of interpreters is that they can execute a program immediately.Haryana. Linker 1. Interpreter 8. Assembler 9.Sohna Palwal Road .UNIT 1 Lecture: 12 & 13 Complier. NH-71 B . Loader 10. net. For this reason. interpreters are sometimes used during the development of a program. the compiler industry is quite competitive. An interpreter translates high-level instructions into an intermediate form.Sohna . because it defines which instructions are acceptable. Because compilers translate source code into object code. E-mail : info@wit. NH-71 B . Gurgaon . the other method is to pass the program through an interpreter. This process can be time-consuming if the program is long. For example. there is a FORTRAN compiler for PCs and another for Apple Macintosh computers. BASIC and LISP are especially designed to be executed by an interpreter.in . In addition. The interpreter.net. however. which is unique for each type of computer. The most common is to compile the program. a compiler translates high-level instructions directly into machine language.UNIT 1 Every high-level programming language (except strictly interpretive languages) comes with a compiler. many compilers are available for the same language. In addition. which it then executes.Sohna Palwal Road . In contrast. interpreters are often used in education because they allow students to program interactively.Haryana. In effect. when a programmer wants to add small sections at a time and test them quickly. page description World Institute Of Technology 8km milestone . can immediately execute high-level programs. In addition. There are two ways to run programs written in a high-level language. More than a dozen companies develop and sell C compilers for the PC. the compiler is the language.in Website : www. However. Compiled programs generally run faster than interpreted programs. so there are actually many compilers for each language on each type of computer. The advantage of an interpreter. 2. Interpreter A program that executes instructions written in a high-level language. is that it does not need to go through the compilation stage during which machine instructions are generated. on the other hand. Both interpreters and compilers are available for most high-level languages.wit. in Website : www.Sohna Palwal Road .Haryana. NH-71 B . but the operating system uses them when necessary. Most loaders are transparent. use an interpreter. Algorithms can be expressed in any language. a recipe for baking a cake is an algorithm. where they can be executed. Most programs. i. Inventing elegant algorithms -. E-mail : info@wit. consist of algorithms. has a built-in interpreter that executes PostScript instructions. the loader can also replace virtual addresses with physical addresses. a set of rules must be unambiguous and have a clear stopping point. Flow Chart A flowchart is a schematic representation of an algorithm or a process.net. We use algorithms every day. In addition to copying a program into main memory. For example. 4.in . Assembler A program that translate programs from assembly language to machine language. from natural languages like English or French to programming languages like FORTRAN.e.algorithms that are simple and require the fewest steps possible -is one of the principal challenges in programming.wit.Sohna . you cannot directly execute them. Every PostScript printer. or the step-by-step solution of a problem. To be an algorithm. such as PostScript. 3. Algorithm (al´g&-rith-&m) (n..) A formula or set of steps for solving a particular problem. for example. Gurgaon . using suitably annotated geometric figures connected by flowlines for the purpose of designing or documenting a process or program World Institute Of Technology 8km milestone .UNIT 1 languages. Loader An operating system utility that copies programs from a storage device to main memory. with the exception of some artificial intelligence applications.net. one corresponding to Yes or True. • A number of other symbols that have less universal currency. Alternatively. A flowchart is one of the seven basic tools of quality control. for example. a conditional with one arrow exiting the loop.Haryana. with the top irregularly sloping up from left to right.wit. • Input/Output. which also includes the histogram. cause-and-effect diagram. display X. Some flow charts may just have an arrow point to another arrow instead.in Website : www. check sheet. These typically contain a Yes/No question or True/False test. An arrow coming from one symbol and ending at another symbol represents that control passes to the symbol the arrow points to. o A Manual input represented by parallelogram. showing what's called "flow of control" in computer science.Sohna Palwal Road . NH-71 B . • Processing steps. represented as a parallelogram. OffWorld Institute Of Technology 8km milestone . usually represented as circles. Pareto chart. Gurgaon . and one corresponding to No or False. This symbol is unique in that it has two arrows coming out of it. such as "submit enquiry" or "receive product". o A Manual operation represented by a trapezoid with the longest parallel side at the top. Circles will have more than one arrow coming into them but only one going out. A loop may. A symbol appearing in a particular "lane" is within the control of that organizational unit. usually containing the word "Start" or "End". ovals or rounded rectangles. and one going back to the connector.UNIT 1 Overview A flowchart is described as "cross-functional" when the page is divided into different "lanes" describing the control of different organizational units. More than two arrows can be used. An example would be to signify data-entry from a form. or to find flaws in the process. Examples: Get X from the user. "save changes" or similar. consist of a connector where control first enters. represented as a diamond (rhombus). • Arrows. in which case it may need to be broken-down further. This technique allows the analyst to locate the responsibility for performing an action or making a decision correctly. or replaced with the "pre-defined process" symbol. and scatter diagram. The arrows should always be labeled. control chart. usually from the bottom point and right point.in . Symbols • Start and end symbols. • Conditional (or decision). such as connectors. but this is normally a clear indicator that a complex decision is being taken. one can use Nassi-Shneiderman diagrams. allowing the relationship between different organizational units with responsibility over a single process. to represent an operation or adjustment to process that can only be made manually. or another phrase signaling the start or end of a process. represented as rectangles. Examples: "Add 1 to X".Sohna . represented as lozenges. These are useful to represent an iterative process (what in Computer Science is called a loop).net. E-mail : [email protected]. "replace identified part". processing steps. to represent converging paths in the flow chart. They are commonly used in business/economic presentations to help the audience visualize the content better. o A Data File represented by a cylinder Flowcharts may contain other symbols. such as: o A Document represented as a rectangle with a wavy base. In addition to combining modules. a linker also replaces symbolic addresses with real addresses. Contents 7. called modules.UNIT 1 page connectors are often used to signify a connection to a (part of another) process held on another sheet or screen. Network devices. Introduction to Network 8. satellites.wit. radio waves.net. telephone lines. Modulation. Linker Also called link editor and binder. All processes should flow from top to bottom and left to right. The three basic types of networks include: World Institute Of Technology 8km milestone . Gurgaon .net. Introduction to Computer Network 9. It is important to remember to keep these connections logical in order. Lecture: 14 & 15 Basic Introduction to Computer Networks: . Introduction to Data Communication 11. Many programming languages allow you to write different pieces of code. Types of Network Device a) Hubs b) Switches c) Routers d) Bridges e) Gateways Introduction to Network A network consists of two or more computers that are linked in order to share resources (such as printers and CDs). more manageable pieces. NH-71 B . The computers on a network may be linked through cables. you may need to link a program even if it contains only one module.Sohna . Types of Networking 10. Introduction to Modulation 12.in Website : www. This is the job of the linker. though.in . a linker is a program that combines object modules to form an executable program. or infrared light beams.Haryana. separately. Eventually. E-mail : info@wit. Therefore. exchange files.Data Communication.Sohna Palwal Road . or allow electronic communications. you need to put all the modules together. This simplifies the programming task because you can break a large program into small. Network Devices 13. 5. is a collection of computers and devices interconnected by communications channels that facilitate communications among users and allows users to share resources.wit. or a fax machine) to one computer and let other computers of the network print (or scan. and then view the movie on a computer that lacks a DVD player You can connect a printer (or a scanner. often simply referred to as a network. A computer network. or fax) to that printer (or scanner. you can place a movie DVD on the computer that has a DVD player. In this case. Networks may be classified according to a wide variety of characteristics. A computer network can also consist of.Sohna .Sohna Palwal Road . In this case. or fax machine) You can place a CD with pictures on one computer and let other computers access those pictures You can create files and store them in one computer. A computer network allows sharing of resources and information among interconnected devices. you can burn CDs or make backups on a computer that has one of these but using data from a computer that doesn’t have a CD writer or a backup system You may have a computer that doesn’t have a DVD player.Haryana. E-mail : [email protected] 1 • • • Local Area Network (LAN) Wide Area Network (WAN) Metropolitan Area Network(MAN) Introduction to Computer Network A computer network can be two computers connected.net. Gurgaon .in Website : www.in . Characteristics of a Computer Network: The primary purpose of a computer network is to share resources: • • • • • • You can play a CD music from one computer while sitting on another computer You may have a computer with a CD writer or a backup system but the other computer doesn’t have it. then access those files from the other computer(s) connected to it Types of Networking Peer-to-Peer Networking World Institute Of Technology 8km milestone . and is usually made for. NH-71 B . more than two computers.net. or Windows XP Professional (you can also connect a Novell SUSE Linux as part of a Microsoft Windowsbased network. also referred to as topology).Sohna . as in a World Institute Of Technology 8km milestone . In a peer-to-peer network. each computer holds its files and resources. In a client/server environment. NH-71 B .Sohna Palwal Road . the current release of the operating system is really easily to install and made part of the network). Client Server Networking : A computer network is referred to as client/server if (at least) one of the computers is used to "serve" other computers referred to as "clients". Gurgaon . if a printer is connected to computer A and computer B wants to printer to that printer. Other computers can also access the resources stored in a computer. other types of devices can be part of the network. each computer still holds (or can still hold) its (or some) resources and files. computer A must be turned on.net. E-mail : [email protected]. Other computers can access these resources but a computer that has a particular resource must be turned on for other computers to access the resource it has. Besides the computers. Me. For example. A network is referred to as peer-to-peer if most computers are similar and run workstation operating systems: It typically has a mix of Microsoft Windows 9X. there are two types of networks.Haryana.net.UNIT 1 Based on their layout (not the physical but the imagined layout.in . Windows XP Home Edition.in Website : www. Modulation is utilized to send an information bearing signal over long distances. we are interested in "connectivity". the method of transfer and the preservation of the data during the transfer process. Since the server is always On. called a user must provide some credentials. Introduction to Modulation Modulation is the process of varying some characteristic of a periodic wave with an external signals. languages. These high frequency carrier signals can be transmitted over the air easily and are capable of traveling long distances. connecting computers together to share resources. The client/server type of network also provides many other advantages such as centralized backup. If the credentials are not valid. The modulating signal is a slowly varying signal – as opposed to the rapidly varying carrier frequency.Sohna . the information bearing signal is also known as the modulating signal.net.in .net. Radio communication superimposes this information bearing signal onto a carrier signal. NH-71 B . etc. World Institute Of Technology 8km milestone .Sohna Palwal Road . In the field of communication engineering. Data Communication is interested in the transfer of data. Another big advantage of a client/server network is that security is created. E-mail : info@wit. including a username and a password. This means that a computer. The rules and regulations are called protocols and standards in Data Communications. Internet monitoring. managed. frequency. cabling and locations to share resources. languages. the client machines can access the files and resources without caring whether a certain computer is On.wit. The actual generation of the information is not part of Data Communications nor is the resulting action of the information at the receiver. cabling and locations. To access the network. a person. In Local Area Networks. Even though the computers can have different disk operating systems. they still can communicate to one another and share resources. One of the particularities of a client/server network is that the files and resources are centralized.UNIT 1 peer-to-peer scenario. the user can be prevented from accessing the network. Introduction to Data Communication Data Communications is the transfer of data or information between a source and a receiver. and can highly get enforced.in Website : www. The characteristics (amplitude. or phase) of the carrier signal are varied in accordance with the information bearing signal. The source transmits the data and the receiver receives it. the server. Intranet capability.Haryana. can hold them and other computers can access them. The purpose of Data Communications is to provide the rules and regulations that allow computers with different disk operating systems. Gurgaon . E-mail : info@wit. and if online access is desired.in . clients. To direct these signals. The router is the equivalent of an electronic traffic cop that handles data traffic between the computers. The server is connected to an external hub.Sohna Palwal Road . which the clients are also connected to. To direct these signals.Haryana. Happily this is much less c In a network. The router is the equivalent of an electronic traffic cop that handles data traffic between the computers.net. A LAN requires a hub. and the others. Now that the computers each have one foot in a common electronic door (the hub). they can use the hub to pass signals back and forth. and the others.Sohna .net. The server is connected to an external hub. Gurgaon .in Website : www. the hub contains a device known as a router. they can use the hub to pass signals back and forth. Now that the computers each have one foot in a common electronic door (the hub). NH-71 B . a high-speed modem.UNIT 1 Types of Modulation • Amplitude Modulation • Frequency Modulation • Phase Modulation Network Devices Network devices are components used to connect computers or other electronic devices together so that they can share files or resources like printers or fax machines. Devices used to setup a Local Area Network (LAN) are the most common type of network devices used by the public.wit. network cards. Types of Network Devices World Institute Of Technology 8km milestone . router. which the clients are also connected to. the hub contains a device known as a router. one computer is designated as the server. clients. one computer is designated as the server. In a network. cabling or radio technology. This means that each port on the switch has the full bandwidth dedicated to it. and transmit it on that network. With 4 computers. When the destination computer receives the request. Hubs work by broadcasting data to all computers that are connected to it. the bandwidth drops to 25Mbps b) Switches Switches are similar to hubs in that they allow you to connect multiple computers together on a network. which means they can either receive or transmit. c) Routers A router is used to route data packets between two networks. readdress the packet to the proper ethernet address. The added benefit of this is that the bandwidth is not subdivided.Sohna Palwal Road .net. If it is destined for an immediate network it has access to. They can connect networks with different architectures such as Token Ring and Ethernet. Connecting a hub to a network is very easy.net. that can boost the performance of your network. It reads the information in each packet to tell where it is going. Once again the hub broadcasts the information to all computers.Sohna . then the bandwidth available to each computer is 50Mbps.in Website : www. The downside to this type of connection is that the bandwidth is subdivided between the number of computers that are connected to the hub. switches establish a direct connection between the transmitting and receiving computers. While hubs transmit data via broadcasting the data to all computers that are connected to it.in .or full-duplex (receive and transmit at the same time). and 2 computers connected to the hub. it sends the information back to the hub. Routing occurs at the network layer of the OSI model. Gurgaon . The performance increase has to do with how data is transmitted between the computers on your network. with only the requesting computer acting on the information. If it is destined for another network and must be sent to another router. Hubs are half-duplex. it will strip the outer packet (IP packet for example). You can simply connect a hub to your router. If you have a 100Mbps connection.UNIT 1 a) Hubs A hub is a piece of hardware that contains several ethernet ports that connects several computers. the total bandwidth available to both computers is 100Mbps.wit. but not both at the same time. it will re-package the outer packet to be received by the next router and send it to the next router. When a computer or program makes a request for information from another computer. however. routers cannot transform information from one data World Institute Of Technology 8km milestone . and then several computers to the hub. E-mail : info@wit. the originating computer sends (broadcasts) the request to the hub.Haryana. NH-71 B . If you have a 100Mbps bandwidth on your network with 2 computers connected to a switch. Although they can transform information at the data link level. The IP addresses of the computers that are connected to the hub are assigned by the router it is connected to. There are several differences between hubs and switches. Many switches also have the ability to either use half. The hub will then brodcast the request to all computers that are connect to it. You can also connect switches to routers in the same way you connect hubs. and periodically broadcasts the routing table to other routers which takes more network bandwidth especially with more routers. To determine the network segment a MAC address belongs to. Gurgaon .Routing information protocol uses a distance vector algorithm.Use dynamic routing algorithms. There are two types of routers: 1. • RIP .in . 2.in Website : www. and will function as a router for routable protocols. NH-71 B .Sohna Palwal Road . which means the bridge cannot read IP addresses.UNIT 1 format such as TCP/IP to another such as IPX/SPX.They build a table of addresses (bridging table) as they receive packets. but only the outermost hardware address of the packet. Routers do not send broadcast packets or corrupted packets. • IPX . not the IP address. • NLSP . o Link state . E-mail : info@wit. Dynamic routers . Common routing protocols include: • IS-IS -Intermediate system to intermediate system which is a routing protocol for the OSI suite of protocols. bridges use one of: • • Transparent Bridging . RIP uses distance vectoring.net. It reduces the traffic on other network segments. Bridges do not normally allow connection of networks with different architectures. Static routers . d) Bridges A bridge reads the outermost section of data on the data packet. Bridging occurs at the data link layer of the OSI model.The source computer provides path information inside the packet. If the address is not in the bridging table.Are configured manually and route data packets based on information in a router table.Sohna .Routing tables are broadcast at startup and then only when they change.net. to tell where the message is going.Uses OSPF algorithm and is replacing IPX to provide internet capability. the packet is forwarded to all segments other than the one it came from. The open shortest path first (OSPF) protocol uses the link state routing method to configure routes or distance vector algorithm (DVA). Does not work on WANs as well as it does on LANs. World Institute Of Technology 8km milestone . It functions at the network and data link layers of the OSI network model. Used on Netware systems. There are two types of algorithms: o Distance vector .Internet Packet Exchange. the packet is discarded.wit. In our case the bridge can read the ethernet data which gives the hardware address of the destination address. There is a device called a brouter which will function similar to a bridge for network transport protocols that are not routable. Bridges can be programmed to reject packets from particular networks. since it does not send all packets.Haryana.Based on hop count. This type of bridge is used on ethernet networks. Only a special bridge called a translation bridge will allow two networks of different architectures to be connected. The hardware address is also called the MAC (media access control) address. This is used on Token Ring networks. If the routing table does not indicate the proper address of a packet. Bridges forward all broadcast messages.Netware Link Services protocol . Source route bridging . To confuse issues. Most Indiana University Bloomington departments are on LANs. Introduction to WAN 1.Sohna Palwal Road . Introduction to MAN 3. This does not mean the routing machine is a gateway as defined here.in Website : www.UNIT 1 e) Gateways A gateway can translate information between different network data formats or network architectures.wit.net. the connections must be high speed and relatively inexpensive (e. MAN & WAN Contents 1. By definition.. Introduction to LAN 2.g. Introduction to LAN A LAN (local area network) is a group of computers and network devices connected together.in . NH-71 B . token ring or Ethernet). World Institute Of Technology 8km milestone . when talking about a router that is used to interface to another network. the word gateway is often used.Haryana. Most gateways operate at the application layer. Gurgaon . It can translate TCP/IP to AppleTalk so computers supporting TCP/IP can communicate with Apple brand computers. E-mail : info@wit. Gateways will start at the lower level and strip information until it gets to the required level and repackage the information and work its way back toward the hardware layer of the OSI model. usually within the same building. although it could be.Sohna . but can operate at the network or session layer of the OSI model. Lecture: 16 LAN.net. wireless. The IUB network is an example of a MAN.net.wit. Speeds adequate for most distributed systems Problems : Multi media based applications Typically buses or rings. E-mail : info@wit. coaxial cables. Token Ring 2.Sohna Palwal Road .Haryana. Low latency (except in high traffic periods).UNIT 1 • • • • • • • • • Typically connects computer in a single building or campus. Gurgaon . Ethernet. World Institute Of Technology 8km milestone . Developed in 1970s.in .net.Sohna . Medium: optical fibers.in Website : www. NH-71 B . twisted pair. High speed networks (0. Introduction to MAN A MAN (metropolitan area network) is a larger network that usually spans several buildings in the same city or town.2 to 100 Mb/sec). and may be limited to an enterprise (a corporation or an organization) or accessible to the public.net. Typical latencies: < 1 msec.in .wit. Medium: optical fibers.in Website : www.Sohna . Introduction to WAN A WAN (wide area network). E-mail : [email protected] Palwal Road . A typical standard is DQDB (Distributed Queue Dual Bus). The technology is high speed and relatively expensive. A WAN connects several LANs.net. is not restricted to a geographical location. in comparison to a MAN. Gurgaon . cables. Data rates adequate for distributed computing applications. Message routing is fast. 3. World Institute Of Technology 8km milestone . NH-71 B . The Internet is an example of a worldwide public WAN.UNIT 1 • • • • • • • Generally covers towns and cities (50 kms) Developed in 1980s.Haryana. although it might be confined within the bounds of a state or country. net. Problems with delays if using satellites. continents).Sohna .UNIT 1 • • • • • • • • • • Developed in 1960s. countries. Typical latencies: 100ms . Gurgaon . Routers forwards packets from one to another following a route from the sender to the receiver.Haryana. E-mail : info@wit. New standards are changing the landscape.in .wit.in Website : www. Medium: communication circuits connected by routers. NH-71 B .500ms.Sohna Palwal Road . Generally covers large distances (states.net.2000 Kbits/s. Not (yet) suitable for distributed computing. Store-and-Forward Hosts are typically connected (or close to) the routers. World Institute Of Technology 8km milestone . Typical speed: 20 . OSI Reference model 2.net. OSI Reference Model World Institute Of Technology 8km milestone .net.wit. Gurgaon . E-mail : info@wit. NH-71 B .UNIT 1 Lecture: 17 OSI Reference Model Contents 1.Sohna Palwal Road .Haryana.in Website : www. 1.Sohna .in . Description of the OSI Layers Layer 1—Physical layer (P) Layer 2—Data Link layer (D) Layer 3—Network layer (N) Layer 4—Transport layer (T) Layer 5—Session layer (S) Layer 6—Presentation layer (P) Layer 7—Application layer (A) Tip to Remember People Do Need To Send Packets Away. as well as personal area networks such as Bluetooth and IEEE 802. repeaters. Most network protocols used in the market today are based on TCP/IP stacks. ITU-T G. FDDI.UNIT 1 The Open Systems Interconnection model (OSI model) is a product of the Open Systems Interconnection effort at the International Organization for Standardization. Various Physical Layer Ethernet standards are also in this layer. at least two) with a shared medium. while it calls the next lower layer to send and receive packets that make up the contents of the path. 2. Modulation. such as token ring. NH-71 B . For example. Ethernet incorporates both this layer and the Data Link Layer.in . A layer is a collection of conceptually similar functions that provide services to the layer above it and receives services from the layer below it. This includes the layout of pins. On each layer. it defines the relationship between a device and a transmission medium. The same applies to other local-area networks. voltages. To understand the function of the Physical Layer.Haryana.e.15. Gurgaon . contrast it with the functions of the Data Link Layer. For example.hn and IEEE 802. host bus adapters (HBA used in storage area networks) and more. Participation in the process whereby the communication resources are effectively shared among multiple users. It is a way of subdividing a communications system into smaller parts called layers. Conceptually two instances at one layer are connected by a horizontal protocol connection on that layer. whereas the Data Link Layer is concerned more with the interactions of multiple devices (i. In particular.net. These are signals operating over the physical cabling (such as copper and optical fiber) or over a radio link. • Parallel SCSI buses operate in this layer.wit. E-mail : [email protected]. a layer that provides error-free communications across a network provides the path needed by applications above it. hubs..in Website : www.Sohna . Think of the Physical Layer as concerned primarily with the interaction of a single device with a medium. Description of the OSI Layers Layer 1—Physical layer (P) The Physical Layer defines the electrical and physical specifications for devices.net.11. cable specifications.Sohna Palwal Road . World Institute Of Technology 8km milestone . contention resolution and flow control. The major functions and services performed by the Physical Layer are: • • • Establishment and termination of a connection to a communications medium. Standards such as RS-232 do use physical wires to control access to the medium. an instance provides services to the instances at the layer above and requests service from the layer below. network adapters. such as a copper or optical cable. Layer 2—Data Link layer (D) The Data Link Layer provides the functional and procedural means to transfer data between network entities and to detect and possibly correct errors that may occur in the Physical Layer. although it must be remembered that the logical SCSI protocol is a Transport Layer protocol that runs over this bus. or conversion between the representation of digital data in user equipment and the corresponding signals transmitted over a communications channel. in . For example. the IEEE 802. The Network Layer performs network routing functions. and on other local area networks.Sohna . Subnetwork Independent Convergence . In this scheme.Sohna Palwal Road . and report delivery errors. such as X. In modern practice. Careful analysis of the Network Layer indicated that the Network Layer could have at least three sublayers: 1.hn standard. on local area networks. characteristic of wide area media in the telephone system.when it is necessary to bring the level of a transit network up to the level of networks on either side. and.UNIT 1 Originally. which included broadcast-capable multiaccess media. while maintaining the quality of service requested by the Transport Layer (in contrast to the data link layer which connects hosts within the same network). but is still used in niches where X. as some of these bits are purely intended for Physical Layer functions.net. is present in data link protocols such as Point-to-Point Protocol (PPP). The ITU-T G.25 offers performance advantages. includes a complete Data Link Layer which provides both error correction and flow control by means of a selective repeat Sliding Window Protocol. It manages the connectionless transfer of data one hop at a time.wit. its flow control and acknowledgment mechanisms are rarely used. Both WAN and LAN service arrange bits. Subnetwork Access . which provides high-speed local area networking over existing wires (power lines. from the Physical Layer. router to router. IPv4 World Institute Of Technology 8km milestone .that considers protocols that deal with the interface to networks.Haryana. Layer 3—Network layer (N) The Network Layer provides the functional and procedural means of transferring variable length data sequences from a source host on one network to a destination host on a different network.25. IEEE work assumed sublayering and management functions not required for WAN use. 3. and from egress router to destination end system. this layer was intended for point-to-point and point-to-multipoint media. or IPv7 ISO 8473.net. not flow control using sliding window.which handles transfer across multiple networks. NH-71 B . phone lines and coaxial cables). Subnetwork Dependent Convergence . into logical sequences called frames. Sliding window flow control and acknowledgment is used at the Transport Layer by protocols such as TCP. was developed independently of the ISO work in IEEE Project 802. only error detection. 2. The addressing scheme is not hierarchical. E-mail : [email protected] LLC layer is not used for most protocols on the Ethernet. Not all Physical Layer bits necessarily go into frames. and might also perform fragmentation and reassembly. The best example of this latter case is CLNP.in Website : www. This is a logical addressing scheme – values are chosen by the network engineer. It is not responsible for reliable delivery to a next hop. Routers operate at this layer—sending data throughout the extended network and making the Internet possible. every fifth bit of the FDDI bit stream is not used by the Layer. Gurgaon . Local area network architecture. but only for the detection of erroneous packets so they may be discarded. from end system to ingress router. although TCP contains functions.net. belong to the Network Layer. Detailed characteristics of TP0-4 classes are shown in the following table: TP0 TP1 TP2 TP3 TP4 Feature Name Connection oriented network Yes Yes Yes Yes Yes Connectionless network No No No No Yes Concatenation and separation No Yes Yes Yes Yes Segmentation and reassembly Yes Yes Yes Yes Yes Error Recovery No Yes Yes Yes Yes Reinitiate connection (if an excessive number of PDUs are No Yes No Yes No unacknowledged) Multiplexing and demultiplexing over a single virtual circuit No No Yes Yes Yes Explicit flow control No No Yes Yes Yes Retransmission on timeout No No No No Yes Reliable Transport Service No Yes No Yes Yes World Institute Of Technology 8km milestone . segmentation/desegmentation. The Transport layer also provides the acknowledgement of the successful data transmission and sends the next data if no errors occurred. The Transport Layer controls the reliability of a given link through flow control. Although not developed under the OSI Reference Model and not strictly conforming to the OSI definition of the Transport Layer. and error control.Sohna Palwal Road . It is the function of the payload that makes these belong to the Network Layer. multicast group management. and Network Layer address assignment. not the protocol that carries them.UNIT 1 and IPv6 would have to be classed with X. similar to the Internet). ISO 7498/4. all OSI TP connection-mode protocol classes provide expedited data and preservation of record boundaries. Class 4 is closest to TCP. These include routing protocols. such as the graceful close.Sohna . NH-71 B .in . designed for less reliable networks. a function defined in the Management Annex. E-mail : info@wit. and was designed for use on network layers that provide error-free connections.25 as subnet access protocols because they carry interface addresses rather than node addresses. Of the actual OSI protocols. A number of layer management protocols. typical examples of Layer 4 are the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). Some protocols are state and connection oriented.wit. providing reliable data transfer services to the upper layers. both of which TCP is incapable. Also. This means that the Transport Layer can keep track of the segments and retransmit those that fail. Class 0 contains no error recovery. which OSI assigns to the Session Layer. Gurgaon .Haryana. there are five classes of connection-mode transport protocols ranging from class 0 (which is also known as TP0 and provides the least features) to class 4 (TP4. Network Layer information and error.net.in Website : www. Layer 4—Transport layer (T) The Transport Layer provides transparent transfer of data between end users. net. While Generic Routing Encapsulation (GRE) might seem to be a Network Layer protocol. or serialization of objects and other data structures from and to XML. such as cryptographic presentation services that can be read by the addressee only. and also for session checkpointing and recovery.in Website : www.g. and restart procedures. and establishes checkpointing. which is not usually used in the Internet Protocol Suite. adjournment. which deals with the dispatch and classification of mail and parcels sent. or end-to-end encryption with IPsec. Layer 5—Session layer (S) The Session Layer controls the dialogues (connections) between computers. The OSI model made this layer responsible for graceful close of sessions. however. If a mapping is available.net. Such application programs fall outside the scope of the OSI model. The presentation layer transforms data into the form that the application accepts.wit.Sohna . The Session Layer is commonly implemented explicitly in application environments that use remote procedure calls. and synchronizing communication. Gurgaon . such as carrying non-IP protocols such as IBM's SNA or Novell's IPX over an IP network. This layer provides independence from data representation (e. encryption) by translating between application and network formats.Sohna Palwal Road . or simplex operation.Haryana. GRE becomes closer to a transport protocol that uses IP headers but contains complete frames or packets to deliver to an endpoint. presentation service data units are encapsulated into session protocol data units.1). with capabilities such as converting an EBCDIC-coded text file to an ASCIIcoded file. that a post office manages the outer envelope of mail. the application layer determines the identity and availability of communication partners for an application with data to transmit. When identifying communication partners. This layer formats and encrypts data to be sent across a network. It establishes. manages and terminates the connections between the local and remote application. Do remember. E-mail : info@wit. Higher layers may have the equivalent of double envelopes. L2TP carries PPP frames inside transport packet. It provides for full-duplex. NH-71 B . World Institute Of Technology 8km milestone . It is sometimes called the syntax layer. and passed down the stack. tunneling protocols operate at the Transport Layer.in . termination. Layer 6—Presentation layer (P) The Presentation Layer establishes context between Application Layer entities. if the encapsulation of the payload takes place only at endpoint. Layer 7—Application layer (A) The Application Layer is the OSI layer closest to the end user. which is a property of the Transmission Control Protocol. Application layer functions typically include identifying communication partners. determining resource availability. which means that both the OSI application layer and the user interact directly with the software application. This layer interacts with software applications that implement a communicating component. in which the higher-layer entities may use different syntax and semantics if the presentation service provides a mapping between them.. The original presentation structure used the basic encoding rules of Abstract Syntax Notation One (ASN. half-duplex.UNIT 1 Perhaps an easy way to visualize the Transport Layer is to compare it with a Post Office. Roughly speaking. net. File Transfer Protocol (FTP).Haryana. NH-71 B .Sohna . all communication between applications requires cooperation that is managed by the application layer.in Website : www. Simple Mail Transfer Protocol (SMTP) Simple Network Management Protocol (SNMP) World Institute Of Technology 8km milestone .UNIT 1 When determining resource availability.wit.Sohna Palwal Road . Some examples of application layer implementations include: • On OSI stack: • FTAM File Transfer and Access Management Protocol X.net.in . Gurgaon . In synchronizing communication.400 Mail Common management information protocol (CMIP) On TCP/IP stack: o o o o o o o Hypertext Transfer Protocol (HTTP). the application layer must decide whether sufficient network or the requested communication exist. E-mail : info@wit. a network of networks that spans the globe. Many options are offered with monthly rates.Haryana. password and access phone number. access time may vary.UNIT 1 Lecture: 18 Introduction to Internet. the Internet is made up of thousands of smaller networks. but it is easily in the thousands and millions respectively. Introduction to Internet Services of Internet Uses of Internet Introduction to Protocol Types of Protocol Introduction to Backbone Network 1. Technically. ISPs also serve large companies. Rather. And other computers. E-mail : info@wit. ISPs are also called IAPs (Internet Access Providers ) World Institute Of Technology 8km milestone . The Internet thrives and develops as its many users find new ways to create.wit. A company that provides access to the Internet. ISPs themselves are connected to one another through Network Access Points (NAPs).in Website : www. 4.net. Equipped with a modem. have direct access to all the facilities on the Internet such as the universities. you must go through service suppliers. Some computers. username. It's impossible to give an exact count of the number of networks or users that comprise the Internet. Depending on the option chosen. In order to be connected to Internet. 6. Introduction to Internet The Internet links are computer networks all over the world so that users can share resources and communicate with each other. there are no central archives. display and retrieve the information that constitutes the Internet. have indirect links through a commercial service provider.in . sometimes referred to as the Internet Protocol Suite. Gurgaon . NH-71 B . the service provider gives you a software package. For a monthly fee. 5. you can then log on to the Internet and browse the World Wide Web and USENET. The Internet is also what we call a distributed system.Sohna . 2.Sohna Palwal Road . The Internet is what we call a metanetwork. providing a direct connection from the company's networks to the Internet. Protocols & Backbone Network Contents 1. In addition to serving individuals. and send and receive e-mail. 3. who offers some or all of the Internet facilities.net. These standards. eg privately-owned ones. The Internet employs a set of standardized protocols which allow for the sharing of resources among different kinds of computers that communicate with each other on the network. that is. no one runs the Internet. are the rules that developers adhere to when creating new functions for the Internet. or on the same protocols used on public networks. such as the Internet.net. FTP is built on a client-server World Institute Of Technology 8km milestone . Intranet systems may be based on proprietary protocols supported by a particular systems vendor. receiving and saving messages over electronic communication systems.UNIT 1 2. E-mail : [email protected]. to network systems based on other protocols and to various mainframe. quarantine or delete some or most of these. Gurgaon . Services of Internet Email Electronic mail. sending. or "spam". email. depending on the situation.in Website : www. sometimes containing a signature block at the end The header is separated from the body by a blank line. and other information about the e-mail Body — The message itself as unstructured text.Sohna Palwal Road . Internet e-mail messages consist of two major sections: • • Header — Structured into fields such as summary.Sohna . minicomputer. sender. or originally eMail. is a store-and-forward method of writing.Haryana.in . but filter programs exist which can automatically block. NH-71 B . E-mail is often used to deliver bulk unsolicited messages. FTP File Transfer Protocol (FTP) is a standard network protocol used to copy a file from one host to another over a TCP-based network. often abbreviated to e-mail. or intranet systems allowing users within one organization to send messages to each other in support of workgroup collaboration. receiver.wit. The term "e-mail" (as a noun or verb) applies to the Internet e-mail system based on the Simple Mail Transfer Protocol. UNIT 1 architecture and utilizes separate control and data connections between the client and server.[1] FTP users may authenticate themselves using a clear-text sign-in protocol but can connect anonymously if the server is configured to allow it. The first FTP client applications were interactive command-line tools, implementing standard commands and syntax. Graphical user interface clients have since been developed for many of the popular desktop operating systems in use today. TELNET Telnet is a network protocol used on the Internet or local area networks to provide a bidirectional interactive text-oriented communications facility using a virtual terminal connection. User data is interspersed in-band with Telnet control information in an 8-bit byte oriented data connection over the Transmission Control Protocol (TCP). Telnet was developed in 1969 beginning with RFC 15, extended in RFC 854, and standardized as Internet Engineering Task Force (IETF) Internet Standard STD 8, one of the first Internet standards. Historically, Telnet provided access to a command-line interface (usually, of an operating system) on a remote host. Most network equipment and operating systems with a TCP/IP stack support a Telnet service for remote configuration (including systems based on Windows NT). Because of security issues with Telnet, its use for this purpose has waned in favor of SSH. The term telnet may also refer to the software that implements the client part of the protocol. Telnet client applications are available for virtually all computer platforms. Telnet is also used as a verb. To telnet means to establish a connection with the Telnet protocol, either with command line client or with a programmatic interface. For example, a common directive might be: "To change your password, telnet to the server, login and run the passwd command." Most often, a user will be telnetting to a Unix-like server system or a network device (such as a router) and obtain a login prompt to a command line text interface or a character-based full-screen manager. 3. Uses of Internet Nowadays internet has become so common that people who are unaware about internet are referred as clumsy. This is due to the speedy development of technology and globalization. Societies are becoming more and more unified. You can easily contact to the person sitting in a different country. You can share your knowledge, thoughts by making the use of an internet. Study results have also traced the popularity of internet usage. Last year's study has wind up that email is the topmost task which is conducted online, followed by general surfing, News reading, shopping etc. Internet shopping has also become popular amongst users especially in developed nations; this is because 'shop on internet' is more efficient than physically going into the stores. The internet endow with the surroundings where shopper's demands are fulfilled. Shopping on the internet also saves time and we can select a better product without having to travel a long distance. Using World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in UNIT 1 the internet, shopper can scrutinize the product's prices from various stores by sitting on one place. Also they can now shop online for the goods which normally get sold in a foreign nation. Rather than having to travel to the country to take the delivery of the goods, they can place the order online and get it efficiently delivered. Internet also gives us the prospective to communicate effectively and efficiently. For example, sending an email costs lower than posting a letter in the mail, especially for people who have to communicate internationally. Besides this, an email can be sent within a minute after it is written. For sending a mail we don't need to complete the official procedure such as Post Office and a mail box etc. The recipient of the email can view it at any time and from any place, as it is a virtual means of communication, as opposed to having a mail box where the letters get delivered. Internet use is not only limited to shopping and communication with people, but it also provides the environment for news distribution and endorse the people to be updated with the latest news. We can access the data easily wherever it may be across the world. Internet is also a very good form of communication for people who want to express their own view points and feelings. For youngsters, internet is not only a place of knowledge but it also has an entertainment aspect such as online games, downloading movies, music etc. But this is not the only reason the internet appeals to the younger generation. They also agreed that the internet provides ease to research and university students. This is because a large number of articles on the same topic can be found on the internet by just one search. 4. Introduction to Protocol A Protocol is the special set of rules that end points in a telecommunication connection use when they communicate. Protocols exist at several levels in a telecommunication connection. For example, there are protocols for the data interchange at the hardware device level and protocols for data interchange at the application program level. In the standard model known as Open Systems Interconnection (OSI), there are one or more protocols at each layer in the telecommunication exchange that both ends of the exchange must recognize and observe. Protocols are often described in an industry or international standard. On the Internet, there are the TCP/IP protocols, consisting of: • • • Transmission Control Protocol (TCP), which uses a set of rules to exchange messages with other Internet points at the information packet level Internet Protocol (IP), which uses a set of rules to send and receive messages at the Internet address level Additional protocols that include the Hypertext Transfer Protocol (HTTP) and File Transfer Protocol (FTP), each with defined sets of rules to use with corresponding programs elsewhere on the Internet There are many other Internet protocols, such as the Border Gateway Protocol (BGP) and the Dynamic Host Configuration Protocol (DHCP). World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in UNIT 1 5. Types of Protocol • Transmission Control Protocol TCP (Transmission Control Protocol) is a set of rules (protocol) used along with the Internet Protocol (IP) to send data in the form of message units between computers over the Internet. While IP takes care of handling the actual delivery of the data, TCP takes care of keeping track of the individual units of data (called packets) that a message is divided into for efficient routing through the Internet. For example, when an HTML file is sent to you from a Web server, the Transmission Control Protocol (TCP) program layer in that server divides the file into one or more packets, numbers the packets, and then forwards them individually to the IP program layer. Although each packet has the same destination IP address, it may get routed differently through the network. At the other end (the client program in your computer), TCP reassembles the individual packets and waits until they have arrived to forward them to you as a single file. TCP is known as a connection-oriented protocol, which means that a connection is established and maintained until such time as the message or messages to be exchanged by the application programs at each end have been exchanged. TCP is responsible for ensuring that a message is divided into the packets that IP manages and for reassembling the packets back into the complete message at the other end. In the Open Systems Interconnection (OSI) communication model, TCP is in layer 4, the Transport Layer. • Internet Protocol Internet protocol is the set of techniques used by many hosts for transmitting data over the Internet. The current version of the Internet protocol is IPv4, which provides a 32-bit address system. Internet protocol is a "best effort" system, meaning that no packet of information sent over it is assured to reach its destination in the same condition it was sent. Often other protocols are used in tandem with the Internet protocol for data that for one reason or another must have extremely high fidelity. Every device connected to a network, be it a local area network (LAN) or the Internet, is given an Internet protocol number. This address is used to identify the device uniquely among all other devices connected to the extended network. The current version of the Internet protocol (IPv4) allows for in excess of four billion unique addresses. This number is reduced drastically, however, by the practice of webmasters taking addresses in large blocks, the bulk of which remain unused. There is a rather substantial movement to adopt a new version of the Internet protocol (IPv6), which would have two to the one-hundred twenty-eighth power of unique addresses. This number can be represented roughly by a three with thirty-nine zeroes after it. World Institute Of Technology 8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana. E-mail : [email protected] Website : www.wit.net.in a program that is designed to wait for HTTP requests and handle them when they arrive. It maintains a table of IP networks or 'prefixes' which designate network reachability among autonomous systems (AS). Your Web browser is an HTTP client. Since January 2006. BGP does not use traditional Interior Gateway Protocol (IGP) metrics. network policies and/or rulesets. NH-71 B . the browser builds an HTTP request and sends it to the Internet Protocol address (IP address) indicated by the URL. All previous versions are now obsolete. It is described as a path vector protocol.Haryana. an HTTP daemon. graphic images. (A Web page often consists of more than one file.net. but makes routing decisions based on path. and other multimedia files) on the World Wide Web. each needing its own address in the Internet protocol. HTTP is an application protocol that runs on top of the TCP/IP suite of protocols (the foundation protocols for the Internet). Gurgaon . As soon as a Web user opens their Web browser. The HTTP daemon in the destination server machine receives the request and sends back the requested file or files associated with the request. E-mail : info@wit. Since 1994.1. version 4 is codified in World Institute Of Technology 8km milestone .Sohna Palwal Road .in . The major enhancement in version 4 was support of Classless Inter-Domain Routing and use of route aggregation to decrease the size of routing tables. of devices communicating via wireless networks.net. it is more appropriately termed a reachability protocol rather than routing protocol. For this reason. but addresses were used only by computers at the time. • Border Gateway Protocol The Border Gateway Protocol (BGP) is the protocol backing the core routing decisions on the Internet.wit. This allowed the Internet to become a truly decentralized system. BGP was created to replace the Exterior Gateway Protocol (EGP) routing protocol to allow fully decentralized routing in order to allow the removal of the NSFNet Internet backbone network. in addition to the Web page files it can serve. version four of the BGP has been in use on the Internet. Any Web server machine contains. it is conceivable that for every human being on earth there will be hundreds.Sohna . In the future.in Website : www. sending requests to server machines. if not thousands. In the past it seemed that four billion addresses would be more than enough. HTTP concepts include (as the Hypertext part of the name implies) the idea that files can contain references to other files whose selection will elicit additional transfer requests. the user is indirectly making use of HTTP.) The latest version of HTTP is HTTP 1. When the browser user enters file requests by either "opening" a Web file (typing in a Uniform Resource Locator or URL) or clicking on a hypertext link. video.UNIT 1 The reason such a virtually unlimited set of Internet protocol addresses is desirable is because of the onset of small wireless devices. • File Transfer Protocol Already discussed ( in services of Internet) • Hypertext Transfer Protocol HTTP (Hypertext Transfer Protocol) is the set of rules for transferring files (text. sound. e) The client sends a REQUEST (or DHCPREQUEST) packet. for example: a) A user turns on a computer with a DHCP client. The server then temporarily reserves that address for the client and sends back to the client an OFFER (or DHCPOFFER) packet. Using DHCP to dynamically assign IP addresses minimizes these conflicts.wit. confirming that the client has a been given a lease on the address for a server-specified period of time. WINS servers. it is one of the most important protocols of the Internet. Since most Internet service providers must use BGP to establish routing between one another (especially if they are multihomed). c) The router directs the DISCOVER packet to the correct DHCP server. letting the server know that it intends to use the address.net. with that address information. 6. RFC 4271 version corrected a number of errors. Very large private IP networks use BGP internally. the server determines an appropriate address (if any) to give to the client.UNIT 1 RFC 4271. d) The server receives the DISCOVER packet. An example would be the joining of a number of large Open Shortest Path First (OSPF) networks where OSPF by itself would not scale to size. One problem with static assignment. This creates a conflict that results in loss of service. NTP servers. a scope) configured for a given network. NH-71 B .net. Another reason to use BGP is multihoming a network for better redundancy either to multiple access points of a single ISP (RFC 1998) or to multiple ISPs. Compare this with Signaling System 7 (SS7). • Dynamic Host Configuration Protocol Dynamic Host Configuration Protocol (DHCP) is a network protocol that enables a server to automatically assign an IP address to a computer from a defined range of numbers (i. looking for a DHCP server to answer. f) The server sends an ACK (or DHCPACK) packet. which can result from user error or inattention to detail. which went through more than 20 drafts based on the earlier RFC 1771 version 4. Gurgaon . which is the inter-provider core call setup protocol on the PSTN. providing a path for the exchange of information World Institute Of Technology 8km milestone . When a computer uses a static IP address. The server also configures the client's DNS servers. Introduction to Backbone Network A backbone network or network backbone is a part of computer network infrastructure that interconnects various pieces of network.Sohna Palwal Road .e. b) The client computer sends a broadcast request (called a DISCOVER or DHCPDISCOVER). Most Internet users do not use BGP directly. it means that the computer is manually configured to use a specific IP address. clarified ambiguities and brought the RFC much closer to industry practices. occurs when two computers are configured with the same IP address. and sometimes other services as well. DHCP assigns an IP address when a system is started.in Website : www..Haryana.Sohna .in . Based on availability and usage policies set on the server. E-mail : info@wit. Haryana. Normally.UNIT 1 between different LANs or subnetworks. E-mail : info@wit. in different buildings in a campus environment. NH-71 B .Sohna Palwal Road . There are two very commonly used designs of backbone networks: • • Bus Backbone Star Backbone World Institute Of Technology 8km milestone . for example.in Website : www.net. the backbone's capacity is greater than the networks connected to it. A large corporation that has many locations may have a backbone network that ties all of the locations together. if a server cluster needs to be accessed by different departments of a company that are located at different geographical locations.wit.Sohna . wireless) that bring these departments together is often mentioned as network backbone.[1][2] A backbone can tie together diverse networks in the same building. The pieces of the network connections (for example: ethernet.net. Network congestion is often taken into consideration while designing backbones. Gurgaon .in . or over wide areas. E-mail : [email protected] 1 Lecture: 19 TCP/IP Reference Model Contents 7. Internet Protocol Suite Application Layer BGP · DHCP · DNS · FTP · HTTP · IMAP · IRC · LDAP · MGCP · NNTP · NTP · POP · RIP · RPC · RTP · SIP · SMTP · SNMP · SSH · Telnet · TLS/SSL · XMPP · World Institute Of Technology 8km milestone .Sohna . addressed.Haryana. an agency of the United States Department of Defense. or Internet Protocol Suite.wit. transmitted. routed and received at the destination. Description of the TCP/IP Layers Layer 1—Physical layer (P) Layer 2—Data Link layer (D) Layer 3—Network layer (N) Layer 4—Transport layer (T) Layer 5—Application layer (A) 9.Sohna Palwal Road .in . Difference between TCP/IP & OSI model 1. The TCP/IP model.net. which was the world's first wide area network and a predecessor of the Internet.net. TCP/IP Reference model 8. NH-71 B . It evolved from ARPANET. Gurgaon . Protocols exist for a variety of different types of communication services between computers. TCP/IP Reference model The TCP/IP model is a description framework for computer network protocols created in the 1970s by DARPA.in Website : www. The TCP/IP Model is sometimes called the Internet Model or the DoD Model. TCP/IP provides end-to-end connectivity specifying how data should be formatted. describes a set of general design guidelines and implementations of specific networking protocols to enable computers to communicate over a network. Haryana. FDDI) · (more) Physical Layer TCP/IP.net. This layer architecture is often compared with the seven-layer OSI Reference Model. Ethernet and collision detection. while those near the bottom are logically closer to the physical transmission of the data.wit. Gurgaon . World Institute Of Technology 8km milestone . Description of the TCP/IP Layers The layers near the top are logically closer to the user application. NH-71 B . while the lower layers avoid having to know the details of each and every application and its protocol. sometimes referred to as the Internet model. E-mail : info@wit. Viewing layers as providing or consuming a service is a method of abstraction to isolate upper layer protocols from the nittygritty detail of transmitting bits over. incorrectly.in . because it is descriptive while the OSI Reference Model was intended to be prescriptive. 2.UNIT 1 (more) Transport Layer TCP · UDP · DCCP · SCTP · RSVP · ECN · (more) Internet Layer IP (IPv4.Sohna Palwal Road . IPv6) · ICMP · ICMPv6 · IGMP · IPsec · (more) Link Layer ARP/InARP · NDP · OSPF · Tunnels (L2TP) · PPP · Media Access Control (Ethernet.in Website : www. using terms such as Internet reference model.Sohna . for example. ISDN. hence being a reference model. has four abstraction layers as defined in RFC 1122. however.net. DSL. E-mail : info@wit. The link is treated like a black box here. there was no intention." Criticisms of this model. on the part of the designers of these protocols. as in the comment by David D. Ethernet) an address mapping protocol is needed.net. the Internal Organization of the Network Layer (IONL). Gurgaon . Again. but the IETF does not use a formal model and does not consider this a limitation. NH-71 B . For example. 3. to comply with OSI architecture. Such protocols can be considered to be below IP but above the existing link system.UNIT 1 This abstraction also allows upper layers to provide services that the lower layers cannot. While the IETF does not use the terminology. TCP provides both data integrity and delivery guarantee (by retransmitting until the receiver acknowledges the reception of the packet). Again.Haryana.in Website : www. often do not consider ISO's later extensions to that model. The IETF explicitly does not intend to discuss transmission systems. For multi-access links with their own addressing systems (e. 4. We believe in: rough consensus and running code.Sohna . this functionality exists as layer management extensions to the OSI model.g. or choose not to. This means that all transport layer implementations must choose whether or not to provide reliability and to what degree. presidents and voting. which have been made with respect to the OSI Reference Model. the original OSI Reference Model was extended to include connectionless services (OSIRM CL). "We reject: kings.net. This model lacks the formalism of the OSI reference model and associated documents. This is fine for discussing IP (since the whole point of IP is it will run over virtually anything). 2. Encapsulation of application data descending through the TCP/IP layers 1. this is a sub network dependent convergence facility according to an extension to the OSI model. Again. World Institute Of Technology 8km milestone . ICMP & IGMP operate on top of IP but do not transport data like UDP or TCP. UDP provides data integrity (via a checksum) but does not guarantee delivery. which is a less academic but practical alternative to the OSI Reference Model.in .Sohna Palwal Road . in its Management Framework (OSIRM MF). IP is not designed to be reliable and is a best effort delivery protocol. Clark.wit. provide. The SSL/TLS library operates above the transport layer (uses TCP) but below application protocols. whereas the Data Link Layer is concerned more with the interactions of multiple devices (i.Haryana. as well as personal area networks such as Bluetooth and IEEE 802. Layer 2—Data Link layer (D) The Link Layer is the networking scope of the local network connection to which a host is attached.net.in . This includes the layout of pins.11. Think of the Physical Layer as concerned primarily with the interaction of a single device with a medium. Layer 1—Physical layer (P) The Physical Layer defines the electrical and physical specifications for devices. Ethernet incorporates both this layer and the Data Link Layer. then actually transmit the frame over a physical medium. voltages. hubs. however all other World Institute Of Technology 8km milestone . although it must be remembered that the logical SCSI protocol is a Transport Layer protocol that runs over this bus. or conversion between the representation of digital data in user equipment and the corresponding signals transmitted over a communications channel. such as Media Access Control (MAC)..net.4. NH-71 B . The Link Layer is used to move packets between the Internet Layer interfaces of two different hosts on the same link. at least two) with a shared medium.Sohna Palwal Road . host bus adapters (HBA used in storage area networks) and more. as well as on firmware or specialized chipsets. For example. cable specifications.15. contrast it with the functions of the Data Link Layer. In particular. This is the lowest component layer of the Internet protocols. As a result TCP/IP has been implemented on top of virtually any hardware networking technology in existence. The major functions and services performed by the Physical Layer are: • • • Establishment and termination of a connection to a communications medium. ITU-T G. The TCP/IP model includes specifications of translating the network addressing methods used in the Internet Protocol to data link addressing. Modulation. network adapters. Standards such as RS-232 do use physical wires to control access to the medium. such as a copper or optical cable. such as token ring.hn and IEEE 802. This regime is called the link in Internet literature. Gurgaon . Various Physical Layer Ethernet standards are also in this layer. • Parallel SCSI buses operate in this layer.wit. These will perform data link functions such as adding a packet header to prepare it for transmission. FDDI. as TCP/IP is designed to be hardware independent. E-mail : info@wit. repeaters.e. it defines the relationship between a device and a transmission medium. contention resolution and flow control. Participation in the process whereby the communication resources are effectively shared among multiple users. The same applies to other local-area networks. These are signals operating over the physical cabling (such as copper and optical fiber) or over a radio link.Sohna .in Website : www.UNIT 1 The following is a description of each layer in the TCP/IP networking model starting from the lowest level. To understand the function of the Physical Layer. The processes of transmitting and receiving packets on a given link can be controlled both in the software device driver for the network card. Layer 3—Network layer (N) The Internet Layer solves the problem of sending packets across one or more networks. congestion control. segmentation. along with error control. This illustrates the differences in the architecture of the TCP/IP stack of the Internet and the OSI model. the TCP/IP model does not dictate a strict hierarchical encapsulation sequence. The Transport Layer can be thought of as a transport mechanism.Sohna Palwal Road . implemented in Transmission Control Protocol (TCP). e.in Website : www. Gurgaon . flow control. In the Internet Protocol Suite.g. Internetworking requires sending data from the source network to the destination network. may be established with a transport protocol or even an application scope protocol that serves as a tunnel in the Link Layer of the protocol stack. Thus. End to end message transmission or connecting applications at the transport layer can be categorized as either connection-oriented. or connectionless. implemented in User Datagram Protocol (UDP).UNIT 1 aspects below that level are implicitly assumed to exist in the Link Layer.wit.net. a vehicle with the responsibility to make sure that its contents (passengers/goods) reach their destination safely and soundly. NH-71 B . In this scenario. respectively. Some of the protocols carried by IP. Such a connection. the Link Layer data may be considered application data which traverses another instantiation of the IP stack for transmission or reception over another IP connection. IP can carry data for a number of different upper layer protocols. These protocols are each identified by a unique protocol number: for example. but are not explicitly defined. World Institute Of Technology 8km milestone . or virtual link. unless another protocol layer is responsible for safe delivery. and application addressing (port numbers). The Link Layer is also the layer where packets may be selected to be sent over a virtual private network or other networking tunnel. Layer 4—Transport layer (T) The Transport Layer's responsibilities include end-to-end message transfer capabilities independent of the underlying network. the Internet Protocol performs two basic functions: • • Host addressing and identification: This is accomplished with a hierarchical addressing system (see IP address).net. This process is called routing.in ..Haryana.Sohna . E-mail : info@wit. Packet routing: This is the basic task of getting packets of data (datagrams) from source to destination by sending them to the next network node (router) closer to the final destination. Internet Control Message Protocol (ICMP) and Internet Group Management Protocol (IGMP) are protocols 1 and 2. such as ICMP (used to transmit diagnostic information about IP transmission) and IGMP (used to manage IP Multicast data) are layered on top of IP but perform internetworking functions. the File Transfer Protocol expects a reliable connection. Protocols above transport. For example. such as VoIP. can tolerate some loss of packets. Data coded according to application layer World Institute Of Technology 8km milestone . in which a connection end can be represented by multiple IP addresses (representing multiple physical interfaces).in Website : www. It also provides multi-homing support. the Transport Layer is the first layer of the TCP/IP stack to offer reliability.Sohna Palwal Road . "unreliable" protocol.in . not transport. also can provide reliability. but the Network File System (NFS) assumes that the subordinate Remote Procedure Call protocol. It is Message-stream-oriented — not byte-stream-oriented like TCP — and provides multiple streams multiplexed over a single connection. TCP and UDP are used to carry an assortment of higher-level applications. but not the reordering or delay that could be caused by retransmission. Reliability is addressed through error detection using a weak checksum algorithm. E-mail : info@wit. Gurgaon . Layer 5—Application layer (A) The Application Layer refers to the higher-level protocols used by most applications for network communication. Like IP.net. User Datagram Protocol is a connectionless datagram protocol. will guarantee reliable transfer. Voice over IP etc) where on-time arrival is more important than reliability. Since IP provides only a best effort delivery.e. It was developed initially for telephony applications (to transport SS7 over IP).UNIT 1 The Transport Layer provides this service of connecting applications through the use of service ports. but can also be used for other applications. Examples of application layer protocols include the File Transfer Protocol (FTP) and the Simple Mail Transfer Protocol (SMTP). the connection is not interrupted. where the overhead of setting up a reliable connection is disproportionately large.net. such that if one fails. connection-oriented transport mechanism. IP can run over a reliable data link protocol such as the HighLevel Data Link Control (HDLC). video. The appropriate transport protocol is chosen based on the higher-layer protocol application. Other applications. such as RPC. Real-time Transport Protocol (RTP) is a datagram protocol that is designed for real-time data such as streaming audio and video. NH-71 B . UDP is typically used for applications such as streaming media (audio. For example. correctness) duplicate data is discarded lost/discarded packets are resent includes traffic congestion control The newer Stream Control Transmission Protocol (SCTP) is also a reliable.Haryana. By convention certain well known ports are associated with specific applications.Sohna . it is a best effort. The applications at any given network address are distinguished by their TCP or UDP port. the Transmission Control Protocol (TCP) is a connection-oriented protocol that addresses numerous reliability issues to provide a reliable byte stream: • • • • • data arrives in-order data has minimal error (i. or for simple query/response applications like DNS lookups.wit. NH-71 B . rather they just provide a conduit for it. tend to use ephemeral ports. etc. on the other hand. Routers and switches do not typically "look inside" the encapsulated traffic to see what kind of application protocol it represents. although the applications are usually aware of key qualities of the transport layer connection such as the end point IP addresses and port numbers. E-mail : info@wit. Telnet has port 23.UNIT 1 protocols are then encapsulated into one or (occasionally) more transport layer protocols (such as the Transmission Control Protocol (TCP) or User Datagram Protocol (UDP)). It's also sometimes necessary for Network Address Translation (NAT) facilities to take account of the needs of particular application layer protocols. the application layer must include any protocols that act like the OSI's presentation and session layer protocols. However. layers are not necessarily clearly defined in the Internet protocol suite. Application Layer protocols generally treat the transport layer (and lower) protocols as "black boxes" which provide a stable network connection across which to communicate.in Website : www.net. Clients.wit. Since the IP stack defines no layers between the application and transport layers.e. some firewall and bandwidth throttling applications do try to determine what's inside. and the commoner servers have specific ports assigned to them by the IANA: HTTP has port 80. Application layer protocols are most often associated with client– server applications. This is usually done through libraries. which in turn use lower layer protocols to effect actual data transfer.Sohna . i. port numbers assigned at random from a range set aside for the purpose.Sohna Palwal Road . and is an almost ubiquitous feature of modern domestic broadband routers).in . Gurgaon . (NAT allows hosts on private networks to communicate with the outside world via a single visible IP address using port forwarding. Transport and lower level layers are largely unconcerned with the specifics of application layer protocols. as with the Resource Reservation Protocol (RSVP).net. As noted above. World Institute Of Technology 8km milestone .Haryana. net. but rather the ability of the reader to navigate increasingly complex search structures.the encyclopedia. if you're reading this document. Currently. Introduction to Hypertext Documents Introduction to HTTP Introduction to DNS Introduction to Network Security 1. 2.wit. is most simply a way of constructing documents that reference other documents. DNS. Hypertext's original idea was to take advantage of electronic data processing to organize large quantities of information that would otherwise overwhelm a reader. the link can be activated to view the other document. World Institute Of Technology 8km milestone . additional increases in human information processing ability seem tied to developing more sophisticated automated search tools.Sohna .UNIT 1 Lecture: 20 & 21 Hypertext Documents. Introduction to Hypertext Documents Hypertext. by making directly accessible information that would otherwise be relegated to a bibliography. a block of text can be tagged as a hypertext link pointing to another document.in Website : www. Two hundred years ago.in . though the present technology presents possibilities that remain far from fully explored. Network Security Contents 1. made famous by the World Wide Web. Within a hypertext document. HTTP. Of course. Hypertext's limiting factor appears not to be the physical size of some books. Hypertext's older cousin combined topical articles with an indexing system to afford the researcher one or perhaps two orders of magnitude increase in the volume of accessible information. E-mail : [email protected]. the printing press made possible a similar innovation .Sohna Palwal Road . you're already familiar with the concept. 3. Gurgaon .Haryana. 4. Early experience with hypertext suggests that it may ultimately yield an additional order of magnitude increase. NH-71 B . When viewed with a hypertext browser. all thirty-odd volumes of it. As soon as a Web user opens their Web browser. then it is little more than normal. in addition to the Web page files it can serve. will be taken using a hand-held hypertext terminal.wit. Can you count on it to be there later? 2. Your Web browser is an HTTP client. video.in Website : www. To make this accessible. This is the potential of hypertext. and other multimedia files) on the World Wide Web.Sohna Palwal Road . available hypertext documents should range from the broadest possible overview of a subject. HTTP is an application protocol that runs on top of the TCP/IP suite of protocols (the foundation protocols for the Internet). sequential text. Hypertext. In general. a program that is designed to wait for HTTP requests and handle them when they arrive. relayed directly to the kitchen for preparation. Gurgaon . then someone could follows a link on atomic energy and ultimately hope to find a description of the U-238 decay process. searchable online and with each article possessing links to a half dozen reference documents with even more detailed subject coverage.Sohna . A hypertext document should present the reader with several links. down to its gritty details. becomes a simple. graphic images. a document should present as many relevant links as the reader can easily comprehend and select among.UNIT 1 Augmenting basic hypertext with graphics.in .Haryana. the user is indirectly making use of HTTP. The great advantage of hypertext is that it permits readers to explore to a breadth and depth that is simply not feasible in print. but it's amazing how many Web links point nowhere.net. if there are ten million pages of text in your system. HTTP concepts include (as the Hypertext part of the name implies) the idea that files can contain references to other files whose selection will elicit additional transfer requests. E-mail : info@wit. more complex user input fields and dynamically generated documents adds considerable power and flexibility to this concept. Imagine the Encyclopedia Britannica. Introduction to HTTP HTTP (Hypertext Transfer Protocol) is the set of rules for transferring files (text. This may seem trivial. it would be just as simple to read through it from beginning to end and forget all this hypertext silliness. be careful linking to any hypertext document not under your direct control. Characteristics of good hypertext documents The flexibility of hypertext gives free range to the author's creativity. If all the text in your system can be printed on ten pages. but good hypertext appears to have some common characteristics: • • • • Lots of documents. Correct links. general purpose user interface that fits neatly into the increasingly popular client-server model. NH-71 B . Any Web server machine contains. It does not seem difficult to image a day when restaurant orders. Ideally. an HTTP daemon. for example.net. and simultaneously logged to a database for later analysis by management. Range of detail. offering a choice about where to go next. sending requests to server machines. sound. If each document has just one link. though still useful for its original goal of organizing large quantities of information. On the other hand. Much of the hypertext's power comes from its ability to make large quantities of information accessible. When the browser user enters file requests by either "opening" a Web file (typing in a Uniform Resource Locator or URL) or World Institute Of Technology 8km milestone . Lots of links. Gurgaon .Sohna .Sohna Palwal Road .188. Other identifiers such as RFID tags. World Wide Web (WWW) hyperlinks and Internet contact information can remain consistent and constant even if the current Internet routing arrangements change or the participant uses a mobile device. By providing a worldwide. the domain name www. In general. Introduction to DNS The Domain Name System (DNS) is a hierarchical naming system built on a distributed database for computers. Because of this. services. independent of each entity's physical location. such as the list of mail servers that accept email for a given Internet domain.) The latest version of HTTP is HTTP 1.77.wit. The Domain Name System distributes the responsibility of assigning domain names and mapping those names to IP addresses by designating authoritative name servers for each domain. The Domain Name System makes it possible to assign domain names to groups of Internet resources and users in a meaningful way.166 (IPv4) or 2001:db8:1f70: 999:de8:7648:6e8 (IPv6). and in turn can assign other authoritative name servers for their sub-domains. E-mail : info@wit. International characters in email addresses and host names.net. the Domain Name System also stores other types of information. Most importantly.example. It associates various information with domain names assigned to each of the participating entities.UNIT 1 clicking on a hypertext link. or any resource connected to the Internet or a private network. and a variety of other identifiers could all potentially utilize DNS.in . NH-71 B .0.32. World Institute Of Technology 8km milestone .net. it translates domain names meaningful to humans into the numerical identifiers associated with networking equipment for the purpose of locating and addressing these devices worldwide. The HTTP daemon in the destination server machine receives the request and sends back the requested file or files associated with the request.in Website : www.com translates to the addresses 192. Users take advantage of this when they recite meaningful Uniform Resource Locators (URLs) and e-mail addresses without having to know how the computer actually locates them. (A Web page often consists of more than one file. For example. This mechanism has made the DNS distributed and fault tolerant and has helped avoid the need for a single central register to be continually consulted and updated. An often-used analogy to explain the Domain Name System is that it serves as the phone book for the Internet by translating human-friendly computer hostnames into IP addresses. the browser builds an HTTP request and sends it to the Internet Protocol address (IP address) indicated by the URL. Authoritative name servers are assigned to be responsible for their particular domains.10 (IPv4) and 2620:0:2d0:200:10 (IPv6). UPC codes. the Domain Name System is an essential component of the functionality of the Internet. Internet domain names are easier to remember than IP addresses such as 208.Haryana. 3. distributed keyword-based redirection service.1. Secure network infrastructure : Switches and routers have hardware and software features that support secure connectivity. or the corporate network). Services include passwords. and institutions undertake to protect the value and ongoing usability of assets and the integrity and continuity of operations. Gurgaon . Dedicated network security hardware and software-Tools such as firewalls and intrusion detection systems provide protection for all areas of the network and enable secure connections. Introduction to Network Security Network security involves all activities that organizations. E-mail : info@wit. such as posing as a technical support person and asking for people's passwords.net. 4.Sohna . identity services.Haryana. intrusion protection. Network security tools include: Antivirus software packages : These packages counter most virus threats if regularly updated and correctly maintained. It defines the DNS protocol. databases. An effective network security strategy requires identifying threats and then choosing the most effective set of tools to combat them. Virtual private networks : These networks provide access control and data encryption between two different computers on a network. perimeter security. Security management : This is the glue that holds together the other building blocks of a strong security solution. Encryption : Encryption ensures that messages cannot be intercepted or read by anyone other than the authorized recipient. access attacks (which exploit network vulnerabilities in order to gain entry to e-mail.in . This allows remote workers to connect to the network without the risk of a hacker or thief intercepting data.Sohna Palwal Road . digital certificates. and security management. NH-71 B .in Website : www. and digital authentication keys.wit. enterprises. World Institute Of Technology 8km milestone . as part of the Internet Protocol Suite.UNIT 1 The Domain Name System also specifies the technical functionality of this database service. a detailed definition of the data structures and communication exchanges used in DNS. which appear to be harmless or useful software programs such as games Vandals : Software applications or applets that cause destruction Attacks : Including reconnaissance attacks (information-gathering activities to collect data that is later used to compromise networks).net. Threats to network security include: Viruses : Computer programs written by devious programmers and designed to replicate themselves and infect computers when triggered by a specific event Trojan horse programs : Delivery vehicles for destructive code. and denial-of-service attacks (which prevent access to part or all of a computer system) Data interception : Involves eavesdropping on communications or altering data packets being transmitted Social engineering : Obtaining confidential network security information through nontechnical means. Identity services : These services help to identify users and control their activities and transactions on the network. C has greatly influenced many other popular programming languages. it is also widely used for developing portable application software.Haryana. Lecture: 20 & 21 An Overview of C: Constants. Introduction to Operators Types of Operators 7.wit. Introduction to C 2.Sohna .in . operators and Expressions. Gurgaon . 2. they can be highly effective in keeping a network safe from attacks and other threats to security. which began as an extension to C. but when they are layered together. E-mail : info@wit. most notably C++. Introduction to Data types Types of Data types About Data type conversion Data type Modifiers 6. NH-71 B . Contents 1. Introduction to Variables Declaration of Variables Constant Variables 5. Although C was designed for implementing system software. C is one of the most popular programming languages of all time and there are very few computer architectures for which a C compiler does not exist. Introduction to C C is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. Variables and Data types.in Website : www. In addition.net. World Institute Of Technology 8km milestone . Introduction to Expressions 1.Sohna Palwal Road . C Programming 3. C Programming A SIMPLE C PROGRAM The following program is written in the C programming language. well-thought-out corporate policies are critical to determine and control access to various parts of the network. Introduction to Constants Types of Constants 4.UNIT 1 None of these approaches alone will be sufficient to protect a network.net. lowercase and uppercase characters are very important! All commands in C must be lowercase.wit. Summary of major points so far • • • • • program execution begins at main() keywords are written in lower-case statements are terminated with a semi-colon text strings are enclosed in double quotes C is case sensitive. Gurgaon . printf() is actually a function (procedure) in C that is used for printing variables and text.net. The two braces. clear line etc. As we shall see later on. There are some exceptions however. Thus the program prints Programming in C is easy. The program has only one statement printf("Programming in C is easy. what follows the \ character will determine what is printed.UNIT 1 #include <stdio.h> is to allow the use of the printf statement to provide program output. NH-71 B . The brackets that follow the keyword main indicate that there are no arguments supplied to this program. and the cursor is set to the beginning of the next line. ie.Haryana.\n").in Website : www.h> main() { printf("Programming in C is easy. These characters are modifiers. A NOTE ABOUT C PROGRAMS In C. Where text appears in double quotes "". { and }. Text to be displayed by printf() must be enclosed in double quotes. The C programs starting point is identified by the word main() This informs the computer as to where the program actually starts. Another important thing to remember is that all C statements are terminated by a semi-colon.Sohna Palwal Road .in . signify the begin and end segments of the program.net. use lower-case and try not to capitalise variable names World Institute Of Technology 8km milestone .Sohna . This has to do with the \ and % characters.\n"). it is printed without modification. and for the present the \ followed by the n character represents a newline character. a tab. E-mail : info@wit. clear screen. } Sample Program Output Programming in C is easy. The purpose of the statment #include <stdio. in Website : www.Sohna . /* HEADER SECTION */ /* Contains name. as a number of well defined sections.Haryana.Sohna Palwal Road .in . #include <stdio. Gurgaon . Introduction to Constants A constant can be defined as “a quantity that does not change during the execution of a program”. NH-71 B . author. revision number*/ /* INCLUDE SECTION /* contains #include statements */ */ /* CONSTANTS AND TYPES SECTION /* contains types and #defines */ /* GLOBAL VARIABLES SECTION /* any global variables declared here */ /* FUNCTIONS SECTION /* user defined functions */ /* main() SECTION */ */ */ */ int main() { } Adhering to a well defined structured layout will make your programs • • • • easy to read easy to modify consistent in format self documenting 3.net.h> void main(void) { World Institute Of Technology 8km milestone . E-mail : [email protected] 1 • • • \n means position the cursor on the beginning of the next line printf() can be used to display text to the screen the curly braces {} define the beginning and end of a program block Basic Structure of C Programs C programs are essentially constructed in the following manner. Haryana. It could either be positive or negative. 4. printf(“%d”. 10 here is an integer constant and every time you try to execute this program. ‘b’. NH-71 B . Types of Constants Integer Constant An integer constant must have at least one digit and should not have decimal point.wit. the output will always be 10. Gurgaon .net. etc.9. or the digits 0 .net. and may be followed by any combination of characters. ‘A’.Sohna . Character Constant A character constant should be only one character and must be enclosed in single quotes e. summary exit_flag i Jerry7 Number_of_moves _valid_flag You should ensure that you use meaningful names for your variables.in Website : www.Sohna Palwal Road . The following is a list of valid variable names.g. Real Constant A real constant must have at least one digit and must have a decimal point.UNIT 1 int a = 10. underscores.EXE file makes programs easier to read Declaration of variables To declare a variable means to create a memory space for the variable depending on the data type used and associate the memory location with the variable name. E-mail : [email protected] . The reasons for this are: • • • • meaningful names for variables are self documenting (see what they do at a glance) they are easier to understand there is no correlation with the amount of space used in the . Introduction to Variables Variables must begin with a character or underscore. In C all the variables World Institute Of Technology 8km milestone .a). } Program Output 10 Here we are declaring a variable a with its initial value 10. auto.Haryana. Its value will remain constant throughout the programs execution. Primary data type. rateofinterest. i. Integer int 2.in . Void void World Institute Of Technology 8km milestone .in Website : www. Character Type.j.14. Declaration of Storage Class.: int age. E-mail : [email protected]. Integer Type. const float pi = 3. Declaration of Variables. extern. Defining Symbolic Constants. Floating Point float 4. Double precision floating point double 5. int age.UNIT 1 should be declared before it can be used. Size and Range of Data Types on 16 bit machine. NH-71 B . User defined type declaration. Void Type. Introduction to Data types C language data types.net. float amount. Character char 3. Here is a declaration of a named constant. Also you cannot re-declare a variable once it has been already declared. Declaring Variable as Constant and Volatile Variable All C Compilers accept the following fundamental data types. The general pattern for declaring a variable is as follows: e. or an error will result when the program is compiled. Constant Variables A constant variable is also called a named constant. Floating Point Types. derived data type.Sohna Palwal Road . static. An initialization value must be given when declaring a variable with the const qualifier.Sohna . char ch. const is a qualifier that tells the compiler to make the variable read only. It looks just like a regular variable declaration except that the word const appears before the data type name. count. A compiler error will also result if there are any statements in the program that attempt to change the contents of a named constant 5. register.g. totalbalance. 1. Gurgaon . A named constant is really a variable whose content is read-only and cannot be changed while the program is running.wit. int An example of an integer value is 32. In addition. int sum. • DOUBLE World Institute Of Technology 8km milestone .4 e+38 double 1. both positive and negative.in Website : www. money = 0.7 e+308 Types of Data Types The four basic data types are: • INTEGER These are whole numbers.Sohna .7 e-308 to 1. • FLOATING POINT These are numbers which contain fractional parts.net. E-mail : [email protected] .Sohna Palwal Road . An example of declaring a float variable called money is. DATA TYPE RANGE OF VALUES char -128 to 127 Int -32768 to +32767 float 3.wit.12. The keyword used to define float variables is. float An example of a float value is 34. The keyword used to define integers is.4 e-38 to 3. sum = 20.Haryana.12.net. NH-71 B . Unsigned integers (positive values only) are supported. Gurgaon . An example of declaring an integer variable called sum is. float money.UNIT 1 The size and range of each data type is given in the table below. both positive and negative. there are short and long integers. printf("value of letter = %c\n".UNIT 1 These are exponetional numbers.h > main() { int sum. Gurgaon . printf("value of money = %f\n". char An example of a character value is the letter A. NH-71 B . big = 312E+7.Use single quotes.0E2. • CHARACTER These are single characters. char letter. both positive and negative.in Website : www.Haryana. The keyword used to define double variables is. double big. E-mail : [email protected]. An example of declaring a double variable called big is. Sample program illustrating each data type #include < stdio. money ). double pi. money = 2.in . An example of declaring a character variable called letter is.Sohna .21. letter = 'A'. The keyword used to define character variables is. Remember the golden rule: Single character . printf("value of pi = %e\n". double An example of a double value is 3. pi ). sum = 10. pi = 2.01E6. /* assign integer value */ /* assign float value */ /* assign character value */ /* assign a double value */ printf("value of sum = %d\n".Sohna Palwal Road . float money. sum ). Note the assignment of the character A to the variable letter is done by enclosing the value in single quotes. letter = 'A'.wit. char letter.net. letter ). } World Institute Of Technology 8km milestone . printf("Float variable is %f\n". #include <stdio. printf("Double variable is %e\n". float set1 = 23. eg.h> main() { int sum = 100.2f\n".000000e23 To change the number of decimal places printed out for float or double variables. sum).567000 Double variable is 11.567.in . set1 ).net. letter). char letter = 'Z'. only how many decimal places printf() uses to display these variable types. The following program illustrates how the different data types are declared and displayed. World Institute Of Technology 8km milestone . printf("Float variable is %.net.in Website : www.210000 value of letter = A value of pi = 2. This does NOT refer to the precision (accuracy) of which the number is actually stored. modify the %f or %e to include a precision value. E-mail : info@wit. printf("Integer variable is %d\n".Sohna Palwal Road . } Sample program output Integer variable is 100 Character variable is Z Float variable is 23. num2).Sohna .UNIT 1 Sample program output value of sum = 10 value of money = 2.010000e+06 MORE ABOUT FLOAT AND DOUBLE VARIABLES C displays both float and double variables to six decimal places. printf("Character is %c\n". NH-71 B . Gurgaon . set1).Haryana. double num2 = 11e+23.wit. 000000 Even though the above declaration seems to work. The following change illustrates how this can be done. printf("The value of %d divided by %d is %f\n". NH-71 B . float answer = 0. It is possible in C to specify that an integer be stored in four memory locations instead of the normal two. } Sample program output The value of 12 divided by 5 is 2. This value differs from computer to computer.value2. answer = value1 / value2. value2 = 5. it is not always 100% reliable.Sohna . The way in which this is done is as follows. #include <stdio.net.Sohna Palwal Road .wit.Haryana. answer = (float)value1 / (float)value2. the use of %. To ensure that the correct result always occurs.56 Double variable is 11. and the output now looks like Sample program output Integer variable is 100 Character variable is Z Float variable is 23. Different Types of Integers A normal integer is limited in range to +-32767.answer ). Gurgaon .000000e23 About Data Type Conversion Consider the following program. E-mail : info@wit. World Institute Of Technology 8km milestone . the data type of value1 and value2 should be converted to a float type before assigning to the float variable answer.in .UNIT 1 In this case. This increases the effective range and allows very large integers to be stored.net. Note how answer does not contain a proper fractional part (ie.in Website : www.value1.2f limits the output to two decimal places.h> main() { int value1 = 12. all zero's). short int small_value = 114h. Short integers are also available.net. and hence the number range of each type.wit. int is assumed. use %l. which means they have a range of -32768 to 32767 and 0 to 65535. Gurgaon . so we will have to use the integer data type int. signed int i. So we have a problem here. Unsigned integers (positive values only) can also be defined. Each of the above can be applied to the base type int. not needed */ Data type Modifiers Let us consider an example of a program.net. which will accept an age from the user to do some processing.UNIT 1 long int big_number = 245032L.Sohna Palwal Road . The size occupied by integers varies upon the machine hardware. World Institute Of Technology 8km milestone . eg. unsigned. The modifiers signed and unsigned can be applied to the base type char. When the base type is ommitted from a declaration. short. big_number ). We all know that even under exceptional case an age of a person cannot exceed more than 150. /* int is implied */ unsigned char ch. printf("The value is %h\n". They can be signed (default) or unsigned. that we are using an integer data type it occupies 2 Bytes of memory. Type modifiers: signed. respectively.in Website : www. Type: int Integer data type Variables of type int are one word in length. The following information is from the on-line help of the Turbo C compiler. long A type modifier alters the meaning of the base type to yield a new type. Instead the value 150 could easily be saved in an integer of 1 Byte in size.Haryana. E-mail : info@wit. Now. NH-71 B . small_value). long can be applied to double. but the default size of an integer is 2 Bytes.Sohna . /* signed is default */ unsigned long int l.in . printf("A larger number is %l\n". Examples: long x. In addition. which would not be required to represent the value 150. To display a long integer. ANSI C (American National Standards Institute) has tried to standardise upon the size of data types. Because the age is represented in numbers. ie. /* int ok. Please refer to the example of age variable to explain the concept of data type modifiers. Short If long data type modifier doubles the size. if we were to declare a variable age. E-mail : [email protected] . This declaration above. will provide the variable age with only 1 byte and its data range will be from -128 to 127.wit. This declaration allows the age variable to store only positive values. C has a rich set of operators which can be explained as. Please note that in some compilers this has no effect. NH-71 B . which modifies the size of the double data type to 10 bytes. E. Types of Operators ARITHMETIC OPERATORS World Institute Of Technology 8km milestone . we can modify the default behavior of the int data type as follows: unsigned int age. The exception to this is long double.Haryana.net. Signed means that the data type is capable of storing negative values.UNIT 1 Well. we know that an age cannot be represented by negative values and hence.Sohna .g. An immediate effect is that the range changes from (-32768 to 32767) to (0 to 65536) Long Many times in our programs we would want to store values beyond the storage capacity of the basic data types. not that we can’t solve. To override the default nature of a data type. Introduction to Operators An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. C has provided us with data type modifiers as follows: Signed By default all data types are declared as signed.in Website : www. The same will be achieved by providing the declaration of age as follows: short int age. This doubles the storage capacity of the data type being used. In such cases we use the data type modifier long. long int annualsalary will make the storage capacity of variable annualsalary to 4 bytes. Operators are used in C language program to operate on data and variables. short on the other hand reduces the size of the data type to half. Gurgaon . 6.Sohna Palwal Road . we require to use the data type unsigned. Unsigned To modify a data type’s behavior so that it can only store positive values. For example. use two.Sohna . modulus = sum % 10. printf("The %% of %d by 10 is %f\n". 4 6 Subtraction - sum = sum -2.h> main() { int sum = 50. NH-71 B .000000 Increment The increment operator adds one to the value of the variable. count++. Note: If the modulus % sign is needed to be displayed as part of a text string. World Institute Of Technology 8km milestone .UNIT 1 The symbols of the arithmetic operators are:Operation Operator Comment Value of Sum before Value of sum after Multiply * sum = sum * 2. 4 1 % The following code fragment adds the variables loop and count together. Gurgaon . modulus). 4 8 Divide / sum = sum / 2. 4 5 Decrement -- --sum.net. count has a value of 5. leaving the result in the variable sum sum = loop + count.in . 4 2 Increment ++ ++sum.in Website : www. sum. ie %% #include <stdio.Sohna Palwal Road . float modulus. so that after the statement is executed.Haryana. 4 2 Addition + sum = sum + 2.net. 4 3 Modulus sum = sum % 3. int count = 4.wit. } Sample Program Output The % of 50 by 10 is 0. E-mail : info@wit. The following code fragment (part of a program) adds one to the value of count. Lets examine what happens when we use the operator along with an assignment operation. /* PRE Increment. /* same as loop = count. loop. count = %d\n". } Sample Program Output loop = 1. loop = count. E-mail : info@wit. #include <stdio. Consider the following statements ++count. the effects of the PRE/POST operation are not clearly visible. */ printf("loop = %d. The following code fragment (part of a program) subtracts one from the value of count.UNIT 1 Decrement The decrement operator subtracts one from the value of the variable. means add one to count */ /* POST Increment. because the value of count is not assigned to any variable. loop = ++count. loop. count = 1 loop = 1. count).h> main() { int count = 0. PRE/POST INCREMENT/DECREMENT OPERATORS PRE means do the operation first followed by any assignment operation. The following code fragment (part of a program) uses the modulus operator to calculate the modulus of 20 % 3. divide 20 by 3. int count = 4.in Website : www.Haryana. Modulus The modulus operator assigns the remainder left over after a division the value of the variable.wit. means add one to count */ In the above example. count = %d\n". count). so that after the statement is executed. count = 2 World Institute Of Technology 8km milestone . */ printf("loop = %d. POST means do the operation after any assignment operation.net. Consider the following program.net. /* same as count = count + 1.Sohna Palwal Road .in . To work this out. loop. Gurgaon . loop = count++. count has a value of 3. count--. count++.Sohna . count = count + 1. NH-71 B . the expression is evaluated first and then replaces the previous value of the variable on the left hand side. E-mail : [email protected] Palwal Road . Implicit type conversion.e.Haryana. every expression results in some value of a certain type that can be assigned to a variable.in Website : www.in . Precedence in Arithmetic Operators. Some examples of C expressions are shown in the table given below. All World Institute Of Technology 8km milestone .net. Type conversions in expressions. so the statement loop = ++count.Arithmetic Expressions. Gurgaon .net.UNIT 1 If the operator precedes (is on the left hand side) of the variable. Explicit Conversion and Operator precedence and associativity. In C every expression evaluates to a value i. Arithmetic Expressions An expression is a combination of variables constants and operators written according to the syntax of C language. Algebraic Expression axb–c C Expression a*b–c (m + n) (x + (m + n) * (x + y) y) (ab / c) a*b/c 3x2 +2x + 1 3*x*x+2*x+1 (x / y) + c x/y+c Evaluation of Expressions Expressions are evaluated using an assignment statement of the form Variable = expression. then assign the new value of count to loop.wit. Variable is any valid C variable name. When the statement is encountered.Sohna . NH-71 B .. Evaluation of Expressions. Introduction to Expression Expression in C programming language . really means increment count first. Rules for evaluation of expression. 7. the operation is performed first. c = 3. Gurgaon .00 y = 7. z = a – ( b / (3 + c) * 2) – 1.Sohna .Haryana. World Institute Of Technology 8km milestone . • If parenthesis are nested. High priority * / % Low priority + - Rules for evaluation of expression • First parenthesized sub expression left to right are evaluated. z.net. y = a – b / (3 + c) * (2 – 1). b. b = 12. There are two distinct priority levels of arithmetic operators in C. The following program illustrates the effect of presence of parenthesis in expressions. the evaluation begins with the innermost sub expression. output x = 10.Sohna Palwal Road .in Website : www. a = 9. .y). printf (“z = %fn”. NH-71 B . c x.net.00 Precedence in Arithmetic Operators An arithmetic expression without parenthesis will be evaluated from left to right using the rules of precedence of operators. main () { float a. . x = a – b / 3 + c * 2 – 1. Example of evaluation statements are x=a*b–c y=b/c*a z = a – b / c + d.in .wit. printf (“y = %fn”.00 z = 4.z). y. printf (“x = %fn”. } . E-mail : [email protected]).UNIT 1 variables used in the expression must be assigned values before evaluation is attempted. . If one operand is long int and other is unsigned int then . If unsigned int can be converted to long int. C automatically converts any intermediate values to the proper type so that the expression can be evaluated without loosing any significance. . the other will be converted into unsigned long int and result will be unsigned long int. If one operand is long double. The associability rule is applied when two or more operators of the same precedence level appear in the sub expression.in Website : www.net. the other will be converted to double and result will be double. the other will be converted to float and result will be float. 7. The following rules apply during evaluating expressions All short and char are automatically converted to int then 1. When Parenthesis are used. 4.. the other will be converted to long int and the result will be long int. 5. then unsigned int operand will be converted as such and the result will be long int. If one operand is unsigned int the other will be converted to unsigned int and the result will be unsigned int.b. the expressions within parenthesis assume highest priority. . Else Both operands will be converted to unsigned long int and the result will be unsigned long int.. This automatic type conversion is know as implicit type conversion During evaluation it adheres to very strict rules and type conversion.UNIT 1 • • • • The precedence rule is applied in determining the order of application of operators in evaluating sub expressions.. .wit.Sohna Palwal Road . Explicit Conversion Many times there may arise a situation where we want to force a type conversion in a way that is different from automatic conversion. the other will be converted to long double and result will be long double.. . .Sohna . 2. If one of the operand is long int. If one operand is float. Arithmetic expressions are evaluated from left to right using the rules of precedence.net..Haryana.. If one of the operand is unsigned long int.a. Gurgaon . If one operand is double. 3.. The result is of higher type. E-mail : info@wit. World Institute Of Technology 8km milestone . Type conversions in expressions Implicit type conversion C permits mixing of constants and variables of different types in an expression.6.in . If the operands are of different types the lower type is automatically converted to the higher type before the operation proceeds. NH-71 B . Gurgaon ... Then using the rule of automatic conversion..... the division is performed by floating point mode............ The precedence is used to determine how an expression involving more than one operator is evaluated..in Website : www. The operators of higher precedence are evaluated first..Sohna . This is known as associativity property of an operator.. This problem can be solved by converting locally one of the variables to the floating point as shown below.net.. the decimal part will be rounded off and its ratio will represent a wrong figure. ------------------.........female_students Ratio =. The general form is (type_name) expression Operator precedence and associativity Each operator in C has a precedence associated with it...UNIT 1 Consider for example the calculation of number of female and male students in a class ...in .... NH-71 B .Sohna Palwal Road . E-mail : [email protected].. There are distinct levels of precedence and an operator may belong to one of these levels. male_students Since if female_students and male_students are declared as integers. The process of such a local conversion is known as explicit conversion or casting a value. World Institute Of Technology 8km milestone ..... The operators of same precedence are evaluated from right to left or from left to right depending on the level......net..Haryana. thus retaining the fractional part of the result.. Ratio = (float) female_students / male_students The operator float converts the female_students to floating point for the purpose of evaluation of the expression... World Institute Of Technology 8km milestone . Decision Making (Branching) Decision making (Branching) is deciding what actions to take and looping is deciding how many times to take a certain action. Decision Making (Branching) 2.net. if statement This is the most simple form of the branching statements.Haryana.Sohna . Branching: Branching is so called because the program chooses to follow one branch or another. Contents 1. E-mail : info@wit. It takes an expression in parenthesis and an statement or block of statements.in Website : www. NH-71 B . Decision making (Branching) 2.wit. Looping 1.net.UNIT 1 Lecture: 23 Decision making & Looping. Gurgaon .in . if the expression is true then the statement or block of statements gets executed otherwise these statements are skipped.Sohna Palwal Road . Looping C provides two styles of flow control: 1. } or if (expression) { Block of statements. Gurgaon .Sohna .wit. ? : is a ternary operator in that it takes three values. } else if(expression) { Block of statements.net. or if (expression) { Block of statements. if statements take the following form: if (expression) statement. E-mail : [email protected] Website : www. NH-71 B .in ... } or if (expression) { Block of statements.UNIT 1 NOTE: Expression will be assumed to be true if its evaulated values are non-zero.Haryana. else statement except that because it is an operator you can use it within expressions. this is the only ternary operator C has. } else { Block of statements. } ? : Operator The ? : operator is just like an if . } else { Block of statements.net. World Institute Of Technology 8km milestone .Sohna Palwal Road . What is default condition: If none of the listed conditions is met then default condition executed.A while statement is like a repeating if statement. E-mail : info@wit. If it is still true the statements get executed again. while loop The most basic loop in C is the while loop. C provides a number of looping way. Its mostly a matter of preference which you use.UNIT 1 ? : takes the following form: if condition is true ? then X return value : otherwise Y value. the test condition is checked again.wit. The difference is that after the statements have been executed. statements2. Looping Loops provide a way to repeat commands and control how many times they are repeated.. Gurgaon . NH-71 B .This cycle repeats until the test condition evaluates to false.Sohna .net.Sohna Palwal Road . switch statement: The switch statement is much like a nested if .in Website : www.net.Haryana.] statements3. if the test condition is true: the statments get executed. else statement.in .] } statements1. 2. This is achieved by using break keyword. Basic syntax of while loop is as follows: while ( expression ) { Single statement or World Institute Of Technology 8km milestone .] Using break keyword: If a condition is met in switch case then execution continues on into the next case clause also if it is not explicitly specified that the execution should exit the switch statement. Like an If statement. switch statement can be slightly more efficient and easier to read. switch( expression ) { case constant-expression1: [case constant-expression2: [case constant-expression3: [default : statements4. } for loop for loop is similar to while..net.Sohna Palwal Road .while loop is as follows: do { Single statement or Block of statements. it's just written differently. Gurgaon . Basic syntax of do. expression2 .in Website : www.Condtional expression..UNIT 1 Block of statements. } In the above syntax: expression1 . do.while loop do . break and continue statements C provides two commands to control how we loop: World Institute Of Technology 8km milestone .Initialisese variables.in . for statements are often used to proccess lists such a range of numbers: Basic syntax of for loop is as follows: for( expression1.Sohna . }while(expression).expression3 is the modifier which may be simple increment of a variable. while is just like a while loop except that the test condition is checked at the end of the loop rather than the start.Haryana. expression2.wit. This has the effect that the content of the loop are always executed at least once. E-mail : info@wit. expression3 . loop will keep executing... NH-71 B . expression3) { Single statement or Block of statements.net.. as long as this condition is true.. Gurgaon . i ++ ) { if( i == 5 ) { continue. You already have seen example of using break statement. Here is an example showing usage of continue statement.in . i ).Sohna Palwal Road .Haryana. for( i = 0.wit.skip 1 iteration of loop.net. continue -.Sohna . NH-71 B . #include main() { int i. i <= j. int j = 10.exit form loop or switch. } } This will produce following output: Hello 0 Hello 1 Hello 2 Hello 3 Hello 4 Hello 6 Hello 7 Hello 8 Hello 9 Hello 10 World Institute Of Technology 8km milestone .net.UNIT 1 break -. } printf("Hello %d\n".in Website : www. E-mail : info@wit. In C. It becomes increasingly more difficult to keep track of this as the number of variables increase.wit. must be declared before they can be used. our initial attempt will be to create a specific variable for each user. Consider the case where a programmer needs to keep track of a number of people within an organisation. int name2 = 232. indexing starts at zero. This might look like. Arrays Arrays are a data structure which hold multiple variables of the same data type.net.in Website : www. Arrays. World Institute Of Technology 8km milestone .in . NH-71 B . like other variables in C. Arrays offer a solution to this problem.Sohna Palwal Road . int name1 = 101. The replacement of the above example using arrays looks like. Contents o o Arrays Character Arrays (Strings) 1. a bit like a filing cabinet. Character Arrays (Strings). So far.Sohna . Gurgaon .net. and uses an indexing system to find each variable stored within it. int name3 = 231.Haryana. E-mail : info@wit. An array is a multi-element box.UNIT 1 Lecture: 24 Arrays. We created an array called names. You may also see that we stored 0 in the last space of the array. 2 */ #include <stdio. word[3] = 'l'. x[10] = g. word[2] = 'l'. array elements start with 0. names[3] = 0. so character based arrays are used to hold strings). Assigning values to array elements is done by. word[5] = 0. names[1] = 232. word[0] = 'H'.net. names[0] = 101. word ). there is no string type. This is a common technique used by C programmers to signify the end of an array.Haryana. World Institute Of Technology 8km milestone .Sohna . Gurgaon . word[4] = 'o'. to signify the end of the character string (in C. Arrays have the following syntax. g = x[10]. word[1] = 'e'. E-mail : [email protected]. NH-71 B . a character based array named word is declared. and each element is assigned a character.net. In C. which has space for four integer variables. and assigning array elements to a variable is done by. A printf statement is then used to print out all elements of the array.in Website : www. /* Introducing array's. The last element is filled with a zero value.h> main() { char word[20]. In the following example.in .Sohna Palwal Road . names[2] = 231. printf("The contents of word[] is -->%s\n".UNIT 1 int names[4]. using square brackets to access each indexed value (called an element). x[i] so that x[5] refers to the sixth element in an array called x. ++x ) printf("Values [%d] is %d\n". World Institute Of Technology 8km milestone .3.in .UNIT 1 } Sample Program Output The contents of word[] is Hello Declaring Arrays Arrays may consist of any of the valid data types. NH-71 B . } Sample Program Output The 3rd element of array numbers is 9 The above program declares two arrays.h> main() { int x.7.Sohna .'l'.6.'l'. /* Introducing array's */ #include <stdio.4. assigns 10 to the value of the 3rd element of array numbers.net. E-mail : [email protected]. static char word[] = { 'H'.'e'. --numbers[2]. numbers[2]). Assigning Initial Values To Arrays The declaration is preceded by the word static. Arrays are declared along with all other variables in the declaration section of the program. and finally prints the value. #include <stdio. The number of elements that each array is to have is included inside the square brackets. float averages[20].2.Sohna Palwal Road . for( x = 0.Haryana. static int values[] = { 1. x < 9. Gurgaon .net. decrements this value ( --numbers[2] ).'o' }. x.h> main() { int numbers[100]. eg. numbers[2] = 10. The initial values are enclosed in braces. values[x]).5. printf("The 3rd element of array numbers is %d\n".9 }.wit.in Website : www. #include <stdio. } Multi Dimensioned Arrays Multi-dimensioned arrays have two or more index values which specify the element in the array. values and word.. The following program shows how to initialise all the elements of an integer based array to the value 10.. static int m2[2][2] = { {0.in .Haryana.wit.3} }.1}. using a for loop to cycle through each element in turn. { 0. In this case.net. the first index value i specifies a row index. count < 100. Declaration and calculations int m1[10][10]..Sohna Palwal Road . int values[100]. World Institute Of Technology 8km milestone .Sohna . multi[i][j] In the above example. sum = m1[i][j] + m2[k][l]. for( count = 0. C initializes the array to the number of elements that appear within the initialize braces. Gurgaon .in Website : www. So values consist of 9 elements (numbered 0 to 8) and the char array word has 5 elements.h> main() { int count. Inside the braces are. NH-71 B .net. count++ ) values[count] = 10. E-mail : info@wit. 1 }. {2. Values[8] is 9 The previous program declares two arrays. whilst j specifies a column index. NOTE the strange way that the initial values have been assigned to the two-dimensional array m2.UNIT 1 } Sample Program Output Values[0] is 1 Values[1] is 2 . Note that inside the squarebrackets there is no variable to indicate how big the array is to be. h> main() { static char name1[] = {'H'. static char name2[] = "Hello".'o'}. the initialization can be changed to. NH-71 B . } Sample Program Output Helloxghifghjkloqw30-=kl`' Hello The difference between the two arrays is that name2 has a null placed at the end of the string. whilst name1 has not. Looking at the initial values assigned to m2.'l'.'\0'}. "hi there. 3 } Remember that arrays are split up into row and columns.in . strcpy( word. Gurgaon . To insert a null at the end of the name1 array. m2[0][0] = 0 m2[0][1] = 1 m2[1][0] = 2 m2[1][1] = 3 2. name1).'l'. they are.UNIT 1 { 2. printf("%s\n".h #include <stdio. name2).net. in name2[5].h> main() { char word[20]. ie. Consider the following program. word ). } World Institute Of Technology 8km milestone .in Website : www. which necessitates using the include file string.Sohna . using the function strcpy." ). the second is the column.net. The first is the row.Haryana.'l'.'e'.'e'. Character Arrays (Strings) #include <stdio. E-mail : info@wit. This can often result in garbage characters being printed on the end. printf("%s\n".wit.'o'. which initialises the contents of the character based array word during the program.'l'. static char name1[] = {'H'. printf("%s\n".h> #include <string.Sohna Palwal Road . in .UNIT 1 Sample Program Output hi there. so character based arrays are used in place of strings.. 5. double radians[1000].. -14. 27. static float radix[12] = { 134. Some Variations In Declaring Arrays int numbers[10]. which reads a string of characters (excluding spaces) from the keyboard. The %s modifier to printf() and scanf() is used to handle character based arrays.Sohna Palwal Road . static char text[] = "Welcome to New Zealand. string).net. char string[18]. -1..in Website : www. 9. string[4] = 'o' string[5] = '\0' Note how the enterkey is not taken by scanf() and the text string is terminated by a NULL character '\0' after the last character stored in the array. -3. static int numbers[] = { 2. Consider the following. Gurgaon .362. Reading Character Strings from The Keyboard Character based arrays are often refered to in C as strings.248 }.Haryana. 45.net. 1913. 16 }.Sohna . C does not support a string type. This assumes that a 0 or NULL value is stored in the last element of the array. 0 }. 28. World Institute Of Technology 8km milestone . 79. NH-71 B . static int numbers[10] = { 34. E-mail : info@wit.".wit. NOTE that the & character does not need to precede the variable name when the formatter %s is used! If the users response was Hello<enterkey> then string[0] = 'H' string[1] = 'e' . scanf("%s". A structure can contain any valid data types like int. zip code. float even arrays or even other structures.Haryana. structure initialization Contents Introduction to Structure Need of Structure Defining Structure Declaring Structure Complex Structure Accessing Structure Members Structure initialization Introduction to Union 1. Each variable in structure is called a structure member. street.Sohna Palwal Road .Sohna . char. you need to access multiple data types under a single name for easier data manipulation. Declaring variables.net.wit. Gurgaon .in Website : www. Accessing structure members. NH-71 B . country. If we need to use a collection of World Institute Of Technology 8km milestone . C supports structure which allows you to wrap one or more variables with different data types. Introduction to Structure In some programming contexts. for example you want to refer to address with multiple data like house number.UNIT 1 Lecture: 25 & 26 Structure and Union in C : Defining structure.in . 2.net. E-mail : info@wit. Need of Structure Arrays are used to store large set of data and manipulate them but the disadvantage is that all the elements stored in an array are to be of the same data type. net. book3. }.book3. For example the statement struct lib_books book1.UNIT 1 different data type items it is not possible using an array. … … } Example: struct lib_books { char title[20]. E-mail : info@wit. These are members of the structures. Structure is a method of packing data of different types.in .book2. author pages and price. The complete structure declaration might look like this struct lib_books { char title[20]. When we require using a collection of different data items of different data types we can use a structure. The tag name can be used to define objects that have the tag names structure.Sohna Palwal Road . The keyword struct declares a structure to holds the details of four fields namely title. data type member2. The structure we just declared is not a variable by itself but a template for the structure. int pages. float price.book2. NH-71 B . int pages.in Website : www. A structure is a convenient method of handling a group of related data items of different data types. char author[15]. book2. Gurgaon . book1. We can declare structure variables using the tag name any where in the program. char author[15]. struct lib_books.Haryana. float price. Each member may belong to different or same data type. general format of structure definition struct tag_name { data type member1. World Institute Of Technology 8km milestone . }.book3 as variables of type struct lib_books each declaration has four elements of the structure lib_books.wit.Sohna .net. declares book1. The use of tag name is optional for example struct { … … … } book1.wit.Sohna . int pages. the declaration struct lib_books { char title[20].UNIT 1 structures do not occupy any memory until it is associated with the structure variable such as book1. float price. The name of structure follows the rule of variable name.book2. NH-71 B . char author[15]. 3. While the entire declaration is considered as a statement. A structure is usually defines before main along with macro definitions. the template is terminated with a semicolon. } book1. Here is the common syntax of structure definition: struct struct_name{ structure_member }. Here is an example of defining address structure: struct address{ World Institute Of Technology 8km milestone .net. you use struct keyword. book2. Gurgaon . Defining Structure To define a structure.book3 as structure variables representing 3 books but does not include a tag name for use in the declaration.in Website : www. In such cases the structure assumes global status and all the functions can access the structure.net.book2. is valid.book3. E-mail : info@wit. The tag name such as lib_books can be used to declare structure variables of its data type later in the program.Sohna Palwal Road . We can also combine both template declaration and variables declaration in one statement.Haryana.in . book3 declares book1. each member is declared independently for its name and type in a separate statement inside the template. 4. The address structure contains house number as an positive integer. 6. Accessing Structure Member To access structure we can use dot operator (. E-mail : info@wit. We can define a complex structure called customer which contains address structure as follows: struct customer{ char name[50].. structure address billing_addr.in .in Website : www. structure address shipping_addr. Here is structure declaration syntax : struct struct_name instance_1.instance_2 instance_n. }. char country[50]. you can declare the structure instance at a different location in your source code after structure definition. you can do it in two ways: The first way is to declare a structure followed by structure definition like this : struct struct_name { structure_member.Sohna . Complex Structure If a structure contains arrays or other structures.instance_2 instance_n. zip code as an integer and country as a string. Declaring Structure The above example only defines an address structure without creating any structure instance.net. To create or declare a structure instance. } instance_1. }. In the second way.UNIT 1 unsigned int house_number. .) between structure name and structure member as follows: World Institute Of Technology 8km milestone .Sohna Palwal Road . char street_name[50].net.wit. it is called complex structure. int zip_code. street name as a string. 5. For example address structure is a structure. Gurgaon . NH-71 B ..Haryana. wit.UNIT 1 structure_name.billing_addr. Thus unions are used to observe memory. jack. NH-71 B . struct customer jack.Sohna Palwal Road . E-mail : [email protected]=”US’”. Structure Initialization A structure can contain pointers as structure members and we can create a pointer to a structure as follows: typedef struct{ unsigned int house_number.net.structure_member For example to access street name of structure address we do as follows: struct address billing_addr.country=”US”.net. char street_name[50]. However the members that compose a union all share the same storage area within the computers memory where as each member within a structure is assigned its own unique storage area. Introduction to Union Unions like structure contain members whose individual data types may differ from one another. Gurgaon . address shipping_addr. int zip_code.Sohna . billing_addr. address billing_addr. They are useful for application involving multiple members. float p.in Website : www. } address. If the structure contains another structure. char country[50]. we can use dot operator to access nested structure and use dot operator again to access variables of nested structure. World Institute Of Technology 8km milestone . Like structures union can be declared using the keyword union as follows: union item { int m. Where values need not be assigned to all the members at any one time. 8. 7.in .Haryana. Sohna . code.UNIT 1 char c. In effect a union creates a storage location that can be used by one of its members at a time. Unions may be used in all places where a structure is allowed. Gurgaon . } code. However we can use only one of them at a time.net.wit. The notation for accessing a union member that is nested inside a structure remains the same as for the nested structure. E-mail : info@wit. NH-71 B . World Institute Of Technology 8km milestone .Haryana.Sohna Palwal Road . When a different number is assigned a new value the new value supercedes the previous members value.in .code.m). During accessing we should make sure that we are accessing the member whose value is currently stored. Would prodece erroneous result.m code. This is because if only one location is allocated for union variable irrespective of size. For example a statement such as code.78.p=456.net.c are all valid member variables. printf(“%d”.m=456.p code. The compiler allocates a piece of storage that is large enough to access a union member we can use the same syntax that we use to access structure members. this declares a variable code of type union item. That is code.in Website : www. The union contains three members each with a different data type. in .in Website : www. Operations on individual members 1. operations on individual members.UNIT 1 Lecture: 27 Copying and comparing structure variables. Copying and Comparing Structure variables World Institute Of Technology 8km milestone . Contents 1.wit. Copying and Comparing Structure variables 2.net.net. E-mail : info@wit. Gurgaon .Haryana.Sohna . NH-71 B .Sohna Palwal Road . x = ((student3. main() { int x. student3.in Website : www.00}."Reddy".number == (student3. printf("%d %s %f\n".72.number) && student2.marks). if(x == 1) { printf("\nstudent2 and student3 are same\n\n").wit.marks)) ? 1 : 0. E-mail : info@wit. NH-71 B .name. Gurgaon .marks == student2.UNIT 1 structclass { int number. structclass student2 = {222.Sohna . structclass student3. structclass student1 = {111. }. student3.net. student3. Operations on individual members World Institute Of Technology 8km milestone . } else printf("\nstudent2 and student3 are different\n\n").50}. 67.Sohna Palwal Road .net.in . } Output student2 and student3 are same 2. char name[20].number. student3 = student2."Rao". float marks.Haryana. in Website : www.Haryana.net. Gurgaon .wit.net.UNIT 1 World Institute Of Technology 8km milestone . E-mail : [email protected] .Sohna Palwal Road . NH-71 B .in . in .UNIT 1 World Institute Of Technology 8km milestone .Sohna Palwal Road .wit.net. NH-71 B . Gurgaon .net.Haryana.in Website : www. E-mail : [email protected] . UNIT 1 Lecture: 28 & 29 Array of structure. char name[20]. int I. } struct info std[100]. Array of Structure It is possible to define a array of structures for example if we are maintaining information of all the students in the college and if 100 students are studying in the college. #include< stdio.n. Array of Structure 2.Haryana. Structure & sizeof Function 1. Remember that each element is a structure that must be assigned corresponding initial values as illustrated below.in Website : www. An array of structures can be assigned initial values just as any other array can.Sohna Palwal Road . structure with structure. E-mail : [email protected] .wit. } student[100].h > { struct info { int id_no. Gurgaon .net.in . We can define an array of structures as shown in the following example: structure information { int id_no. char name[20]. int age. Size of Structure. Structure with in Structure 3. char address[20]. char combination[3]. We need to use an array than single variables. World Institute Of Technology 8km milestone . NH-71 B . char combination[3]. Contents 1. char address[20]. int age. address.&n).I < n.I++) scanf(%d%s%s%s%d”. // 50 bytes World Institute Of Technology 8km milestone . }.UNIT 1 printf(“Enter the number of students”).&std[I]. NH-71 B .I++) printf(“%d%s%s%s%d\n”. int age. newstudent. In such structures the declaration of the embedded structure must appear before the declarations of other structures.Sohna Palwal Road .// 4 bytes 05 char street[50]. scanf(“%d”.id_no. 3. Gurgaon .Sohna . struct date { int day. char address[20]. the sturucture student constains another structure date as its one of its members.net.in Website : www.std[I]. int month. char combination[3].name.std[I]. structure date doa. struct student { int id_no. char name[20].in .age). }oldstudent. Structure & sizeof Function sizeof is used to get the size of any data types even with any structures.Haryana. } 2. printf(“\n Student information”).id_no.age).name address combination age\m”). Let's take a look at simple program: 01 02 #include <stdio.std[I].std[I]. int year.std[I].name.std[I]. ”. for (I=0. for(I=0. printf(“ Enter Id_no. E-mail : [email protected]< n. structure date def. Structure with in Structure A structure may be defined as a member of another structure.combination.h> 03 04 typedef struct __address{ int house_number.wit.combination.&std[I].net.std[I].std[I].address. E-mail : [email protected]. The syntax is as shown below. Finally you give the name of the variable. 11.Haryana. Understanding Pointers Contents 8.Sohna .UNIT 1 06 int zip_code.net. The asterisk tells the compiler that you are creating a pointer variable.Sohna Palwal Road . So you should be careful when you read the whole structure from file which was written from other programs. Introduction to Address Operator 10. NH-71 B .in Website : www. 15 } You will never get the size of a structure exactly as you think it must be. You start by specifying the type of data stored in the location identified by the pointer. Pointer Declaration 10. Each memory cell in the computer has an address that can be used to access that location so a pointer variable points to a memory location we can access and change the contents of this memory location via the pointer. Pointer Declaration A pointer is a variable that contains the memory location of another variable. World Institute Of Technology 8km milestone . Introduction to Pointers 9. The sizeof function returns the size of structure larger than it is because the compiler pads struct members so that each one can be accessed faster without delays. Gurgaon .in . Introduction to Pointers In c a pointer is a variable that points to or references a memory location in which data is stored. Lecture: 30 Pointers in C: Introduction.// 20 bytes 09 10 } address.//78 bytes in total 11 12 void main() { 13 14 // it returns 80 bytes printf("size of address is %d bytes\n". // 4 bytes 07 08 char country[20].sizeof(address)). And since this is the location of the variable num the value also becomes 45. float *string. 12.in Website : www. /* A program to illustrate pointer declaration*/ main() { int *ptr. ptr). Gurgaon . ptr=∑ printf (“\n Sum is %d\n”.net.wit.Sohna Palwal Road . } We will get the same result by assigning the address of num to a regular(non pointer) variable. E-mail : info@wit. sum=45. While the value of pointer is 21260 the value of sum is 45 however we can assign a value to the pointer * ptr as in *ptr=45. If num is stored in memory 21260 address then the variable ptr has the value 21260. This places the address where num is stores into the variable ptr.Sohna . NH-71 B . this shows how we can change the value of pointer directly using a pointer and the indirection pointer.Haryana. Since the pointer contains the address 21260 the value 45 is placed in that memory location.in .UNIT 1 type * variable name Example: int *ptr. printf (“\n The sum pointer is %d”.net. /* Program to display the contents of the variable their address using pointer variable*/ World Institute Of Technology 8km milestone . int sum. sum). This means place the value 45 in the memory address pointer by the variable ptr. Introduction to Address Operator Once we declare a pointer variable we must point it to something we can do this by assigning to the pointer the address of the variable you want to point as in the following example: ptr=&num. The benefit is that we can also refer to the pointer variable as *ptr the asterisk tells to the computer that we are not interested in the value 21260 but in the value stored in that memory location. allocating a block of memory: Malloc.cptr). NH-71 B . Introduction to Dynamic Memory Allocation In programming we may come across situations where we may have to deal with data.net. *intptr. File Operation Functions in C 18. intptr=&x. ch=’a’. Contents 14.*cptr.Haryana. World Institute Of Technology 8km milestone . The number of data items may change during the executions of a program.h > { int num.Sohna Palwal Road .wit. float x. num=123.*intptr. Allocating a block of Memory: Malloc 15. The number of customers in a queue can increase or decrease during the process at any time. Dynamic data items at run time.intptr). thus optimizing file usage of storage space. cptr=&ch. which is dynamic in nature. Introduction to Dynamic Memory Allocation 15. floptr=&x. x=12. E-mail : info@wit.*floptr. printf(“Character %c stored at address %u\n”.Sohna .in Website : www. Such situations can be handled move easily by using dynamic techniques. Various Functions for purpose of Memory Management 16.net.34.in .floptr). *floptr.UNIT 1 include< stdio. Introduction to file Management 17. printf(“Num %d stored at address %u\n”. printf(“Value %f stored at address %u\n”. Memory Management in C 19. *cptr. Gurgaon . char ch. } Lecture: 37 Dynamic Memory Allocation and File Management in C : Introductoin. Dynamic memory allocation. When the list grows we need to allocate more memory space to accommodate additional data items. Opening a file 3.net.net. Introduction to File management C supports a number of functions that have the ability to perform basic file operations. It becomes cumbersome and time consuming to handle large volumes of data through terminals.UNIT 1 Dynamic memory allocation: The process of allocating memory at run time is known as dynamic memory allocation. File Operation Functions in C World Institute Of Technology 8km milestone . Many languages permit a programmer to specify an array size at run time. which include: 1. 18. NH-71 B .wit. the memory space required by the variables in the program. which can be used to allocate and free memory during the program execution.in Website : www. Reading from a file 4. the console oriented I/O operations pose two major problems.Sohna . The entire data is lost when either the program is terminated or computer is turned off therefore it is necessary to have more flexible approach where data can be stored on the disks and read whenever necessary.Haryana. 17.in . 16. Such languages have the ability to calculate and assign during executions. Although c does not inherently have this facility there are four library routines which allow this function. Gurgaon . Function Task malloc Allocates memory requests size of bytes and returns a pointer to the Ist byte of allocated space calloc Allocates space for an array of elements initializes them to zero and returns a pointer to the memory free Frees previously allocated space realloc Modifies the size of previously allocated space. But c inherently does not have this facility but supports with memory management functions. Writing data into a file 5. Naming a file 2. This method employs the concept of files to store data. E-mail : info@wit. Closing a file Real life situations involve large volume of data and in such cases. without destroying the data.Sohna Palwal Road . Various Functions for purpose of Memory Management The following functions are used in c for purpose of memory management. The malloc function reserves a block of memory of specified size and returns a pointer of type void. Gurgaon .UNIT 1 Function Name Operation fopen() Creates a new file Opens a new existing file for use fclose Closes a file which has been opened for use getc() Reads a character from a file putc() Writes a character to a file fprintf() Writes a set of data values to a file fscanf() Reads a set of data values from a file getw() Reads a integer from a file putw() Writes an integer to the file fseek() Sets the position to a desired point in the file ftell() Gives the current position in the file rewind() Sets the position to the begining of the file for use 19. Therefore it is possible to encounter memory overflow during dynamic allocation process. E-mail : info@wit. The free memory region is called the heap.net.in .in Website : www. It takes the following form: ptr=(cast-type*)malloc(byte-size). Allocating a Block of Memory: Malloc A block mf memory may be allocated using the function malloc. The size of heap keeps changing when program is executed due to creation and death of variables that are local for functions and blocks.Haryana. ptr is a pointer of type cast-type the malloc returns a pointer (of cast type) to an area of memory with size byte-size.Sohna . This means that we can assign it to any type of pointer.net. the memory allocation functions mentioned above will return a null pointer.Sohna Palwal Road . Memory Management in C According to the conceptual view the program instructions and global and static variable in a permanent storage area and local area variables are stored in stacks.wit. The memory space that is located between these two regions in available for dynamic allocation during the execution of the program. Example: World Institute Of Technology 8km milestone . 20. NH-71 B . In such situations. Allocating Multiple Blocks of Memory: Calloc 2.in Website : www.Sohna . The general form of calloc is: ptr=(cast-type*) calloc(n. NH-71 B . Gurgaon .Sohna Palwal Road .elem-size). Releasing the Used Space: Free 3.net. E-mail : info@wit. Allocating Multiple Blocks of Memory: Calloc Calloc is another memory allocation function that is normally used to request multiple blocks of storage each of the same size and then sets all bytes to zero. If there is not enough space a null pointer is returned. Altering the Size of Block: Realloc 4. World Institute Of Technology 8km milestone .net.UNIT 1 x=(int*)malloc(100*sizeof(int)). The above statement allocates contiguous space for n blocks each size of elements size bytes.wit.Haryana. Releasing the used space: Free. Altering the size of Block: Realloc. All bytes are initialized to zero and a pointer to the first byte of the allocated region is returned. Example 1. Lecture: 38 Allocating multiple blocks of memory: Calloc.in . Contents 1. On successful execution of this statement a memory equivalent to 100 times the area of int bytes is reserved and the address of the first byte of memory allocated is assigned to the pointer x of type int. wit. The release of storage space becomes important when the storage is limited. 3. exit(1). 4. The general statement of reallocation of memory is: ptr=realloc(ptr. Example #include< stdio.UNIT 1 2. ptr is a pointer that has been created by using malloc or calloc.Haryana.h > #include< stdlib. /*Allocating memory*/ if((buffer=(char *) malloc(10))==NULL) { printf(“Malloc failed\n”). } World Institute Of Technology 8km milestone . E-mail : info@wit. The allocated new block may be or may not be at the same region. Gurgaon . we may release that block of memory for future use. NH-71 B . This function allocates new memory space of size newsize to the pointer variable ptr ans returns a pointer to the first byte of the memory block. it is our responsibility to release the space when it is not required. free(ptr).net. Altering the Size of Block: Realloc The memory allocated by using calloc or malloc might be insufficient or excess sometimes in both the situations we can change the memory size already allocated with the help of the function realloc. using the free function. Releasing the Used space: Free Compile time storage of a variable is allocated and released by the system in accordance with its storage class.net.h > define NULL 0 main() { char *buffer.Sohna . This process is called reallocation of memory. With the dynamic runtime allocation.in . When we no longer need the data we stored in a block of memory and we do not intend to use that block for storing any other information.newsize).Sohna Palwal Road .in Website : www. /*freeing memory*/ free(buffer).in . Contents Defining and Opening file Closing File Various I/O Operation on files 1.net. printf(“\nBuffer contains:%s\n”.”Bangalore”). World Institute Of Technology 8km milestone .15))==NULL) { printf(“Reallocation failed\n”).Sohna Palwal Road .Haryana.Sohna . They include the fielname.buffer). exit(1). purpose. } Lecture: 39 Defining and opening file. strcpy(buffer. we must specify certain things about the file to the operating system.”Mysore”). Defining and Opening file If we want to store data in a file into the secondary memory. Gurgaon .\n”). printf(“\nBuffer still contains: %s\n”.in Website : www. fp=fopen(“filename”.buffer). closing file & I/O operation on files. printf(“\nBuffer now contains:%s\n”. } printf(“\nBuffer size modified.wit. strcpy(buffer. NH-71 B . /*Reallocation*/ if((buffer=(char *)realloc(buffer. The general format of the function used for opening a file is FILE *fp. E-mail : info@wit. data structure._msize(buffer)).UNIT 1 printf(“Buffer of size %d created \n.”mode”).net.buffer). p1=fopen (“Input”. A open the file for appending data to it. Consider the following statements: FILE *p1. The mode does this job. This pointer. File is a structure that is defined in the I/O Library. it is in the following format. its contents are deleted and the files are opened as a new file. Observe the following program. The second statement also specifies the purpose of opening the file. Gurgaon . …. 2. fclose(p2) The above program opens two files and closes them after all operations on them are completed. *p2.”r”). In these statements the p1 and p2 are created and assigned to open the files data and results respectively the file data is opened for reading and result is opened for writing. E-mail : info@wit. In case the results file already exists. which contains all the information about the file.in Website : www.Haryana. p2=fopen(“results”.Sohna .wit. If data file does not exist error will occur.net. NH-71 B . …. fclose(file_pointer).”r”). FILE *p1 *p2.net.UNIT 1 The first statement declares the variable fp as a pointer to the data type FILE. World Institute Of Technology 8km milestone .in . A file must be closed as soon as all operations on it have been completed. once a file is closed its file pointer can be reversed on other file. This would close the file associated with the file pointer. p1=fopen(“data”.”w”). … fclose(p1). R open the file for read only. The second statement opens the file named filename and assigns an identifier to the FILE type pointer fp.”w”). is subsequently used as a communication link between the system and the program. As stated earlier. p2=fopen (“Output”.Sohna Palwal Road . W open the file for writing only. Closing File The input output library supports the function to close a file. I< 30. to the file input.fp).Haryana. Various I/O Operation on files The getw and putw functions: These are integer-oriented functions. c=getc(fp2). These functions would be usefull when we deal with only integer data. The general forms of getw and putw are: putw(integer.fp1). /*write a character to input*/ fclose(f1).net. similarly getc function is used to read a character from a file that has been open in read mode.c). /*Example program for using getw and putw functions*/ #include< stdio. fclose(f1).”W”). } 3. /*Open the file Input*/ while((c=getchar())!=EOF) /*get a character from key board*/ putc(c.wit.Sohna Palwal Road . /*close the file input*/ printf(“\nData output\n”). printf(“Data input output”).net. f1=fopen(“DATA”. f1=fopen(“INPUT”. E-mail : [email protected] > main() { FILE *f1. The end of the data is indicated by entering an EOF character. #include< stdio.*f2. The program shown below displays use of a file operations. f1=fopen(“Input”.Sohna . /*Reopen the file input*/ while((c=getc(f1))!=EOF) printf(“%c”. printf(“Contents of the data file\n\n”).I++) World Institute Of Technology 8km milestone . They are similar to get c and putc functions and are used to read and write integer values.”w”).f1). which is control-z. NH-71 B .in . The data enter through the keyboard and the program writes it. int number I. The putc function writes the character contained in character variable c to the file associated with the pointer fp1. the file input is closed at this signal.”r”).*f3.h > main() { file *f1.in Website : www. getw(fp). for(I=1. ex putc(c. Character by character. Gurgaon .UNIT 1 The getc and putc functions are analogous to getchar and putchar functions and handle one character at a time. wit.Haryana. printf(“\n\nContents of the odd file\n\n”)./*write to odd file*/ } fclose(f1). if(number==-1) break. World Institute Of Technology 8km milestone .”control string”. constant and string.”w”).number). fclose(f2).%s%d%f”. while(number=getw(f2))!=EOF) printf(“%d%d”.”r”). printf(“\n\nContents of the even file”).net.Sohna Palwal Road . E-mail : info@wit. Where fp id a file pointer associated with a file that has been opened for writing. NH-71 B . while(number=getw(f3))!=EOF) printf(“%d”. The control string is file output specifications list may include variable. The first argument of theses functions is a file pointer which specifies the file to be used.UNIT 1 { scanf(“%d”. list). f2=fopen(“ODD”.7.&number). f1=fopen(“DATA”. fclose(f2). } The fprintf & fscanf functions: The fprintf and scanf functions are identical to printf and scanf functions except that they work on files. fprintf(f1.in Website : www.number). } fclose(f1).”r”).name.”r”). f3=fopen(“EVEN”. fclose(f3). f3=fopen(“EVEN”. while((number=getw(f1))!=EOF)/* Read from data file*/ { if(number%2==0) putw(number. Gurgaon . f2=fopen(“ODD”.f2).in ./*Write to even file*/ else putw(number.net. putw(number. The general form of fprintf is fprintf(fp.age.f1).5).Sohna .f3).”w”). fclose(f3). ”%s%d%f%d%d\n”. for I=1. fp=fopen(filename. /*Program to handle mixed data types*/ #include< stdio.&prince. } World Institute Of Technology 8km milestone .”\n\n”).h > main() { FILE *fp. NH-71 B .quality).Sohna .UNIT 1 Here name is an array variable of type char and age is an The general format of fscanf is fscanf(fp.qty. Gurgaon .Haryana.item. fprintf(stdout.”%s%d%f%d”.in int variable .price.”%s%d%f%d”.item.I++) { fscanf(stdin.&price.I< =3.net. scanf(“%s”.I< =3. This statement would cause the reading of items in the control string. printf(“Item name number price quantity value”).Sohna Palwal Road .&number.item. fscanf also returns the number of items that are successfully read. printf(“Input filename”).”controlstring”.price. printf(“Item namem number price quantity\n”).value). } fclose(fp).wit. for(I=1.itemnumber.&number. value=price*quantity”).&quality).in Website : www.item.”5s%d”.list). printf(“Input inventory data\n\n”0. } fclose (fp).”%s%d%f%d”.value. Example: fscanf(f2. char item[10]. E-mail : info@wit. Like scanf.filename). int num.I++) { fscanf(fp.”r”).”w”). fprintf(“stdout.number.&quantity”).I. fprintf(fp.filename[10].net. float price.&quality). fp=fopen(filename.quantity. The position can take the 3 values. Lecture: 31 Pointers in C: Introduction. Introduction to Pointers 12.UNIT 1 Random access to files: Sometimes it is required to access only a particular part of the and not the complete file. NH-71 B . Fileptr is a pointer to the file concerned. and position in an integer number.net.in . Value Meaning : 0 Beginning of the file 1 Current position 2 End of the file.Haryana.in Website : www. Pointer Declaration 13. Gurgaon . Introduction to Address Operator 13. This function is used to move the file position to a desired location within the file. Offset specifies the number of positions (bytes) to be moved from the location specified bt the position. Understanding Pointers Contents 11.Sohna . E-mail : info@wit. Introduction to Pointers World Institute Of Technology 8km milestone .net.Sohna Palwal Road . This can be accomplished by using the following function: 1 > fseek fseek function: The general format of fseek function is a s follows: fseek(file pointer.wit. position).offset. Offset is a number or variable of type long. Sohna Palwal Road . NH-71 B .wit.Sohna .in .in Website : www.Haryana.UNIT 1 World Institute Of Technology 8km milestone . E-mail : info@wit. Gurgaon .net.net.
Copyright © 2024 DOKUMEN.SITE Inc.