Vous êtes sur la page 1sur 147

UNIT 1

Lecture: 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 informationPerform arithmetic or logical operations on data/ information.
3. Produce outputCommunicate information to the outside world through output
devices like monitor, printer, etc.
4. Store informationStore 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 : info@wit.net.in
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 : info@wit.net.in
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 : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 2
Evaluation of Computers, Hardware organization of a computers.
Contents
1.
2.
3.
4.
5.
6.
7.
8.

Evolution of Computers
Hardware organization of a computers
Input Device
Output Device
CPU
Memory Unit
Control Unit
ALU

1. 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. Having the right tool to perform right has always
been important for human beings. In this post, I have mentioned some important history in the
evolution of computers.
In the beginning, when the task was simply counting or adding, people used either their fingers
or pebbles along lines in the sand in order to simply the process of counting, people in Asia
minor built a counting device called ABACUS, the device allowed users to do calculations using
a system of sliding beads arranged on a rack.
With the passage of time, many computing devices such as Napier bones and slide rule were
invented. It took many centuries for the advancement in computing devices. In 1642, a French
mathematician, Blaise Pascal invented the first functional automatic calculator. The brass
rectangular box also called Pascaline, used eight movable dials to add sums and eight figures
only.
In 1694, german mathematician Gotfried Wilhemvoz Leibniz, extended Pascals design to
perform multiplication, division and to find square root. This machine is known as
stepped reckoner. The only problem with this device that it lacked mechanical precision in
its construction and was not reliable.
The real beginning computer was made by an English mathematician Charles Babbage in 1822.
He proposed a engine to perform difference equations, called a difference engine. It would print
results automatically. However, Babbage never quite made a fully functional difference engine,
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

and in 1833, he quit working on it to concentrate on analytical engine. 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,000 numbers up to 50 decimal digits long. It also contained a controlled
unit that allowed processing instructions at any sequence, output device to produce printed
results. Babbage borrowed the idea of punch cards to encode the instructions in
the machine from the Joseph Marie jacquards loom.

A computer as shown in Fig. performs basically five major operations or functions irrespective
of their size and make. 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 ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

4) It gives results in the form of output


5) It controls all operations inside a computer.
2. Hardware Organization of Computer
All general purpose computers require the following hardware components:
(i)
Central Processing Unit (CPU): The brain of the computer, the component that
actually executes instructions.
(ii)

Memory : It enables a computer to store, at least temporarily, data and programs.

(iii) Input device : Usually a keyboard or mouse is used to read data and programs into the
computer.
(iv)
Output device: A display screen, printer, etc. that lets you see what the computer has
accomplished.
(v)
Mass storage device: It allows a computer to permanently store large amounts of data.
Common mass storage devices include disk drive and tape drive.
In addition to these components, many others make it possible for the basic components of a
computer to work together efficiently.
Objectives
After going through this lesson, you will be in a position to:

identify the basic components of a computer and their working.

explain the importance of various units of a computer .

learn how these units work together to accomplish a given job .


3. Input Device

An input device presents data to the processing unit in a machine-readable form.


Although the keyboard is a common input device for a small computer, a system may also
support various other input devices such as Optical Character Recognition (OCR), Magnetic
Ink Character Recognition (MICR), mark sense reader, etc.
4. Output Device
Output devices receive information from the CPU and present it to the user in the desired
form. Output devices include display screen, loudspeakers, printers, plotters, etc.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

5. CPU
This part of the computer that executes program instructions is known as the processor or
Central Processing Unit (CPU). In a microcomputer, the CPU is based on a single electronic
component, the microprocessor chip, within the system unit or system cabinet. The system
unit also includes circuit boards, memory chips, ports and other components. A
microcomputers system cabinet will also house disk drives, hard disks, etc., but these are
considered separate from the CPU.
The CPU has two parts The Control Unit (CU) and the Arithmetic Logic Unit (ALU). In a
microcomputer, both are on a single microprocessor chip.
6. Memory Unit
Memory - also known as the primary storage or main memory - is a part of the
microcomputer that holds data and instructions.
Part of the contents of the memory is held only temporarily, that is, it is stored only as long
as the microcomputer is turned on. When you turn the machine off, the contents are lost.
The capacity of the memory to hold data and program instructions varies in different
computers. The original IBM PC could hold approximately several thousand characters of
data or instructions only. But modern microcomputers can hold millions or even billions of
characters in their memory.
7. Control Unit
The control unit tells the rest of the computer system how to carry out a programs
instructions. It directs the movement of electronic signals between memory - which
temporarily holds data, instructions and processes information - and the ALU. It also
directs these control signals between the CPU and input/output devices.
8. ALU
Arithmetic Logic Unit, usually called the ALU, performs two types of operations arithmetical and logical. Arithmetical operations are the fundamental mathematical
operations consisting of addition, subtraction, multiplication and division. Logical
operations consist of comparisons. That is two pieces of data are compared to see whether
one is equal to, less than, or greater than the other.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 3
Introduction to Microprocessor, Generation of Microprocessor
Contents
6. Introduction to Microprocessor
7. Generation of Microprocessor
P1 (086) First-Generation Processors
8088 and 8086 Processors
80186 and 80188 Processors
8087 Coprocessor
6. Introduction to Microprocessor

Intel 4004, the first general-purpose, commercial microprocessor

Microprocessor incorporates most or all of the functions of a computer's central


processing unit (CPU) on a single integrated circuit (IC, or microchip). The first
microprocessors emerged in the early 1970s and were used for electronic calculators,
using binary-coded decimal (BCD) arithmetic on 4-bit words. Other embedded uses
of 4-bit and 8-bit microprocessors, such as terminals, printers, various kinds of
automation etc., followed soon after. Affordable 8-bit microprocessors with 16-bit
addressing also led to the first general-purpose microcomputers from the mid-1970s
on.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

During the 1960s, computer processors were often constructed out of small and medium-scale
ICs containing from tens to a few hundred transistors. The integration of a whole CPU onto a
single chip greatly reduced the cost of processing power. From these humble beginnings,
continued increases in microprocessor capacity have rendered other forms of computers almost
completely obsolete (see history of computing hardware), with one or more microprocessors
used in everything from the smallest embedded systems and handheld devices to the largest
mainframes and supercomputers.
Since the early 1970s, the increase in capacity of microprocessors has been a consequence of
Moore's Law, which suggests that the number of transistors that can be fitted onto a chip doubles
every two years. Although originally calculated as a doubling every year, Moore later refined the
period to two years. It is often incorrectly quoted as a doubling of transistors every 18 months.

7. Generation of Microprocessor
Each generation of computer is characterized by a major technological development
that fundamentally changed the way computers operate, resulting in increasingly
smaller, cheaper, more powerful and more efficient and reliable devices.
P1 (086) First-Generation Processors
The first generation of processors represents the series of chips from Intel that were
found in the first PCs. IBM, as the architect of the PC at the time, chose Intel processors and
support chips to build the PC motherboard, 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.
The 8086 was one of the first 16-bit processor chips on the market; at the time virtually all other
processors were 8-bit designs. The 8086 had 16-bit internal registers and could run a new class
of software using 16-bit instructions. It also had a 16-bit external data path, which meant it could
transfer data to memory 16 bits at a time.
The address bus was 20 bits wide, meaning that the 8086 could address a full 1MB (220) of
memory. This was in stark contrast to most other chips of that time that had 8-bit internal
registers, an 8-bit external data bus, and a 16-bit address bus allowing a maximum of only 64KB
of RAM (216).
Unfortunately, most of the personal computer world at the time was using 8-bit processors,
which ran 8-bit CP/M (Control Program for Microprocessors) operating systems and software.
The board and circuit designs at the time were largely 8-bit as well. Building a full 16-bit
motherboard and memory system would be costly, pricing such a computer out of the market.
The cost was high because the 8086 needed a 16-bit data bus rather than a less expensive 8-bit
bus. Systems available at that time were 8-bit, 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. In response,
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Intel introduced a kind of crippled version of the 8086, called the 8088. The 8088 essentially
deleted 8 of the 16 bits on the data bus, making the 8088 an 8-bit chip as far as data input and
output were concerned. However, because it retained the full 16-bit internal registers and the 20bit address bus, the 8088 ran 16-bit software and was capable of addressing a full 1MB of RAM.
For these reasons, IBM selected the 8-bit 8088 chip for the original IBM PC. Years later, IBM
was criticized for using the 8-bit 8088 instead of the 16-bit 8086. In retrospect, it was a very wise
decision. IBM even covered up the physical design in its ads, which at the time indicated its new
PC had a "high-speed 16-bit microprocessor." IBM could say that because the 8088 still ran the
same powerful 16-bit software the 8086 ran, just a little more slowly. In fact, 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. This allowed IBM to deliver a PC capable of running a
new generation of 16-bit software, while retaining a much less expensive 8-bit design for the
hardware. Because of this, the IBM PC was actually priced less at its introduction than the most
popular PC of the time, the Apple II. For the trivia buffs out there, the IBM PC listed for $1,265
and included only 16KB of RAM, while a similarly configured Apple II cost $1,355.
The original IBM PC used the Intel 8088. The 8088 was introduced in June 1979, but the IBM
PC did not appear until August 1981. Back then, there was often a significant lag time between
the introduction of a new processor and systems that incorporated it. That is unlike today, when
new processors and systems using them are often released on the same day.
The 8088 in the IBM PC ran at 4.77MHz, or 4,770,000 cycles (essentially computer heartbeats)
per second. Each cycle represents a unit of time to the system, with different instructions or
operations requiring one or more cycles to complete. The average instruction on the 8088 took
12 cycles to complete.
Computer users sometimes wonder why a 640KB conventional-memory barrier exists if the 8088
chip can address 1MB of memory. The conventional-memory barrier exists because IBM
reserved 384KB of the upper portion of the 1,024KB (1MB) address space of the 8088 for use by
adapter cards and system BIOS. The lower 640KB is the conventional memory in which DOS
and software applications execute.
80186 and 80188 Processors
After Intel produced the 8086 and 8088 chips, it turned its sights toward producing a
more powerful chip with an increased instruction set. The company's first efforts along this
linethe 80186 and 80188were unsuccessful. But incorporating system components into the
CPU chip was an important idea for Intel because it led to faster, better chips, such as the 286.
The relationship between the 80186 and 80188 is the same as that of the 8086 and 8088; one is a
slightly more advanced version of the other. Compared CPU to CPU, the 80186 is almost the
same as the 8088 and has a full 16-bit design. The 80188 (like the 8088) is a hybrid chip that
compromises the 16-bit design with an 8-bit external communications interface. The advantage
of the 80186 and 80188 is that they combine on a single chip 15 to 20 of the 80868088 series
system componentsa fact that can greatly reduce the number of components in a computer
design. The 80186 and 80188 chips were used for highly intelligent peripheral adapter cards of
that age, such as network adapters.
8087 Coprocessor
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Intel introduced the 8086 processor in 1976. The math coprocessor that was paired
with the chipthe 8087often was called the numeric data processor (NDP), the math
coprocessor, or simply the math chip. The 8087 is designed to perform high-level math
operations at many times the speed of the main processor. The primary advantage of using this
chip is the increased execution speed in number-crunching programs, such as spreadsheet
applications.

Lecture: 4
Commonly used CPUs, Input/output devices.
Contents
9. Introduction to CPU
10. CPU Registers
11. Input Devices
12. Output Devices
9. Introduction to CPU

The central processing unit (CPU) is the portion of a computer system that carries out the
instructions of a computer program, and is the primary element carrying out the computer's
functions. The central processing unit carries out each instruction of the program in sequence, to
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

perform the basic arithmetical, logical, and input/output operations of the system. This term has
been in use in the computer industry at least since the early 1960s.[1] The form, design and
implementation of CPUs have changed dramatically since the earliest examples, but their
fundamental operation remains much the same.
Early CPUs were custom-designed as a part of a larger, sometimes one-of-a-kind, computer.
However, 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. 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). The IC has allowed increasingly complex CPUs to be designed and manufactured to
tolerances on the order of nanometers. 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. Modern microprocessors appear in everything
from automobiles to cell phones and children's toys.

10. CPU Registers


EAX: Arithmetic operations, I/O port access and interrupt call
EDX: Arithmetic operations, I/O port access and interrupt call. If you have a multiplication
operation which results in more than what a single register can handle, 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. Also used for "this" pointer for a class
EIP: Instruction pointer. Points to the next instruction to execute.
ESP: Stack pointer. This points to the top of the stack.
EBP: Base/Frame pointer.
11. 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. An output device reverses the process,
translating the digitized signals into a form intelligible to the user. At one time punched-card and
paper-tape readers were extensively used for inputting, but these have now been supplanted by
more efficient devices.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Input devices include typewriter-like keyboards; hand-held devices such as the mouse, trackball,
joystick, and special pen with pressure-sensitive pad; and microphones. They also include
sensors that provide information about their environmenttemperature, pressure, and so forth
to a computer. Another direct-entry mechanism is the optical laser scanner (e.g., scanners used
with point-of-sale terminals in retail stores) that can read bar-coded data or optical character
fonts. Output equipment includes video display terminals (either cathode-ray tubes or liquid
crystal displays), ink-jet and laser printers, loudspeakers, and devices such as flow valves that
control machinery, often in response to computer processing of sensor input data. Some devices,
such as video display terminals, may provide both input and output. Other examples are devices
that enable the transmission and reception of data between computerse.g., modems and
network interfaces. Most auxiliary storage devicesas, for example, magnetic tape, magnetic
disk drives, and certain types of optical compact discsalso double as input/output devices
Various standards for connecting peripherals to computers exist. For example, integrated drive
electronics (IDE) and enhanced integrated drive electronics (EIDE) are common interfaces, or
buses, for magnetic disk drives. A bus (also known as a port) can be either serial or parallel,
depending on whether the data path carries one bit at a time (serial) or many at once (parallel).
Serial connections, which use relatively few wires, are generally simpler and slower than parallel
connections. Universal serial bus (USB) is a common serial bus. A common example of a
parallel bus is the small computer systems interface, or SCSI, bus.
Keyboards and mice no longer have to be wired to the computer. Wireless versions can be
connected to the computer by using infrared beams, provided there is a clear line of sight
between the device and the infrared port on the computer. Since a laptop may be used in a
confined space, alternate pointing devices such as a trackball, touchpad, or pointing stick are
usually provided. However, some users prefer to connect an external mouse to their laptop
computers, thereby bypassing these alternatives. Even some computer display screens can be
used as input devices. Touch screens can be found at an ATM or a kiosk, 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 ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

There is an assortment of optical devices. Digital cameras are replacing conventional film
cameras. One no longer has to wait for film to be developed. State-of-the-art digital cameras now
store pictures internally in chips, on special memory strips, or on disks. Some cameras have an
LCD on which pictures can be previewed. Once image files have been transferred to a computer
by a wire connection or by disk, they can be edited and printed. The quality of the final picture
depends on both the quality of the paper and printer. Digital images do not have to be printed.
They can easily be posted to a Web site or e-mailed to friend or relative. Some of the images
used in these Lecture Notes were taken with a digital camera.
There are several different types of scanners. An MICR scans and reads the magnetic markings
at the bottom of a check that represents information about the bank, the account, the check
number, and once written, the amount of the check.
Most likely, you have used a pencil to take a test or to complete a form that is then scanned and
interpreted by an optical scanner. Many states are using optical recognition to read and process
handwritten income tax forms, and retail store salespeople use handheld wand readers to read
sales tags on store merchandise. The United States Postal Service has funded millions of dollars
in grants in an attempt to develop systems that can read cursive handwriting. Like other
peripheral devices, the prices for personal computer scanners have decreased dramatically over
the past few years. Perhaps you have scanned an image into a computer and used it as wallpaper,
or scanned and converted text from a page into a word processing document using OCR
software. Several years ago the food industry began to use unique bar codes called the UPC
(Universal Product Code) to identify specific products. Other "industries" also use bar codes.
Although the codes are different from those used in supermarkets, each book in my campus
library contains a bar code and so does each faculty/staff/students' identification card. 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, selected by pointing or
clicking, and visualized by scanners and cameras. There is one final method of inputting data,
and that is by voice. Using a microphone and appropriate software, you can use your voice to
enter commands or dictate words. One of the challenges to voice input is speech recognition.
Early speech recognition software required users to speak discrete words. That is, they had to
briefly pause between each word as they spoke. Newer speech recognition software, know as
continuous word systems, allow users to speak at a natural pace. Users are able to speak at a
faster rate due to software advances and increased processor speeds that interpret what is being
spoken. One of my colleagues is a professor, an artist, and a designer and uses a computer for her
professional and creative activities. Although physically challenged, she uses her voice to
command the computer, dictate documents, and draw pictures. We will now turn our attention to
output devices.
12. Output Devices

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Output devices receive information from the CPU and present it to the user in the desired
form. Output devices include display screen, loudspeakers, printers, plotters, etc.
Softcopy
The traditional output device for personal computers has been the CRT monitor. Originally they
were only available in monochrome, but today most monitors are now color. The size and quality
of the display are a function of the monitor and video adapter to which they are connected. Like
televisions, the size of a monitor is determined by a diagonal measurement of the screen. A few
years ago, several computer companies were sued because of misleading advertisements. They
measured from corner to corner of the screen instead of the portion of the screen that could
actually be used.
Subsequently, descriptions now include the "viewable" measurement, so a typical advertisement
will mention a 17" monitor with 16" viewable. Quality of the display is determined by several
factors.
1. The number of horizontal and vertical pixels. Typical low resolution would be 640 by
480, while a high resolution can be 1600 by 1200.
2. The dot pitch, which is the distance between pixels. This can vary from .15 mm to .30 m.
3. The color depth, which refers to the number of colors. Typically this can range from 256
colors to 16.7 million colors.
As one would expect, a higher quality video card and monitor will correspondingly have a higher
price. As shown below, if you are using a Windows-based computer, you can find (and change)
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

information about your graphics card and monitor settings by right-clicking on the background,
selecting Properties, and then select the Settings tab

Obviously a CRT monitor is not a good choice for a portable computer display device. Using the
same flat-panel technology that is typically found in wristwatches and calculators, laptop
computers use an LCD, and like their CRT "cousins", better visual quality carries a higher price
tag. Only recently have flat-panel displays been available for both Wintel and Macintosh desktop
computers. Unlike CRT monitors that get deeper as they get wider, LCD panels remain very thin.
Unfortunately, this small footprint carries a large price tag.
As previously mentioned, sound played through speakers is another example of softcopy output.
Just as monitors require a video card to create and display visual output, speakers require an
audio card to create and produce auditory output. This sound can be previously recorded or a
synthesized voice, recorded sound effects, recorded vocal/ instrumental music, or synthesized
instrumental music. With the proper hardware and software, a human voice can be recorded and
then played back. This is useful if the number of spoken words is small. For example, how many
words are needed to speak all of the zip codes used in the United States? Since we "spell" zip
codes, only ten words are needed! That is, 14372 is spoken as "one-four-three-seven-two"
instead of "fourteen thousand three hundred seventy-two." When large numbers of words are
needed, then a human voice is synthesized. Depending on the system, these voices range from
nearly perfect speaking to mechanical robot-like speech. An example of such a system would be
a speaker used in conjunction with "vocalizer" software. A visually impaired user could use this
software to read the text that appears in a document that is displayed on a monitor. Just as human
words can be synthesized, so can instrumental music. Using a MIDI device, most often in the
form of a musical keyboard connected to a computer, instrumental musical sounds can be created
and stored. These instrumental sounds are not recorded, but information such as the note,
duration, and "voice" (piano, saxophone, etc.) is stored as a file. MIDI files can be thought of as
a recording of the sheet music instead of the actual instrument playing. Consequently, MIDI files
are considerably smaller than recorded ones. When played back, the musical sound of the
instrument is synthesized by the sound card and sent to the speakers. There are some additional
input and output devices that are used in the production and presentation of multimedia, and they
will be discussed in a later chapter.
Hardcopy
Printers are subdivided into impact and non-impact categories. When microcomputers were first
available, the traditional hardcopy output device for personal and large-scale computers was a
dot-matrix printer. These printers had a small print head that contained an arrangement (matrix)
of one or more columns of small wires or pins. These pins would form the various printable
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

characters. Shown below is a one-column 7-pin head (the pins are much closer than indicated in
the figure), a printed letter, and a magnified view of the letter showing the dots that created it.

Since dot-matrix printers are impact printers (small pins striking a ribbon and paper), they tend to
be noisy, and their quality is marginal. Although rarely used with new personal computers, they
re still popular with businesses that need the ability to produce multiple copies of forms or
similar output.
The two most popular non-impact printers for personal computers are the laser and inkjet
printers. The printer speed of laser printers used with home computers generally print around 8 to
10 ppm, and the quality of print is between 600 and 1200 dpi. For comparison, a dot matrix
printer prints at 75-100 dpi, and a large organization may have an expensive, high-volume laser
printer that prints 1,000 ppm. Low cost black and white laser printers for use with personal
computers can be purchased for a few hundred dollars. Inkjet printers, which spray ink from
multiple nozzles, are available in both black and white and color models. Although most of
today's inkjets are capable of printing in color, they have much slower print rates typically 2-6
ppm and lower resolution 300-600 dpi. Although laser printers have a higher initial cost than
inkjet printers, they cost less per page to print hardcopies. Because of its ability to print in color,
and despite the lesser speed and quality and higher printing cost, the inkjet is still the most
popular printer used with personal computers.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 5
Input/output ports and connectors.
Contents
1. Input/output Ports
2. Connectors
3. Types of Connectors
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

1. Input/output Ports
This is the standard input and output facilities in Isis. Input from and output to any endpoint
is handled using the same mechanism known as a port, which allows the same procedures to
be used for reading, writing, and other operations, regardless of where the data is coming
from or going to. You can create ports that connect to disk files, memory buffers, internet
sites, multicast networks, or serial ports, just to name a few.
In Isis, a port is represented as a list of several items, which includes the port type, internal
identity information, and the procedures used to operate on the port. It will usually not be
necessary to look at anything in this list, and of course, nothing in the list should ever be
modified manually. Use only the port manipulation routines described below.

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. Whatever you type on your keyboard is available for reading from the default input
port, and whatever you write to the default output port appears on your screen. Technically,
the default input port and output ports refer to the "standard input" and "standard output" files
of the Isis process.
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, the print function
prints messages to the current output port). current-input-port and current-output-port allow
you to find out what the current input and output ports are. When Isis is started, the current
input and output ports are the same as the default input and output ports, but you can change
them using set-input-port and set-output-port.

Opening ports
(open-input filename)

# open a disk file for input

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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, open-output, and open-update open a disk file for reading, writing, or both. A
port is returned, or Null if there was a problem accessing the file.
(set iport (open-input "inputfile.dat"))
(set oport (open-output "outputfile.dat"))
new-string-port creates a port that points to a specified string (which is copied into a memory
buffer), and new-memory-port creates a port that points directly to a buffer in memory. A
string name is expected for each, to be used for identification and in error messages. newmemory-port expects the size of the memory buffer in bytes, the address of the buffer, and a
boolean freeflag indicating whether the buffer should be automatically freed when the port is
closed. Both routines return the newly created port, valid for reading or writing.
(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, you may open ports to TCP connections, serial
ports, multicast networks, unix pipes, and other devices. Descriptions of these ports appears
in other sections of the documentation.

Closing ports
(close port)
# close port and deallocate associated resources
When a port is no longer needed, it should be closed so that resources associated with the
port may be reclaimed.

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 ...) # write values in human readable format
(write port val val ...)
# write CODED Isis values
(write-raw port numbytes address) # write raw bytes from memory address
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

(read-string)
(print val val ...)

# 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, coded Isis
values, and raw bytes. There is a separate pair of read and write functions for each format. If
data is written in one format, it should usually be read back with the corresponding read
function for the same format.
Read-string and write-string read and write human-readable strings. read-string reads
characters from the port up to the next newline character and returns a string (without the
newline in it), or Null if no more data is available. write-string writes one or more strings,
characters, and other Isis values in a human-readable format, and returns the total number of
bytes written to the port, 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,
and a newline character must be given explicitly if it is desired.
(set oport (open-output "test.txt"))
(write-string oport "The number of the day is: " (random) newline)
(write-string oport "Thank you and goodbye." newline)
(close oport)
(set iport (open-input "test.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. These routines are most useful for sending and receiving Isis values
over a network or in disk files, where other programs will not have to access the data. Any
type of value except procedures and addresses may be read or written. read reads one value
from the given port and returns it, or Null if no more data is available. write writes one or
more values to the given port, and returns the total number of bytes written, or Null if an
error occurred. A description of the protocol used in coding values can be obtained from
Stefan.
(set oport (open-output "test.data"))
(write oport (random) (random) (random))
(close oport)
(set iport (open-input "test.data"))
(print "The three secret numbers are: "
(read iport) (read iport) (read iport) newline)
(close iport)
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Read-raw and write-raw receive and transmit blocks of raw data in memory buffers. Each
expects the port, an integer number of bytes, and the address of the memory buffer. Each also
returns the total number of bytes read or written, or Null if an error occurred. These functions
are most useful for transfering large blocks of raw data, like images or audio, in the most
time and space efficient manner.
(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.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.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, it reads a string from the current input port
(usually the keyboard). Similarly, the print function prints values to the current output port
(usually the screen). 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. See above for more
information about how to query or change the current input and output ports.
(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, or Null if it is not known or if there is an error. seek sets the current read/write position.
It returns True if successful, and False if not.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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 otherwise.
If a second argument is given, the function waits up to the specified number of microseconds,
and returns immediately with True if data is pending, or False if the time limit was reached.
read-ready is exactly the same as pending.
write-ready performs the converse operation for writing. It returns True if the port is ready to
accept data, or False if not or if the optional time limit has been reached. This routine is
typically useful to prevent a program from blocking when, in TCP networking applications
for example, 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. 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, return string


# read entire port, return string

(read-data port numbytes)


(read-all-data port)

# read up to numbytes, return [buf len]


# read entire port, return [buf len]

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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.
Both functions return Null if there is an error.
read-data and read-all-data are similar, except they read raw data. The return value is a list of
two items: the address of a newly-allocated memory buffer, and an integer indicating the
number of bytes stored in that buffer (which may be smaller than the number of bytes
requested). You are responsible for deallocating the memory buffer when you no longer need
it. If there is an error, the returned number of bytes will be 0.
transfer-data and transfer-all-data read bytes from one port and write them to another. The
number of bytes actually transferred is returned, or 0 if there was an error.
(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, port name
port-type
# string, port type
port-inflag
# boolean, input enabled on port?
port-outflag
# boolean, output enabled on port?
port-internal-id
# internal id of port, 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 ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

These constants represent indices in the port descriptor list that you can use to get certain
information about a port. The most useful item to most users is the probably the name of the
port, which you can obtain by indexing into the port list with port-name.
-> ((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. name and type should be strings. inflag and outflag should be
booleans that indicate whether the port will support input or output or both. internal-id can be
any value that you want to use as an internal identifier to the port. The rest of the arguments
will be the procedures that are used to manipulate the port. The procedures that you design
for the port should be defined in the following way, where id will be the internal-id that you
specify in new-port:
(close id)
# close and free resources, return True if successful
(read id n addr)
# read n bytes into addr, return num bytes actually read
(readline id n addr stopval) # read n bytes or up to stopval, return num bytes actually read
(write id n addr)
# write n bytes from addr, return num bytes actually written
(tell id)
# return current read/write position, or Null if N/A
(seek id pos)
# set current read/write position, 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 ...) # perform user-defined operations
For example, below is the definition of new-memory-port, which uses new-port to create a
new port. 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. Talk to
Stefan for more information on creating new types of ports.
(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 ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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 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 (- 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 ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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 : info@wit.net.in
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 : info@wit.net.in
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 : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Operating System Basics: Introduction to Operating system, Functions of an Operating


system, Types of an Operating Systems.
Contents
1.
2.
3.
4.
5.

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. Introduction to Operating System


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.
2. 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, such as a printer, video card, sound card or CD ROM drive. It
translates commands from the operating system or user into commands understood by
the the component computer part it interfaces with. It also translates responses from
the component computer part back to responses that can be understood by the
operating system, application program, or user. The below diagram gives a graphical
depiction of the interfaces between the operating system and the computer
component.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

3. Functions of an 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.
4. Operating System Concerns
As mentioned previously, an operating system is a computer program. Operating systems are
written by human programmers who make mistakes. Therefore there can be errors in the code
even though there may be some testing before the product is released. 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. Errors in operating systems cause three main types of
problems:
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

System crashes and instabilities - These can happen due to a software bug typically in the
operating system, although computer programs being run on the operating system can
make the system more unstable or may even crash the system by themselves. This varies
depending on the type of operating system. A system crash is the act of a system freezing
and becoming unresponsive which would cause the user to need to reboot.
Security flaws - Some software errors leave a door open for the system to be broken into
by unauthorized intruders. As these flaws are discovered, unauthorized intruders may try
to use these to gain illegal access to your system. Patching these flaws often will help
keep your computer system secure. How this is done will be explained later.
Sometimes errors in the operating system will cause the computer not to work correctly
with some peripheral devices such as printers.
5. Types of an 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 - An 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 : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 7
Basic introduction to DOS, UNIX/LINUX OS, Windows XP.
Contents
1.
2.
3.
4.
5.
6.

Introduction to DOS
Basic DOS Commands
Introduction to UNIX OS
Introduction to LINUX OS
Basic UNIX/LINUX Commands
Introduction to Windows XP

1. Introduction to DOS
This is about the family of operating systems for IBM PC-compatible computers. For other
uses, see DOS (disambiguation). DOS, short for "Disk Operating System", is an acronym for
several closely related operating systems that dominated the IBM PC compatible market
between 1981 and 1995, or until about 2000 if one includes the partially DOS-based
Microsoft Windows versions 95, 98, and Millennium Edition. Related systems include MSDOS, PC-DOS, DR-DOS, FreeDOS, PTS-DOS, ROM-DOS, JM-OS, and several others. In
spite of the common usage, none of these systems were simply named "DOS" (a name given
only to an unrelated IBM mainframe operating system in the 1960s). A number of unrelated,
non-x86 microcomputer disk operating systems had "DOS" in their name, and are often
referred to simply as "DOS" when discussing machines that use them (e.g. AmigaDOS,
AMSDOS, ANDOS, Apple DOS, Atari DOS, Commodore DOS, CSI-DOS, ProDOS, and
TRS-DOS). While providing many of the same operating system functions for their
respective computer systems, programs running under any one of these operating systems
would not run under others.
2. Basic DOS Commands
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
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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 : info@wit.net.in
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 : info@wit.net.in
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 : info@wit.net.in
Website : www.wit.net.in

UNIT 1

SST uses a similar scheme of wild cards to abbreviate variable names.


Listing the contents of a file on the monitor
To display the contents of a text file on the monitor, you can use the DOS type command which
has the following syntax:
A>type filename
As always, if the filename is not preceded by a drive specification, DOS assumes the file is on
the default drive. To type a file on the A drive, use instead:
B>type a:filename
Not all files in DOS are textfiles. Files with the extension `.exe' or `.com' are executable
programs stored in a binary format which cannot be typed.
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 stop scrolling, press the <Ctrl> and the <Scroll Lock> keys simultaneously. To restart
output, press the <Ctrl> and <Scroll Lock> keys again.
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, depress the <shift arrow> and <PrtSc> keys simultaneously, and DOS
will send a copy of what is on the screen to your printer. If you want to obtain a printed copy of
the rest of your computer session, depress the <Ctrl> and <PrtSc> keys simultaneously. Further
output will be sent to the printer as it appears on the screen. To stop printing depress these keys
again.
Subdirectories
DOS allows you to organize disks into subdirectories--groupings of files in a tree structure. For
most purposes a subdirectory on a disk is used as if it were a separate disk.
To create a subdirectory named sst, type:
C>mkdir sst
The subdirectory sst now exists. There are two ways to access files in the subdirectory. First, you
can make the subdirectory the default directory in the same way that you make a disk drive the
default drive. This is done by changing directories:
C>cd sst
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

You are now located within the sst subdirectory. To obtain a listing of files in the sst
subdirectory, give the command:
C>dir
Unless you specify otherwise, 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. To return to the main (or root) directory, give the command:
C>cd \
The backslash (`\') is DOS's symbol for the top directory.
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. If you are in the root directory and you would like to see the
contents of a file in the sst subdirectory, try:
C>type sst\filename
Thus, it is not necessary to change directories to access a file in another directory.
DOS allows you to create subdirectories in subdirectories so directory structures can become
rather complicated. We do not recommend this practice if you are a newcomer to DOS. For the
purposes of this manual we will assume that you do not have subdirectories to subdirectories.
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. If you type:
C>path \;\sst
DOS will search the root directory (\) and the sst subdirectory (\sst) when it looks for programs
to execute. With the above path command, it is possible to execute sst, for example, without
being located in the sst subdirectory.
3. Introduction to UNIX OS
Unix operating systems are widely used in servers, workstations, and mobile devices. The
Unix environment and the clientserver 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.
Both Unix and the C programming language were developed by AT&T and distributed to
government and academic institutions, which led to both being ported to a wider variety of
machine families than any other operating system. As a result, Unix became synonymous
with "open systems".
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Unix was designed to be portable, multi-tasking and multi-user in a time-sharing


configuration. Unix systems are characterized by various concepts: the use of plain text for
storing data; a hierarchical file system; treating devices and certain types of inter-process
communication (IPC) as files; and the use of a large number of software tools, small
programs that can be strung together through a command line interpreter using pipes, as
opposed to using a single monolithic program that includes all of the same functionality.
These concepts are collectively known as the Unix philosophy.
Under Unix, the "operating system" consists of many of these utilities along with the master
control program, the kernel. The kernel provides services to start and stop programs, handles
the file system and other common "low level" tasks that most programs share, and, perhaps
most importantly, schedules access to hardware to avoid conflicts if two programs try to
access the same resource or device simultaneously. To mediate such access, the kernel was
given special rights on the system, leading to the division between user-space and kernelspace.
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. In an
era when a "normal" computer consisted of a hard disk for storage and a data terminal for
input and output (I/O), the Unix file model worked quite well as most I/O was "linear".
However, modern systems include networking and other new devices. As graphical user
interfaces developed, the file model proved inadequate to the task of handling asynchronous
events such as those generated by a mouse, and in the 1980s non-blocking I/O and the set of
inter-process communication mechanisms was augmented (sockets, shared memory, message
queues, semaphores), and functionalities such as network protocols were moved out of the
kernel.
4. Introduction to LINUX OS
Linux refers to the family of Unix-like computer operating systems using the Linux kernel.
Linux can be installed on a wide variety of computer hardware, ranging from mobile phones,
tablet computers and video game consoles, to mainframes and supercomputers. Linux is a
leading server operating system, and runs the 10 fastest supercomputers in the world.
The development of Linux is one of the most prominent examples of free and open source
software collaboration; typically all the underlying source code can be used, freely modified,
and redistributed, both commercially and non-commercially, by anyone under licenses such
as the GNU General Public License. Typically Linux is packaged in a format known as a
Linux distribution for desktop and server use. Some popular mainstream Linux distributions
include Debian (and its derivatives such as Ubuntu), Fedora and openSUSE. Linux
distributions include the Linux kernel and supporting utilities and libraries to fulfill the
distribution's intended use.
A distribution oriented toward desktop use may include the X Window System, 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. A
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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. Because Linux is freely redistributable, it is possible for anyone
to create a distribution for any intended use. Commonly used applications with desktop
Linux systems include the Mozilla Firefox web-browser, the OpenOffice.org office
application suite and the GIMP image editor.
The name "Linux" comes from the Linux kernel, originally written in 1991 by Linus
Torvalds. 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.
5. Basic UNIX/LINUX Commands
Files

ls --- lists your files


ls -l --- lists your files in 'long format', which contains lots of useful information, e.g. the
exact size of the file, who owns the file and who has the right to look at it, and when it
was last modified.
ls -a --- lists all files, including the ones whose filenames begin in a dot, which you do
not always want to see.
There are many more options, for example to list files by size, by date, recursively etc.
more filename --- shows the first part of a file, just as much as will fit on one screen. Just
hit the space bar to see more or q to quit. You can use /pattern to search for a pattern.
emacs filename --- is an editor that lets you create and edit a file. See the emacs page.
mv filename1 filename2 --- moves a file (i.e. gives it a different name, or moves it into a
different directory (see below)
cp filename1 filename2 --- copies a file
rm filename --- removes a file. It is wise to use the option rm -i, which will ask you for
confirmation before actually deleting anything. You can make this your default by
making an alias in your .cshrc file.
diff filename1 filename2 --- compares files, and shows where they differ
wc filename --- tells you how many lines, words, and characters there are in a file
chmod options filename --- lets you change the read, write, and execute permissions on
your files. The default is that only you can look at them and change them, but you may
sometimes want to change these permissions. For example, chmod o+r filename will
make the file readable for everyone, and chmod o-r filename will make it unreadable for
others again. Note that for someone to be able to actually look at the file the directories it
is in need to be at least executable. See help protection for more details.
File Compression
o gzip filename --- compresses files, so that they take up much less space. Usually
text files compress to about half their original size, but it depends very much on
the size of the file and the nature of the contents. There are other tools for this
purpose, too (e.g. compress), but gzip usually gives the highest compression rate.
Gzip produces files with the ending '.gz' appended to the original filename.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

gunzip filename --- uncompresses files compressed by gzip.


gzcat filename --- lets you look at a gzipped file without actually having to
gunzip it (same as gunzip -c). You can even print it directly, using gzcat
filename | lpr
printing
o lpr filename --- print. Use the -P option to specify the printer name if you want to
use a printer other than your default printer. For example, if you want to print
double-sided, use 'lpr -Pvalkyr-d', or if you're at CSLI, you may want to use 'lpr Pcord115-d'. See 'help printers' for more information about printers and their
locations.
o lpq --- check out the printer queue, e.g. to get the number needed for removal, or
to see how many other files will be printed before yours will come out
o lprm jobnumber --- remove something from the printer queue. You can find the
job number by using lpq. Theoretically you also have to specify a printer name,
but this isn't necessary as long as you use your default printer in the department.
o genscript --- converts plain text files into postscript for printing, and gives you
some options for formatting. Consider making an alias like alias ecop 'genscript
-2 -r \!* | lpr -h -Pvalkyr' to print two pages on one piece of paper.
o dvips filename --- print .dvi files (i.e. files produced by LaTeX). You can use
dviselect to print only selected pages. See the LaTeX page for more information
about how to save paper when printing drafts.
o
o

Directories
Directories, like folders on a Macintosh, are used to group files together in a hierarchical
structure.

mkdir dirname --- make a new directory


cd dirname --- change directory. You basically 'go' to another directory, and you will see
the files in that directory when you do 'ls'. You always start out in your 'home directory',
and you can get back there by typing 'cd' without arguments. 'cd ..' will get you one level
up from your current position. You don't have to walk along step by step - you can make
big leaps or avoid walking around by specifying pathnames.
pwd --- tells you where you currently are.

Finding things

ff --- find files anywhere on the system. This can be extremely useful if you've forgotten
in which directory you put a file, but do remember the name. In fact, if you use ff -p you
don't even need the full name, just the beginning. This can also be useful for finding other
things on the system, e.g. documentation.
grep string filename(s) --- looks for the string in the files. This can be useful a lot of
purposes, e.g. finding the right file among many, figuring out which is the right version
of something, and even doing serious corpus work. grep comes in several varieties (grep,
egrep, and fgrep) and has a lot of very flexible options. Check out the man pages if this
sounds good to you.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

About other people

w --- tells you who's logged in, and what they're doing. Especially useful: the 'idle' part.
This allows you to see whether they're actually sitting there typing away at their
keyboards right at the moment.
who --- tells you who's logged on, and where they're coming from. Useful if you're
looking for someone who's actually physically in the same building as you, or in some
other particular location.
finger username --- gives you lots of information about that user, e.g. when they last
read their mail and whether they're logged in. Often people put other practical
information, such as phone numbers and addresses, in a file called .plan. This
information is also displayed by 'finger'.
last -1 username --- tells you when the user last logged on and off and from where.
Without any options, last will give you a list of everyone's logins.
talk username --- lets you have a (typed) conversation with another user
write username --- lets you exchange one-line messages with another user
elm --- lets you send e-mail messages to people around the world (and, of course, read
them). It's not the only mailer you can use, but the one we recommend. See the elm page,
and find out about the departmental mailing lists (which you can also find in
/user/linguistics/helpfile).

About your (electronic) self

whoami --- returns your username. Sounds useless, but isn't. You may need to find out
who it is who forgot to log out somewhere, and make sure *you* have logged out.
finger
&
.plan
files
of course you can finger yourself, too. That can be useful e.g. as a quick check whether
you got new mail. Try to create a useful .plan file soon. Look at other people's .plan files
for ideas. The file needs to be readable for everyone in order to be visible through 'finger'.
Do 'chmod a+r .plan' if necessary. You should realize that this information is accessible
from anywhere in the world, not just to other people on turing.
passwd --- lets you change your password, which you should do regularly (at least once a
year). See the LRB guide and/or look at help password.
ps -u yourusername --- lists your processes. Contains lots of information about them,
including the process ID, which you need if you have to kill a process. Normally, when
you have been kicked out of a dialin session or have otherwise managed to get yourself
disconnected abruptly, this list will contain the processes you need to kill. Those may
include the shell (tcsh or whatever you're using), and anything you were running, for
example emacs or elm. Be careful not to kill your current shell - the one with the number
closer to the one of the ps command you're currently running. But if it happens, don't
panic. Just try again :) If you're using an X-display you may have to kill some X
processes before you can start them again. These will show only when you use ps -efl,
because they're root processes.
kill PID --- kills (ends) the processes with the ID you gave. This works only for your
own processes, of course. Get the ID by using ps. If the process doesn't 'die' properly, use
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

the option -9. But attempt without that option first, because it doesn't give the process a
chance to finish possibly important business before dying. You may need to kill
processes for example if your modem connection was interrupted and you didn't get
logged out properly, which sometimes happens.
quota -v --- show what your disk quota is (i.e. how much space you have to store files),
how much you're actually using, 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, or moving them to your own computer).
du filename --- shows the disk usage of the files and directories in filename (without
argument the current directory is used). du -s gives only a total.
last yourusername --- lists your last logins. Can be a useful memory aid for when you
were where, how long you've been working for, and keeping track of your phonebill if
you're making a non-local phonecall for dialling in.
6. Introduction to Windows XP

Windows XP is an operating system that was produced by Microsoft for use on personal
computers, including home and business desktops, laptops, and media centers. It was first
released in August 2001, and is the most popular version of Windows, based on installed user
base. The name "XP" is short for "eXPerience.
Windows XP was the successor to both Windows 2000 and Windows Me, and was the first
consumer-oriented operating system produced by Microsoft to be built on the Windows NT
kernel and architecture. Windows XP was released for retail sale on October 25, 2001, and
over 400 million copies were in use in January 2006, according to an estimate in that month
by an IDC analyst. It was succeeded by Windows Vista, which was released to volume
license customers on November 8, 2006, and worldwide to the general public on January 30,
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

2007. Direct OEM and retail sales of Windows XP ceased on June 30, 2008. Microsoft
continued to sell Windows XP through their System Builders (smaller OEMs who sell
assembled computers) program until January 31, 2009. XP may continue to be available as
these sources run through their inventory or by purchasing Windows 7 Ultimate, Windows 7
Pro, Windows Vista Ultimate or Windows Vista Business, and then downgrading to
Windows XP.
The most common editions of the operating system were Windows XP Home Edition, which
was targeted at home users, and Windows XP Professional, which offered additional features
such as support for Windows Server domains and two physical processors, and was targeted
at power users, business and enterprise clients. Windows XP Media Center Edition has
additional multimedia features enhancing the ability to record and watch TV shows, view
DVD movies, and listen to music. Windows XP Tablet PC Edition was designed to run stylus
applications built using the Tablet PC platform.
Windows XP was eventually released for two additional architectures, Windows XP 64-bit
Edition for IA-64 (Itanium) processors and Windows XP Professional x64 Edition for x8664. There is also Windows XP Embedded, a component version of the Windows XP
Professional, and editions for specific markets such as Windows XP Starter Edition. By mid
2009, a manufacturer revealed the first Windows XP powered cellular telephone.
The NT-based versions of Windows, which are programmed in C, C++, and assembly, are
known for their improved stability and efficiency over the 9x versions of Microsoft
Windows.Windows XP presented a significantly redesigned graphical user interface, a
change Microsoft promoted as more user-friendly than previous versions of Windows. A new
software management facility called Side-by-Side Assembly was introduced to ameliorate
the "DLL hell" that plagues 9x versions of Windows. It is also the first version of Windows
to use product activation to combat illegal copying. Windows XP had also been criticized by
some users for security vulnerabilities, tight integration of applications such as Internet
Explorer 6 and Windows Media Player, and for aspects of its default user interface. Later
versions with Service Pack 2, Service Pack 3, and Internet Explorer 8 addressed some of
these concerns.
During development, the project was codenamed "Whistler", after Whistler, British
Columbia, as many Microsoft employees skied at the Whistler-Blackcomb ski resort.
According to web analytics data generated by W3Schools, as of December 2010, Windows
XP is the most widely used operating system for accessing the Internet in the world with a
47.2% market share, having peaked at 76.1% in January 2007.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 9
Basic Introduction to System Software and Programs : Machine Language
Contents
1.
2.
3.
4.
5.

Introduction to Programming Language


Characteristics of good Programming Language
Machine Language
Advantages of Machine language
Disadvantages of Machine language
8. Introduction to Programming Language

A vocabulary and set of grammatical rules for instructing a computer to perform specific tasks.
The term programming language usually refers to high-level languages, such as BASIC, C, C++,
COBOL, FORTRAN, Ada, and Pascal. Each language has a unique set of keywords (words that
it understands) and a special syntax for organizing program instructions.
High-level programming languages, while simple compared to human languages, are more
complex than the languages the computer actually understands, called machine languages. Each
different type of CPU has its own unique machine language.
Lying between machine languages and high-level languages are languages called assembly
languages. Assembly languages are similar to machine languages, but they are much easier to
program in because they allow a programmer to substitute names for numbers. Machine
languages consist of numbers only.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lying above high-level languages are languages called fourth-generation languages (usually
abbreviated 4GL). 4GLs are far removed from machine languages and represent the class of
computer languages closest to human languages.
Regardless of what language you use, 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. Every language has its strengths and weaknesses. For example,
FORTRAN is a particularly good language for processing numerical data, but it does not lend
itself very well to organizing large programs. Pascal is very good for writing well-structured and
readable programs, but it is not as flexible as the C programming language. C++ embodies
powerful object-oriented features, but it is complex and difficult to learn.
The choice of which language to use depends on the type of computer the program is
to run on, what sort of program it is, and the expertise of the programmer.
9. Characteristics of good Programming Language
1. 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.
2. Complexity management (architecture support) the extent to which inherent
language features support the management of system complexity, in terms of
addressing issues of data, algorithm, interface, and architectural complexity.
3. Concurrency support the extent to which inherent language features support
the construction of code with multiple threads of control (also known as parallel
processing).
4. Distributed system support the extent to which inherent language features
support the construction of code to be distributed across multiple platforms on a
network.
5. 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.
6. Mixed language support the extent to which inherent language features
support interfacing to other languages.
7. Object-oriented programming support the extent to which inherent language
features support the construction of object-oriented code.
8. Portability the extent to which inherent language features support the transfer
of a program from one hardware and/or software platform to another.
9. Real-time support the extent to which inherent language features support the
construction of real-time systems.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

10. 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.
11. Reusability the extent to which inherent language features support the
adaptation of code for use in another application.
12. Safety the extent to which inherent language features support the construction
of safety-critical systems, yielding systems that are fault-tolerant, fail-safe, or
robust in the face of systemic failures.
13. 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.
14. Support for modern engineering methods the extent to which inherent
language features support the expression of source code that enforces good
software engineering principles.
3. Machine Language
The lowest-level programming language (except for computers that utilize programmable
microcode) Machine languages are the only languages understood by computers. While easily
understood by computers, machine languages are almost impossible for humans to use because
they consist entirely of numbers. Programmers, therefore, use either a high-level programming
language or an assembly language. An assembly language contains the same instructions as a
machine language, but the instructions and variables have names instead of being just numbers.
4. Low Level Language
Lower level languages are typically assembly languages that are machine specific. Computers
run instructions at the binary level, interpreting zeros and ones as instructions. Rather than
writing programming code at this level, we've developed languages that compile into the zeros
and ones that computers understand. As these languages become more robust, they get further
and further way from zeros and ones, becoming higher level languages.
Low level languages will require more involvement with the actual register and interrupt
interfaces to the hardware. This can provide more control and efficiency for the program and can
be good for applications which need high speed execution, but high level compilers are much
better at optimizing for speed now.
5. Advantages of Machine Language
1. 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. The only advantage is that program of machine language run very fast because no
translation program is required for the CPU.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

3. In machine language, the very basic and specific commands may be used, like to where
the specific data will be stored, how operations and functions be carried out. and since it
is in a code the machine can understand, it may not need a compiler.

6. Disadvantages of Machine Language


1. It is very difficult to program in machine language. The programmer has to
know details of hardware to write program.
2. The programmer has to remember a lot of codes to write a program which
results in program errors.
3. It is difficult to debug the program.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 10 & 11
Assembly Language, High level Languages, Types of high level languages
Contents
1.
2.
3.
4.
5.
6.
7.
8.

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. Assembly Language
Machine languages consist entirely of numbers and are almost impossible for humans to read and
write. Assembly languages have the same structure and set of commands as machine languages,
but they enable a programmer to use names instead of numbers.
Each type of CPU has its own machine language and assembly language, so an assembly
language program written for one type of CPU won't run on another. In the early days of
programming, all programs were written in assembly language. Now, most programs are written
in a high-level language such as FORTRAN or C. 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.
8. Comparison Between Assembly & Machine Language
Machine language is the actual bits used to control the processor in the computer, usually viewed
as a sequence of hexadecimal numbers (typically bytes). The processor reads these bits in from
program memory, and the bits represent "instructions" as to what to do next.
Thus machine language provides a way of entering instructions into a computer (whether
through
switches,
punched
tape,
or
a
binary
file).
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Assembly language is a more human readable view of machine language. Instead of representing
the machine language as numbers, the instructions and registers are given names (typically
abbreviated words, or mnemonics, eg ld means "load"). Unlike a high level language, assembler
is very close to the machine language. The main abstractions (apart from the mnemonics) are the
use
of
labels
instead
of
fixed
memory
addresses,
and
comments.
An assembly language program (ie a text file) is translated to machine language by an assembler.
A disassembler performs the reverse function (although the comments and the names of labels
will
have
been
discarded
in
the
assembler
process).
Machine language faster than assembly language even than assembly language depend upon
machine language.
9. Advantages of Assembly Languages
Assembly language is a symbolic representation of a processor's native code. Using machine
code allows the programmer to control precisely what the processor does. It offers a great deal of
power to use all of the features of the processor. The resulting program is normally very fast and
very compact. In small programs it is also very predictable. Timings, for example, can be
calculated very precisely and program flow is easily controlled. It is often used for small, real
time applications.
10. Disadvantages of Assembly Languages
The programmer needs to have a good understanding of the hardware being used. As programs
become larger, assembly language get very cumbersome. Maintenance of assembly language is
notoriously difficult, especially if another programmer is brought in to carry out modifications
after the code has been written. Assembly langauge also has no support of an operating system,
nor does it have any complex instructions. Storing and retrieving data is a simple task with high
level languages; assembly needs the whole process to be programmed step by step. Mathmatical
processes also have to be performed with binary addition and subtraction when using assembly
which can get very complex. Finally, every processor has its own assembly language. Use a new
processor and you need to learn a new language each time.
11. High Level Language
Programs written in high-level languages are translated into assembly language or machine
language by a compiler. Assembly language programs are translated into machine language by a
program called an assembler.
Every CPU has its own unique machine language. Programs must be rewritten or recompiled,
therefore, to run on different types of computers.
A programming language such as C, FORTRAN, or Pascal that enables a programmer to write
programs that are more or less independent of a particular type of computer. Such languages are
considered high-level because they are closer to human languages and further from machine
languages. In contrast, assembly languages are considered low-level because they are very close
to machine languages.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

The main advantage of high-level languages over low-level languages is that they are easier to
read, write, and maintain. Ultimately, programs written in a high-level language must be
translated into machine language by a compiler or interpreter.
The first high-level programming languages were designed in the 1950s. Now there are dozens
of different languages, including Ada, Algol, BASIC, COBOL, C, C++, FORTRAN, LISP,
Pascal, and Prolog.
12. Advantages of High Level Language
In high level languages we can write programs in English like manner and is more convenient to
use. Programmer can perform complex task by using high level languages with less efforts.
There are different high level languages such as FORTRAN (Formula Instructions), BASIC
(Beginners All Purpose Symbolic Instruction Code), COCOL (Common Business Oriented
Language),
PASCAL,
C++,
Visual
Basic,
VB.
Net
etc.
High level languages have many advantages. High level languages are very similar to nature
language such as English so they are very easy to learn and use. For higher level languages
programmers needs not to learn about internal structure of the computer. High level language
programs require less time and efforts that due the preparation cost of the program.
High level programs are very easy to maintain than lower level languages. In lower level
languages instruction are difficult and very hard to locate, correct and modify but in high level
languages it is very easy to understand and modify when desired. In high level languages
programmer needs not to write all steps because computer take cares of all small error.
Compilers of high level languages automatically catch and point out the errors made by the
programmers.
13. Disadvantages of High Level Languages
Though it is much easier to code in a high level language, oftentimes access to more low-level
functionalities are lost. For instance, the ability to communicate directly with the compiler and
alter
code
before
it
gets
transferred
into
machine
code
is
lost.
To make it more easier for the programmer to understand and write code. High level
programming languages like C, 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. Coding a computer
today is just one step below to talking to a human. It is that easy.
Now, why are low-level programming languages important? Low level programming languages
are important because of space and speed. If you write a program in a high level language, say
Java, first the Java Compiler will compile it to byte code. Now, this byte code is again compiled
during run time to assembly code(low level) which in turn is again converted to executable code.
But, when you write low level code, it is directly converted into executable code avoiding all the
other steps. This will incredibly save you space and increase speed. That is the reason why Bill
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Gates said that 1MB is the unreachable limit. However, the time consumed to write a program
will be very large. Because, at low level, you have to manage everything: memory and
everything.
14. Types of High Level Languages
a) BASIC. In computer programming, BASIC is a family of high-level programming
languages. The original BASIC was designed in 1964 by John George Kemeny and
Thomas Eugene Kurtz at Dartmouth College in New Hampshire, USA to provide
computer access to non-science students. At the time, nearly all use of computers
required writing custom software, which was something only scientists and
mathematicians tended to do. The language and its variants became widespread on
microcomputers in the late 1970s and 1980s. BASIC remains popular to this day in a
handful of highly modified dialects and new languages influenced by BASIC such as
Microsoft Visual Basic. As of 2006, 59% of developers for the .NET platform used
Visual Basic .NET as their only language.
b) COBOL. COBOL is one of the oldest programming languages. Its name is an acronym
for COmmon Business-Oriented Language, defining its primary domain in business,
finance, and administrative systems for companies and governments.
The COBOL 2002 standard includes support for object-oriented programming and other modern
language features.
Features
COBOL as defined in the original specification included a PICTURE clause for detailed field
specification. It did not support local variables, recursion, dynamic memory allocation, or
structured programming constructs. Support for some or all of these features has been added in
later editions of the COBOL standard. COBOL has many reserved words (over 400), called
keywords.
Self-modifying code
The original COBOL specification supported self-modifying code via the infamous "ALTER X
TO PROCEED TO Y" statement. X and Y are paragraph labels, and any "GOTO X" statements
executed after such an ALTER statement have the meaning "GOTO Y" instead. Most compilers
still support it, but it should not be used in new programs.
Syntactic features
COBOL provides an update-in-place syntax, for example
ADD YEARS TO AGE
The equivalent construct in many procedural languages would be
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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). These are declared as sub-items of
another item (the conditional variable). The named condition can be used in an IF statement, and
tests whether the conditional variable is equal to any of the values given in the named condition's
VALUE clause. The SET statement can be used to make a named condition TRUE (by assigning
the first of its values to the conditional variable).
COBOL allows identifiers to be up to 30 characters long. When COBOL was introduced, much
shorter lengths (e.g., 6 characters for FORTRAN) were prevalent.
The concept of copybooks was introduced by COBOL; these are chunks of code which can be
inserted into a program's code. This is done with the COPY statement, which also allows parts of
the copybook's code to be replaced with other code.
c) FORTRAN. Fortran is a general-purpose, procedural, imperative programming
language that is especially suited to numeric computation and scientific computing.
Originally developed by IBM at their campus in south San Jose, California in the 1950s
for scientific and engineering applications, 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, finite element
analysis, computational fluid dynamics, computational physics and computational
chemistry. It was one of the most popular languages in the area of high-performance
computing, and is the language used for programs that benchmark and rank the world's
fastest supercomputers.
FORTRAN encompasses a lineage of versions, each of which evolved to add extensions to the
language while usually retaining compatibility with previous versions. Successive versions have
added support for processing of character-based data array programming, modular programming
and object-based programming and object-oriented and generic programming.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 12 & 13
Complier, Interpreter, Assembler, Loader, Linker, Relationship between Complier,
Interpreter, Loader and Linker.
Contents
6. Compiler
7. Interpreter
8. Assembler
9. Loader
10. Linker
1. Compiler
A program that translate source code into object code. The compiler derives its name from the
way it works, looking at the entire piece of source code and collecting and reorganizing the
instructions. Thus, a compiler differs from an interpreter, which analyzes and executes each line
of source code in succession, without looking at the entire program. The advantage of
interpreters is that they can execute a program immediately. Compilers require some time before
an executable program emerges. However, programs produced by compilers run much faster
than the same programs executed by an interpreter.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Every high-level programming language (except strictly interpretive languages) comes with a
compiler. In effect, the compiler is the language, because it defines which instructions are
acceptable.
Because compilers translate source code into object code, which is unique for each type of
computer, many compilers are available for the same language. For example, there is a
FORTRAN compiler for PCs and another for Apple Macintosh computers. In addition, the
compiler industry is quite competitive, so there are actually many compilers for each language
on each type of computer. More than a dozen companies develop and sell C compilers for the
PC.
2. Interpreter
A program that executes instructions written in a high-level language. There are two ways to run
programs written in a high-level language. The most common is to compile the program; the
other method is to pass the program through an interpreter.
An interpreter translates high-level instructions into an intermediate form, which it then executes.
In contrast, a compiler translates high-level instructions directly into machine language.
Compiled programs generally run faster than interpreted programs. The advantage of an
interpreter, however, is that it does not need to go through the compilation stage during which
machine instructions are generated. This process can be time-consuming if the program is long.
The interpreter, on the other hand, can immediately execute high-level programs. For this reason,
interpreters are sometimes used during the development of a program, when a programmer wants
to add small sections at a time and test them quickly. In addition, interpreters are often used in
education because they allow students to program interactively.
Both interpreters and compilers are available for most high-level languages. However, BASIC
and LISP are especially designed to be executed by an interpreter. In addition, page description
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

languages, such as PostScript, use an interpreter. Every PostScript printer, for example, has a
built-in interpreter that executes PostScript instructions.
3. Assembler
A program that translate programs from assembly language to machine language.
4. Loader
An operating system utility that copies programs from a storage device to main memory, where
they can be executed. In addition to copying a program into main memory, the loader can also
replace virtual addresses with physical addresses. Most loaders are transparent, i.e., you cannot
directly execute them, but the operating system uses them when necessary.
Algorithm

(alg&-rith-&m) (n.) A formula or set of steps for solving a particular problem. To be an


algorithm, a set of rules must be unambiguous and have a clear stopping point. Algorithms can
be expressed in any language, from natural languages like English or French to programming
languages like FORTRAN.
We use algorithms every day. For example, a recipe for baking a cake is an algorithm. Most
programs, with the exception of some artificial intelligence applications, consist of algorithms.
Inventing elegant algorithms -- algorithms that are simple and require the fewest steps possible -is one of the principal challenges in programming.
Flow Chart
A flowchart is a schematic representation of an algorithm or a process, or the step-by-step
solution of a problem, 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 ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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. A symbol appearing in a particular "lane"
is within the control of that organizational unit. This technique allows the analyst to locate the
responsibility for performing an action or making a decision correctly, allowing the relationship
between different organizational units with responsibility over a single process.
A flowchart is one of the seven basic tools of quality control, which also includes the histogram,
Pareto chart, check sheet, control chart, cause-and-effect diagram, and scatter diagram. They are
commonly used in business/economic presentations to help the audience visualize the content
better, or to find flaws in the process. Alternatively, one can use Nassi-Shneiderman diagrams.
Symbols
Start and end symbols, represented as lozenges, ovals or rounded rectangles, usually
containing the word "Start" or "End", or another phrase signaling the start or end of a
process, such as "submit enquiry" or "receive product".
Arrows, showing what's called "flow of control" in computer science. An arrow coming
from one symbol and ending at another symbol represents that control passes to the
symbol the arrow points to.
Processing steps, represented as rectangles. Examples: "Add 1 to X"; "replace identified
part"; "save changes" or similar.
Input/Output, represented as a parallelogram. Examples: Get X from the user; display
X.
Conditional (or decision), represented as a diamond (rhombus). These typically contain
a Yes/No question or True/False test. This symbol is unique in that it has two arrows
coming out of it, usually from the bottom point and right point, one corresponding to Yes
or True, and one corresponding to No or False. The arrows should always be labeled.
More than two arrows can be used, but this is normally a clear indicator that a complex
decision is being taken, in which case it may need to be broken-down further, or replaced
with the "pre-defined process" symbol.
A number of other symbols that have less universal currency, such as:
o A Document represented as a rectangle with a wavy base;
o A Manual input represented by parallelogram, with the top irregularly sloping up
from left to right. An example would be to signify data-entry from a form;
o A Manual operation represented by a trapezoid with the longest parallel side at
the top, to represent an operation or adjustment to process that can only be made
manually.
o A Data File represented by a cylinder
Flowcharts may contain other symbols, such as connectors, usually represented as circles, to
represent converging paths in the flow chart. Circles will have more than one arrow coming into
them but only one going out. Some flow charts may just have an arrow point to another arrow
instead. These are useful to represent an iterative process (what in Computer Science is called a
loop). A loop may, for example, consist of a connector where control first enters, processing
steps, a conditional with one arrow exiting the loop, and one going back to the connector. OffWorld Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

page connectors are often used to signify a connection to a (part of another) process held on
another sheet or screen. It is important to remember to keep these connections logical in order.
All processes should flow from top to bottom and left to right.
5. Linker
Also called link editor and binder, a linker is a program that combines object modules to form an
executable program. Many programming languages allow you to write different pieces of code,
called modules, separately. This simplifies the programming task because you can break a large
program into small, more manageable pieces. Eventually, though, you need to put all the
modules together. This is the job of the linker.
In addition to combining modules, a linker also replaces symbolic addresses with real addresses.
Therefore, you may need to link a program even if it contains only one module.
Lecture: 14 & 15
Basic Introduction to Computer Networks: - Data Communication, Modulation,
Network devices.
Contents
7. Introduction to Network
8. Introduction to Computer Network
9. Types of Networking
10. Introduction to Data Communication
11. Introduction to Modulation
12. Network Devices
13. 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), exchange files, or allow electronic communications. The computers on a
network may be linked through cables, telephone lines, radio waves, satellites, or infrared light
beams.
The three basic types of networks include:
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 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. A computer network can also consist
of, and is usually made for, more than two computers.
A computer network, often simply referred to as a network, is a collection of computers and
devices interconnected by communications channels that facilitate communications among
users and allows users to share resources. Networks may be classified according to a wide
variety of characteristics. A computer network allows sharing of resources and information
among interconnected devices.

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
doesnt have it; In this case, you can burn CDs or make backups on a computer that has
one of these but using data from a computer that doesnt have a CD writer or a backup
system
You may have a computer that doesnt have a DVD player. In this case, you can place a
movie DVD on the computer that has a DVD player, and then view the movie on a
computer that lacks a DVD player
You can connect a printer (or a scanner, or a fax machine) to one computer and let other
computers of the network print (or scan, or fax) to that printer (or scanner, 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, 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 ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Based on their layout (not the physical but the imagined layout, also referred to as topology),
there are two types of networks. 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, Me, Windows XP Home Edition, or Windows
XP Professional (you can also connect a Novell SUSE Linux as part of a Microsoft Windowsbased network; the current release of the operating system is really easily to install and made part
of the network).
In a peer-to-peer network, each computer holds its files and resources. 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. For example, if a printer is connected to computer A and
computer B wants to printer to that printer, computer A must be turned on.
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". Besides the computers, other types of devices
can be part of the network.

In a client/server environment, each computer still holds (or can still hold) its (or some)
resources and files. Other computers can also access the resources stored in a computer, as in a
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

peer-to-peer scenario. One of the particularities of a client/server network is that the files and
resources are centralized. This means that a computer, the server, can hold them and other
computers can access them. Since the server is always On, the client machines can access the
files and resources without caring whether a certain computer is On.
Another big advantage of a client/server network is that security is created, managed, and can
highly get enforced. To access the network, a person, called a user must provide some
credentials, including a username and a password. If the credentials are not valid, the user can
be prevented from accessing the network.
The client/server type of network also provides many other advantages such as centralized
backup, Intranet capability, Internet monitoring, etc.
Introduction to Data Communication
Data Communications is the transfer of data or information between a source and a receiver.
The source transmits the data and the receiver receives it. The actual generation of the
information is not part of Data Communications nor is the resulting action of the information
at the receiver. Data Communication is interested in the transfer of data, the method of
transfer and the preservation of the data during the transfer process.
In Local Area Networks, we are interested in "connectivity", connecting computers together
to share resources. Even though the computers can have different disk operating systems,
languages, cabling and locations, they still can communicate to one another and share
resources.
The purpose of Data Communications is to provide the rules and regulations that allow
computers with different disk operating systems, languages, cabling and locations to share
resources. The rules and regulations are called protocols and standards in Data
Communications.
Introduction to Modulation
Modulation is the process of varying some characteristic of a periodic wave with an external
signals. Modulation is utilized to send an information bearing signal over long distances. Radio
communication superimposes this information bearing signal onto a carrier signal.
These high frequency carrier signals can be transmitted over the air easily and are capable of
traveling long distances. The characteristics (amplitude, frequency, or phase) of the carrier signal
are varied in accordance with the information bearing signal. In the field of communication
engineering, the information bearing signal is also known as the modulating signal. The
modulating signal is a slowly varying signal as opposed to the rapidly varying carrier
frequency.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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. A
LAN requires a hub, router, cabling or radio technology, network cards, and if online access is
desired, a high-speed modem. Happily this is much less c In a network, one computer is
designated as the server, and the others, clients. The server is connected to an external hub,
which the clients are also connected to. 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. To direct these
signals, the hub contains a device known as a router. The router is the equivalent of an electronic
traffic cop that handles data traffic between the computers. In a network, one computer is
designated as the server, and the others, clients. The server is connected to an external hub,
which the clients are also connected to. 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. To direct these
signals, the hub contains a device known as a router. The router is the equivalent of an electronic
traffic cop that handles data traffic between the computers.
Types of Network Devices
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

a) Hubs
A hub is a piece of hardware that contains several ethernet ports that connects several computers.
Connecting a hub to a network is very easy. You can simply connect a hub to your router, and
then several computers to the hub. The IP addresses of the computers that are connected to the
hub are assigned by the router it is connected to.
Hubs work by broadcasting data to all computers that are connected to it. When a computer or
program makes a request for information from another computer, the originating computer sends
(broadcasts) the request to the hub. The hub will then brodcast the request to all computers that
are connect to it. When the destination computer receives the request, it sends the information
back to the hub. Once again the hub broadcasts the information to all computers, with only the
requesting computer acting on the information.
The downside to this type of connection is that the bandwidth is subdivided between the number
of computers that are connected to the hub. If you have a 100Mbps connection, and 2 computers
connected to the hub, then the bandwidth available to each computer is 50Mbps. With 4
computers, 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. You can also connect switches to routers in the same way you connect hubs.
There are several differences between hubs and switches, however, that can boost the
performance of your network. The performance increase has to do with how data is transmitted
between the computers on your network.
While hubs transmit data via broadcasting the data to all computers that are connected to it,
switches establish a direct connection between the transmitting and receiving computers. The
added benefit of this is that the bandwidth is not subdivided. If you have a 100Mbps bandwidth
on your network with 2 computers connected to a switch, the total bandwidth available to both
computers is 100Mbps. This means that each port on the switch has the full bandwidth dedicated
to it.
Many switches also have the ability to either use half- or full-duplex (receive and transmit at the
same time). Hubs are half-duplex, which means they can either receive or transmit, but not both
at the same time.
c) Routers
A router is used to route data packets between two networks. It reads the information in each
packet to tell where it is going. If it is destined for an immediate network it has access to, it will
strip the outer packet (IP packet for example), readdress the packet to the proper ethernet
address, and transmit it on that network. If it is destined for another network and must be sent
to another router, it will re-package the outer packet to be received by the next router and send
it to the next router. Routing occurs at the network layer of the OSI model. They can connect
networks with different architectures such as Token Ring and Ethernet. Although they can
transform information at the data link level, routers cannot transform information from one data
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

format such as TCP/IP to another such as IPX/SPX. Routers do not send broadcast packets or
corrupted packets. If the routing table does not indicate the proper address of a packet, the
packet is discarded. There are two types of routers:
1. Static routers - Are configured manually and route data packets based on information in a
router table.
2. Dynamic routers - Use dynamic routing algorithms. There are two types of algorithms:
o Distance vector - Based on hop count, and periodically broadcasts the routing
table to other routers which takes more network bandwidth especially with more
routers. RIP uses distance vectoring. Does not work on WANs as well as it does
on LANs.
o Link state - Routing tables are broadcast at startup and then only when they
change. The open shortest path first (OSPF) protocol uses the link state routing
method to configure routes or distance vector algorithm (DVA).
Common routing protocols include:
IS-IS -Intermediate system to intermediate system which is a routing protocol for the OSI
suite of protocols.
IPX - Internet Packet Exchange. Used on Netware systems.
NLSP - Netware Link Services protocol - Uses OSPF algorithm and is replacing IPX to
provide internet capability.
RIP - Routing information protocol uses a distance vector algorithm.
There is a device called a brouter which will function similar to a bridge for network transport
protocols that are not routable, and will function as a router for routable protocols. It functions at
the network and data link layers of the OSI network model.
d) Bridges
A bridge reads the outermost section of data on the data packet, to tell where the message is
going. It reduces the traffic on other network segments, since it does not send all packets.
Bridges can be programmed to reject packets from particular networks. Bridging occurs at the
data link layer of the OSI model, which means the bridge cannot read IP addresses, but only the
outermost hardware address of the packet. In our case the bridge can read the ethernet data which
gives the hardware address of the destination address, not the IP address. Bridges forward all
broadcast messages. Only a special bridge called a translation bridge will allow two networks of
different architectures to be connected. Bridges do not normally allow connection of networks
with different architectures. The hardware address is also called the MAC (media access control)
address. To determine the network segment a MAC address belongs to, bridges use one of:

Transparent Bridging - They build a table of addresses (bridging table) as they receive
packets. If the address is not in the bridging table, the packet is forwarded to all segments
other than the one it came from. This type of bridge is used on ethernet networks.
Source route bridging - The source computer provides path information inside the packet.
This is used on Token Ring networks.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

e) Gateways
A gateway can translate information between different network data formats or network
architectures. It can translate TCP/IP to AppleTalk so computers supporting TCP/IP can
communicate with Apple brand computers. Most gateways operate at the application
layer, but can operate at the network or session layer of the OSI model. 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. To confuse issues, when talking about a router that is used to interface to another
network, the word gateway is often used. This does not mean the routing machine is a
gateway as defined here, although it could be.

Lecture: 16
LAN, MAN & WAN
Contents
1. Introduction to LAN
2. Introduction to MAN
3. Introduction to WAN
1. Introduction to LAN
A LAN (local area network) is a group of computers and network devices connected together,
usually within the same building. By definition, the connections must be high speed and
relatively inexpensive (e.g., token ring or Ethernet). Most Indiana University Bloomington
departments are on LANs.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Typically connects computer in a single building or campus.


Developed in 1970s.
Medium: optical fibers, coaxial cables, twisted pair, wireless.
Low latency (except in high traffic periods).
High speed networks (0.2 to 100 Mb/sec).
Speeds adequate for most distributed systems
Problems : Multi media based applications
Typically buses or rings.
Ethernet, Token Ring
2. Introduction to MAN

A MAN (metropolitan area network) is a larger network that usually spans several buildings in
the same city or town. The IUB network is an example of a MAN.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Generally covers towns and cities (50 kms)


Developed in 1980s.
Medium: optical fibers, cables.
Data rates adequate for distributed computing applications.
A typical standard is DQDB (Distributed Queue Dual Bus).
Typical latencies: < 1 msec.
Message routing is fast.
3. Introduction to WAN

A WAN (wide area network), in comparison to a MAN, is not restricted to a geographical


location, although it might be confined within the bounds of a state or country. A WAN connects
several LANs, and may be limited to an enterprise (a corporation or an organization) or
accessible to the public. The technology is high speed and relatively expensive. The Internet is
an example of a worldwide public WAN.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Developed in 1960s.
Generally covers large distances (states, countries, continents).
Medium: communication circuits connected by routers.
Routers forwards packets from one to another following a route from the sender to the
receiver. Store-and-Forward
Hosts are typically connected (or close to) the routers.
Typical latencies: 100ms - 500ms.
Problems with delays if using satellites.
Typical speed: 20 - 2000 Kbits/s.
Not (yet) suitable for distributed computing.
New standards are changing the landscape.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 17
OSI Reference Model
Contents
1. OSI Reference model
2. Description of the OSI Layers
Layer 1Physical layer (P)
Layer 2Data Link layer (D)
Layer 3Network layer (N)
Layer 4Transport layer (T)
Layer 5Session layer (S)
Layer 6Presentation layer (P)
Layer 7Application layer (A)
Tip to Remember
People Do Need To Send Packets Away.
1. OSI Reference Model

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

The Open Systems Interconnection model (OSI model) is a product of the Open Systems
Interconnection effort at the International Organization for Standardization. It is a way of subdividing a communications system into smaller parts called layers. 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. On each layer, an instance provides services to the instances at the layer
above and requests service from the layer below.
For example, a layer that provides error-free communications across a network provides the path
needed by applications above it, while it calls the next lower layer to send and receive packets
that make up the contents of the path. Conceptually two instances at one layer are connected by a
horizontal protocol connection on that layer. Most network protocols used in the market today
are based on TCP/IP stacks.
2. Description of the OSI Layers
Layer 1Physical layer (P)
The Physical Layer defines the electrical and physical specifications for devices. In particular, it
defines the relationship between a device and a transmission medium, such as a copper or optical
cable. This includes the layout of pins, voltages, cable specifications, hubs, repeaters, network
adapters, host bus adapters (HBA used in storage area networks) and more.
To understand the function of the Physical Layer, contrast it with the functions of the Data Link
Layer. Think of the Physical Layer as concerned primarily with the interaction of a single device
with a medium, whereas the Data Link Layer is concerned more with the interactions of multiple
devices (i.e., at least two) with a shared medium. Standards such as RS-232 do use physical
wires to control access to the medium.
The major functions and services performed by the Physical Layer are:

Establishment and termination of a connection to a communications medium.


Participation in the process whereby the communication resources are effectively shared
among multiple users. For example, contention resolution and flow control.
Modulation, or conversion between the representation of digital data in user equipment
and the corresponding signals transmitted over a communications channel. 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, although it must be remembered that the logical SCSI
protocol is a Transport Layer protocol that runs over this bus. Various Physical Layer Ethernet
standards are also in this layer; Ethernet incorporates both this layer and the Data Link Layer.
The same applies to other local-area networks, such as token ring, FDDI, ITU-T G.hn and IEEE
802.11, as well as personal area networks such as Bluetooth and IEEE 802.15.4.
Layer 2Data 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.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Originally, this layer was intended for point-to-point and point-to-multipoint media,
characteristic of wide area media in the telephone system. Local area network architecture,
which included broadcast-capable multiaccess media, was developed independently of the ISO
work in IEEE Project 802. IEEE work assumed sublayering and management functions not
required for WAN use. In modern practice, only error detection, not flow control using sliding
window, is present in data link protocols such as Point-to-Point Protocol (PPP), and, on local
area networks, the IEEE 802.2 LLC layer is not used for most protocols on the Ethernet, and on
other local area networks, its flow control and acknowledgment mechanisms are rarely used.
Sliding window flow control and acknowledgment is used at the Transport Layer by protocols
such as TCP, but is still used in niches where X.25 offers performance advantages.
The ITU-T G.hn standard, which provides high-speed local area networking over existing wires
(power lines, phone lines and coaxial cables), includes a complete Data Link Layer which
provides both error correction and flow control by means of a selective repeat Sliding Window
Protocol.
Both WAN and LAN service arrange bits, from the Physical Layer, into logical sequences called
frames. Not all Physical Layer bits necessarily go into frames, as some of these bits are purely
intended for Physical Layer functions. For example, every fifth bit of the FDDI bit stream is not
used by the Layer.
Layer 3Network 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,
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). The Network Layer performs network
routing functions, and might also perform fragmentation and reassembly, and report delivery
errors. Routers operate at this layersending data throughout the extended network and making
the Internet possible. This is a logical addressing scheme values are chosen by the network
engineer. The addressing scheme is not hierarchical.
Careful analysis of the Network Layer indicated that the Network Layer could have at least three
sublayers:
1. Subnetwork Access - that considers protocols that deal with the interface to networks,
such as X.25;
2. Subnetwork Dependent Convergence - when it is necessary to bring the level of a transit
network up to the level of networks on either side;
3. Subnetwork Independent Convergence - which handles transfer across multiple networks.
The best example of this latter case is CLNP, or IPv7 ISO 8473. It manages the connectionless
transfer of data one hop at a time, from end system to ingress router, router to router, and from
egress router to destination end system. It is not responsible for reliable delivery to a next hop,
but only for the detection of erroneous packets so they may be discarded. In this scheme, IPv4
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

and IPv6 would have to be classed with X.25 as subnet access protocols because they carry
interface addresses rather than node addresses.
A number of layer management protocols, a function defined in the Management Annex, ISO
7498/4, belong to the Network Layer. These include routing protocols, multicast group
management, Network Layer information and error, and Network Layer address assignment. It is
the function of the payload that makes these belong to the Network Layer, not the protocol that
carries them.
Layer 4Transport layer (T)
The Transport Layer provides transparent transfer of data between end users, providing reliable
data transfer services to the upper layers. The Transport Layer controls the reliability of a given
link through flow control, segmentation/desegmentation, and error control. Some protocols are
state and connection oriented. This means that the Transport Layer can keep track of the
segments and retransmit those that fail. The Transport layer also provides the acknowledgement
of the successful data transmission and sends the next data if no errors occurred.
Although not developed under the OSI Reference Model and not strictly conforming to the OSI
definition of the Transport Layer, typical examples of Layer 4 are the Transmission Control
Protocol (TCP) and User Datagram Protocol (UDP).
Of the actual OSI protocols, 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, designed for less reliable networks, similar to the Internet). Class 0 contains no error
recovery, and was designed for use on network layers that provide error-free connections. Class
4 is closest to TCP, although TCP contains functions, such as the graceful close, which OSI
assigns to the Session Layer. Also, all OSI TP connection-mode protocol classes provide
expedited data and preservation of record boundaries, both of which TCP is incapable. 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 ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Perhaps an easy way to visualize the Transport Layer is to compare it with a Post Office, which
deals with the dispatch and classification of mail and parcels sent. Do remember, however, that a
post office manages the outer envelope of mail. Higher layers may have the equivalent of double
envelopes, such as cryptographic presentation services that can be read by the addressee only.
Roughly speaking, tunneling protocols operate at the Transport Layer, such as carrying non-IP
protocols such as IBM's SNA or Novell's IPX over an IP network, or end-to-end encryption with
IPsec. While Generic Routing Encapsulation (GRE) might seem to be a Network Layer protocol,
if the encapsulation of the payload takes place only at endpoint, GRE becomes closer to a
transport protocol that uses IP headers but contains complete frames or packets to deliver to an
endpoint. L2TP carries PPP frames inside transport packet.
Layer 5Session layer (S)
The Session Layer controls the dialogues (connections) between computers. It establishes,
manages and terminates the connections between the local and remote application. It provides for
full-duplex, half-duplex, or simplex operation, and establishes checkpointing, adjournment,
termination, and restart procedures. The OSI model made this layer responsible for graceful
close of sessions, which is a property of the Transmission Control Protocol, and also for session
checkpointing and recovery, which is not usually used in the Internet Protocol Suite. The Session
Layer is commonly implemented explicitly in application environments that use remote
procedure calls.
Layer 6Presentation layer (P)
The Presentation Layer establishes context between Application Layer entities, in which the
higher-layer entities may use different syntax and semantics if the presentation service provides a
mapping between them. If a mapping is available, presentation service data units are
encapsulated into session protocol data units, and passed down the stack.
This layer provides independence from data representation (e.g., encryption) by translating
between application and network formats. The presentation layer transforms data into the form
that the application accepts. This layer formats and encrypts data to be sent across a network. It
is sometimes called the syntax layer.
The original presentation structure used the basic encoding rules of Abstract Syntax Notation
One (ASN.1), with capabilities such as converting an EBCDIC-coded text file to an ASCIIcoded file, or serialization of objects and other data structures from and to XML.
Layer 7Application layer (A)
The Application Layer is the OSI layer closest to the end user, 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. Such application
programs fall outside the scope of the OSI model. Application layer functions typically include
identifying communication partners, determining resource availability, and synchronizing
communication. When identifying communication partners, the application layer determines the
identity and availability of communication partners for an application with data to transmit.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

When determining resource availability, the application layer must decide whether sufficient
network or the requested communication exist. In synchronizing communication, all
communication between applications requires cooperation that is managed by the application
layer. Some examples of application layer implementations include:

On OSI stack:

FTAM File Transfer and Access Management Protocol


X.400 Mail
Common management information protocol (CMIP)
On TCP/IP stack:
o
o
o

o
o
o
o

Hypertext Transfer Protocol (HTTP),


File Transfer Protocol (FTP),
Simple Mail Transfer Protocol (SMTP)
Simple Network Management Protocol (SNMP)

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 18
Introduction to Internet, Protocols & Backbone Network
Contents
1.
2.
3.
4.
5.
6.

Introduction to Internet
Services of Internet
Uses of Internet
Introduction to Protocol
Types of Protocol
Introduction to Backbone Network

1. Introduction to Internet
The Internet links are computer networks all over the world so that users can share resources and
communicate with each other. Some computers, have direct access to all the facilities on the
Internet such as the universities. And other computers, eg privately-owned ones, have indirect
links through a commercial service provider, who offers some or all of the Internet facilities. In
order to be connected to Internet, you must go through service suppliers. Many options are
offered with monthly rates. Depending on the option chosen, access time may vary.
The Internet is what we call a metanetwork, that is, a network of networks that spans the globe.
It's impossible to give an exact count of the number of networks or users that comprise the
Internet, but it is easily in the thousands and millions respectively. 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. These standards, sometimes
referred to as the Internet Protocol Suite, are the rules that developers adhere to when creating
new
functions
for
the
Internet.
The Internet is also what we call a distributed system; there are no central archives. Technically,
no one runs the Internet. Rather, the Internet is made up of thousands of smaller networks. The
Internet thrives and develops as its many users find new ways to create, display and retrieve the
information that constitutes the Internet.
A company that provides access to the Internet. For a monthly fee, the service provider gives you
a software package, username, password and access phone number. Equipped with a modem,
you can then log on to the Internet and browse the World Wide Web and USENET, and send and
receive e-mail.
In addition to serving individuals, ISPs also serve large companies, providing a direct connection
from the company's networks to the Internet. ISPs themselves are connected to one another
through Network Access Points (NAPs).
ISPs are also called IAPs (Internet Access Providers )
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

2. Services of Internet
Email
Electronic mail, often abbreviated to e-mail, email, or originally eMail, is a store-and-forward
method of writing, sending, receiving and saving messages over electronic communication
systems. The term "e-mail" (as a noun or verb) applies to the Internet e-mail system based on the
Simple Mail Transfer Protocol, to network systems based on other protocols and to various
mainframe, minicomputer, or intranet systems allowing users within one organization to send
messages to each other in support of workgroup collaboration. Intranet systems may be based on
proprietary protocols supported by a particular systems vendor, or on the same protocols used on
public networks. E-mail is often used to deliver bulk unsolicited messages, or "spam", but filter
programs exist which can automatically block, quarantine or delete some or most of these,
depending on the situation.
Internet e-mail messages consist of two major sections:

Header Structured into fields such as summary, sender, receiver, and other
information about the e-mail
Body The message itself as unstructured text; sometimes containing a signature block
at the end

The header is separated from the body by a blank line.


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, such as the Internet. FTP is built on a client-server
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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 : info@wit.net.in
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 : info@wit.net.in
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 : info@wit.net.in
Website : www.wit.net.in

UNIT 1

The reason such a virtually unlimited set of Internet protocol addresses is desirable is because of
the onset of small wireless devices. In the past it seemed that four billion addresses would be
more than enough, but addresses were used only by computers at the time. In the future, it is
conceivable that for every human being on earth there will be hundreds, if not thousands, of
devices communicating via wireless networks, each needing its own address in the Internet
protocol.

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, graphic images,
sound, video, and other multimedia files) on the World Wide Web. As soon as a Web user opens
their Web browser, the user is indirectly making use of HTTP. HTTP is an application protocol
that runs on top of the TCP/IP suite of protocols (the foundation protocols for the Internet).
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. Any Web server
machine contains, in addition to the Web page files it can serve, an HTTP daemon, a program
that is designed to wait for HTTP requests and handle them when they arrive. Your Web browser
is an HTTP client, sending requests to server machines. 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, the browser builds an HTTP request and sends it to the Internet
Protocol address (IP address) indicated by the URL. The HTTP daemon in the destination server
machine receives the request and sends back the requested file or files associated with the
request. (A Web page often consists of more than one file.)
The latest version of HTTP is HTTP 1.1.

Border Gateway Protocol

The Border Gateway Protocol (BGP) is the protocol backing the core routing decisions on the
Internet. It maintains a table of IP networks or 'prefixes' which designate network reachability
among autonomous systems (AS). It is described as a path vector protocol. BGP does not use
traditional Interior Gateway Protocol (IGP) metrics, but makes routing decisions based on path,
network policies and/or rulesets. For this reason, it is more appropriately termed a reachability
protocol rather than routing protocol.
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.
This allowed the Internet to become a truly decentralized system. Since 1994, version four of the
BGP has been in use on the Internet. All previous versions are now obsolete. 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. Since January 2006, version 4 is codified in
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

RFC 4271, which went through more than 20 drafts based on the earlier RFC 1771 version 4.
RFC 4271 version corrected a number of errors, clarified ambiguities and brought the RFC much
closer to industry practices.
Most Internet users do not use BGP directly. Since most Internet service providers must use BGP
to establish routing between one another (especially if they are multihomed), it is one of the most
important protocols of the Internet. Compare this with Signaling System 7 (SS7), which is the
inter-provider core call setup protocol on the PSTN. Very large private IP networks use BGP
internally. 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. 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.

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.e., a scope)
configured for a given network.
DHCP assigns an IP address when a system is started, for example:
a) A user turns on a computer with a DHCP client.
b) The client computer sends a broadcast request (called a DISCOVER or
DHCPDISCOVER), looking for a DHCP server to answer.
c) The router directs the DISCOVER packet to the correct DHCP server.
d) The server receives the DISCOVER packet. Based on availability and usage policies set
on the server, the server determines an appropriate address (if any) to give to the client.
The server then temporarily reserves that address for the client and sends back to the
client an OFFER (or DHCPOFFER) packet, with that address information. The server
also configures the client's DNS servers, WINS servers, NTP servers, and sometimes
other services as well.
e) The client sends a REQUEST (or DHCPREQUEST) packet, letting the server know that
it intends to use the address.
f) The server sends an ACK (or DHCPACK) packet, confirming that the client has a been
given a lease on the address for a server-specified period of time.
When a computer uses a static IP address, it means that the computer is manually configured to
use a specific IP address. One problem with static assignment, which can result from user error
or inattention to detail, occurs when two computers are configured with the same IP address.
This creates a conflict that results in loss of service. Using DHCP to dynamically assign IP
addresses minimizes these conflicts.
6. Introduction to Backbone Network
A backbone network or network backbone is a part of computer network infrastructure that
interconnects various pieces of network, providing a path for the exchange of information
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

between different LANs or subnetworks.[1][2] A backbone can tie together diverse networks in the
same building, in different buildings in a campus environment, or over wide areas. Normally, 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, for example, if a server cluster needs to be accessed by different departments
of a company that are located at different geographical locations. The pieces of the network
connections (for example: ethernet, wireless) that bring these departments together is often
mentioned as network backbone. Network congestion is often taken into consideration while
designing backbones.
There are two very commonly used designs of backbone networks:

Bus Backbone
Star Backbone

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 19
TCP/IP Reference Model
Contents
7. TCP/IP Reference model
8. Description of the TCP/IP Layers
Layer 1Physical layer (P)
Layer 2Data Link layer (D)
Layer 3Network layer (N)
Layer 4Transport layer (T)
Layer 5Application layer (A)
9. Difference between TCP/IP & OSI model
1. TCP/IP Reference model
The TCP/IP model is a description framework for computer network protocols created in the
1970s by DARPA, an agency of the United States Department of Defense. It evolved from
ARPANET, which was the world's first wide area network and a predecessor of the Internet. The
TCP/IP Model is sometimes called the Internet Model or the DoD Model.
The TCP/IP model, or Internet Protocol Suite, describes a set of general design guidelines and
implementations of specific networking protocols to enable computers to communicate over a
network. TCP/IP provides end-to-end connectivity specifying how data should be formatted,
addressed, transmitted, routed and received at the destination. Protocols exist for a variety of
different types of communication services between computers.

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 Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

(more)
Transport Layer
TCP UDP DCCP SCTP RSVP ECN
(more)
Internet Layer
IP (IPv4, IPv6) ICMP ICMPv6 IGMP
IPsec
(more)
Link Layer
ARP/InARP

NDP

OSPF

Tunnels (L2TP)

PPP

Media

Access

Control (Ethernet,

DSL,

ISDN,

FDDI)

(more)
Physical Layer

TCP/IP, sometimes referred to as the Internet model, has four abstraction layers as defined in
RFC 1122. This layer architecture is often compared with the seven-layer OSI Reference Model;
using terms such as Internet reference model, incorrectly, however, because it is descriptive
while the OSI Reference Model was intended to be prescriptive, hence being a reference model.
2. Description of the TCP/IP Layers
The layers near the top are logically closer to the user application, while those near the bottom
are logically closer to the physical transmission of the data. 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, for example, Ethernet and collision detection, while the
lower layers avoid having to know the details of each and every application and its protocol.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

This abstraction also allows upper layers to provide services that the lower layers cannot, or
choose not to, provide. Again, the original OSI Reference Model was extended to include
connectionless services (OSIRM CL). For example, IP is not designed to be reliable and is a best
effort delivery protocol. This means that all transport layer implementations must choose
whether or not to provide reliability and to what degree. UDP provides data integrity (via a
checksum) but does not guarantee delivery; TCP provides both data integrity and delivery
guarantee (by retransmitting until the receiver acknowledges the reception of the packet).
This model lacks the formalism of the OSI reference model and associated documents, but the
IETF does not use a formal model and does not consider this a limitation, as in the comment by
David D. Clark, "We reject: kings, presidents and voting. We believe in: rough consensus and
running code." Criticisms of this model, which have been made with respect to the OSI
Reference Model, often do not consider ISO's later extensions to that model.

Encapsulation of application data descending through the TCP/IP layers


1. For multi-access links with their own addressing systems (e.g. Ethernet) an address
mapping protocol is needed. Such protocols can be considered to be below IP but above
the existing link system. While the IETF does not use the terminology, this is a sub
network dependent convergence facility according to an extension to the OSI model, the
Internal Organization of the Network Layer (IONL).
2. ICMP & IGMP operate on top of IP but do not transport data like UDP or TCP. Again,
this functionality exists as layer management extensions to the OSI model, in its
Management Framework (OSIRM MF).
3. The SSL/TLS library operates above the transport layer (uses TCP) but below application
protocols. Again, there was no intention, on the part of the designers of these protocols,
to comply with OSI architecture.
4. The link is treated like a black box here. This is fine for discussing IP (since the whole
point of IP is it will run over virtually anything). The IETF explicitly does not intend to
discuss transmission systems, which is a less academic but practical alternative to the OSI
Reference Model.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

The following is a description of each layer in the TCP/IP networking model starting from the
lowest level.
Layer 1Physical layer (P)
The Physical Layer defines the electrical and physical specifications for devices. In particular, it
defines the relationship between a device and a transmission medium, such as a copper or optical
cable. This includes the layout of pins, voltages, cable specifications, hubs, repeaters, network
adapters, host bus adapters (HBA used in storage area networks) and more.
To understand the function of the Physical Layer, contrast it with the functions of the Data Link
Layer. Think of the Physical Layer as concerned primarily with the interaction of a single device
with a medium, whereas the Data Link Layer is concerned more with the interactions of multiple
devices (i.e., at least two) with a shared medium. Standards such as RS-232 do use physical
wires to control access to the medium.
The major functions and services performed by the Physical Layer are:

Establishment and termination of a connection to a communications medium.


Participation in the process whereby the communication resources are effectively shared
among multiple users. For example, contention resolution and flow control.
Modulation, or conversion between the representation of digital data in user equipment
and the corresponding signals transmitted over a communications channel. 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, although it must be remembered that the logical SCSI
protocol is a Transport Layer protocol that runs over this bus. Various Physical Layer Ethernet
standards are also in this layer; Ethernet incorporates both this layer and the Data Link Layer.
The same applies to other local-area networks, such as token ring, FDDI, ITU-T G.hn and IEEE
802.11, as well as personal area networks such as Bluetooth and IEEE 802.15.4.
Layer 2Data Link layer (D)
The Link Layer is the networking scope of the local network connection to which a host is
attached. This regime is called the link in Internet literature. This is the lowest component layer
of the Internet protocols, as TCP/IP is designed to be hardware independent. As a result TCP/IP
has been implemented on top of virtually any hardware networking technology in existence.
The Link Layer is used to move packets between the Internet Layer interfaces of two different
hosts on the same link. The processes of transmitting and receiving packets on a given link can
be controlled both in the software device driver for the network card, as well as on firmware or
specialized chipsets. These will perform data link functions such as adding a packet header to
prepare it for transmission, then actually transmit the frame over a physical medium. The TCP/IP
model includes specifications of translating the network addressing methods used in the Internet
Protocol to data link addressing, such as Media Access Control (MAC), however all other
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

aspects below that level are implicitly assumed to exist in the Link Layer, but are not explicitly
defined.
The Link Layer is also the layer where packets may be selected to be sent over a virtual private
network or other networking tunnel. In this scenario, 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. Such a connection, or virtual link, 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, the TCP/IP model does not dictate a strict hierarchical
encapsulation sequence.
Layer 3Network layer (N)
The Internet Layer solves the problem of sending packets across one or more networks.
Internetworking requires sending data from the source network to the destination network. This
process is called routing.
In the Internet Protocol Suite, the Internet Protocol performs two basic functions:

Host addressing and identification: This is accomplished with a hierarchical addressing


system (see IP address).
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.

IP can carry data for a number of different upper layer protocols. These protocols are each
identified by a unique protocol number: for example, Internet Control Message Protocol (ICMP)
and Internet Group Management Protocol (IGMP) are protocols 1 and 2, respectively.
Some of the protocols carried by IP, 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. This illustrates the differences in the architecture of the
TCP/IP stack of the Internet and the OSI model.
Layer 4Transport layer (T)
The Transport Layer's responsibilities include end-to-end message transfer capabilities
independent of the underlying network, along with error control, segmentation, flow control,
congestion control, and application addressing (port numbers). End to end message transmission
or connecting applications at the transport layer can be categorized as either connection-oriented,
implemented in Transmission Control Protocol (TCP), or connectionless, implemented in User
Datagram Protocol (UDP).
The Transport Layer can be thought of as a transport mechanism, e.g., a vehicle with the
responsibility to make sure that its contents (passengers/goods) reach their destination safely and
soundly, unless another protocol layer is responsible for safe delivery.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

The Transport Layer provides this service of connecting applications through the use of service
ports. Since IP provides only a best effort delivery, the Transport Layer is the first layer of the
TCP/IP stack to offer reliability. IP can run over a reliable data link protocol such as the HighLevel Data Link Control (HDLC). Protocols above transport, such as RPC, also can provide
reliability.
For example, 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.e. 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, connection-oriented
transport mechanism. It is Message-stream-oriented not byte-stream-oriented like TCP and
provides multiple streams multiplexed over a single connection. It also provides multi-homing
support, in which a connection end can be represented by multiple IP addresses (representing
multiple physical interfaces), such that if one fails, the connection is not interrupted. It was
developed initially for telephony applications (to transport SS7 over IP), but can also be used for
other applications.
User Datagram Protocol is a connectionless datagram protocol. Like IP, it is a best effort,
"unreliable" protocol. Reliability is addressed through error detection using a weak checksum
algorithm. UDP is typically used for applications such as streaming media (audio, video, Voice
over IP etc) where on-time arrival is more important than reliability, or for simple
query/response applications like DNS lookups, where the overhead of setting up a reliable
connection is disproportionately large. Real-time Transport Protocol (RTP) is a datagram
protocol that is designed for real-time data such as streaming audio and video.
TCP and UDP are used to carry an assortment of higher-level applications. The appropriate
transport protocol is chosen based on the higher-layer protocol application. For example, the File
Transfer Protocol expects a reliable connection, but the Network File System (NFS) assumes that
the subordinate Remote Procedure Call protocol, not transport, will guarantee reliable transfer.
Other applications, such as VoIP, can tolerate some loss of packets, but not the reordering or
delay that could be caused by retransmission.
The applications at any given network address are distinguished by their TCP or UDP port. By
convention certain well known ports are associated with specific applications.
Layer 5Application layer (A)
The Application Layer refers to the higher-level protocols used by most applications for network
communication. Examples of application layer protocols include the File Transfer Protocol
(FTP) and the Simple Mail Transfer Protocol (SMTP). Data coded according to application layer
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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)), which in turn use
lower layer protocols to effect actual data transfer.
Since the IP stack defines no layers between the application and transport layers, the application
layer must include any protocols that act like the OSI's presentation and session layer protocols.
This is usually done through libraries.
Application Layer protocols generally treat the transport layer (and lower) protocols as "black
boxes" which provide a stable network connection across which to communicate, although the
applications are usually aware of key qualities of the transport layer connection such as the end
point IP addresses and port numbers. As noted above, layers are not necessarily clearly defined
in the Internet protocol suite. Application layer protocols are most often associated with client
server applications, and the commoner servers have specific ports assigned to them by the
IANA: HTTP has port 80; Telnet has port 23; etc. Clients, on the other hand, tend to use
ephemeral ports, i.e. port numbers assigned at random from a range set aside for the purpose.
Transport and lower level layers are largely unconcerned with the specifics of application layer
protocols. Routers and switches do not typically "look inside" the encapsulated traffic to see
what kind of application protocol it represents, rather they just provide a conduit for it. However,
some firewall and bandwidth throttling applications do try to determine what's inside, as with the
Resource Reservation Protocol (RSVP). It's also sometimes necessary for Network Address
Translation (NAT) facilities to take account of the needs of particular application layer protocols.
(NAT allows hosts on private networks to communicate with the outside world via a single
visible IP address using port forwarding, and is an almost ubiquitous feature of modern domestic
broadband routers).

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 20 & 21
Hypertext Documents, HTTP, DNS, Network Security
Contents
1.
2.
3.
4.

Introduction to Hypertext Documents


Introduction to HTTP
Introduction to DNS
Introduction to Network Security

1. Introduction to Hypertext Documents


Hypertext, made famous by the World Wide Web, is most simply a way of constructing
documents that reference other documents. Within a hypertext document, a block of text can be
tagged as a hypertext link pointing to another document. When viewed with a hypertext browser,
the link can be activated to view the other document. Of course, if you're reading this document,
you're already familiar with the concept.
Hypertext's original idea was to take advantage of electronic data processing to organize large
quantities of information that would otherwise overwhelm a reader. Two hundred years ago, the
printing press made possible a similar innovation - the encyclopedia. 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. Early experience with
hypertext suggests that it may ultimately yield an additional order of magnitude increase, by
making directly accessible information that would otherwise be relegated to a bibliography.
Hypertext's limiting factor appears not to be the physical size of some books, but rather the
ability of the reader to navigate increasingly complex search structures. Currently, additional
increases in human information processing ability seem tied to developing more sophisticated
automated search tools, though the present technology presents possibilities that remain far from
fully explored.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Augmenting basic hypertext with graphics, more complex user input fields and dynamically
generated documents adds considerable power and flexibility to this concept. Hypertext, though
still useful for its original goal of organizing large quantities of information, becomes a simple,
general purpose user interface that fits neatly into the increasingly popular client-server model. It
does not seem difficult to image a day when restaurant orders, for example, will be taken using a
hand-held hypertext terminal, relayed directly to the kitchen for preparation, and simultaneously
logged to a database for later analysis by management.
Characteristics of good hypertext documents
The flexibility of hypertext gives free range to the author's creativity, but good hypertext appears
to have some common characteristics:

Lots of documents. Much of the hypertext's power comes from its ability to make large
quantities of information accessible. If all the text in your system can be printed on ten
pages, it would be just as simple to read through it from beginning to end and forget all
this hypertext silliness. On the other hand, if there are ten million pages of text in your
system, then someone could follows a link on atomic energy and ultimately hope to find a
description of the U-238 decay process.
Lots of links. If each document has just one link, then it is little more than normal,
sequential text. A hypertext document should present the reader with several links,
offering a choice about where to go next. Ideally, a document should present as many
relevant links as the reader can easily comprehend and select among.
Range of detail. The great advantage of hypertext is that it permits readers to explore to
a breadth and depth that is simply not feasible in print. To make this accessible, available
hypertext documents should range from the broadest possible overview of a subject,
down to its gritty details. Imagine the Encyclopedia Britannica, all thirty-odd volumes of
it, searchable online and with each article possessing links to a half dozen reference
documents with even more detailed subject coverage. This is the potential of hypertext.
Correct links. This may seem trivial, but it's amazing how many Web links point
nowhere. In general, be careful linking to any hypertext document not under your direct
control. Can you count on it to be there later?
2. Introduction to HTTP

HTTP (Hypertext Transfer Protocol) is the set of rules for transferring files (text, graphic images,
sound, video, and other multimedia files) on the World Wide Web. As soon as a Web user opens
their Web browser, the user is indirectly making use of HTTP. HTTP is an application protocol
that runs on top of the TCP/IP suite of protocols (the foundation protocols for the Internet).
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. Any Web server
machine contains, in addition to the Web page files it can serve, an HTTP daemon, a program
that is designed to wait for HTTP requests and handle them when they arrive. Your Web browser
is an HTTP client, sending requests to server machines. 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 ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

clicking on a hypertext link, the browser builds an HTTP request and sends it to the Internet
Protocol address (IP address) indicated by the URL. The HTTP daemon in the destination server
machine receives the request and sends back the requested file or files associated with the
request. (A Web page often consists of more than one file.)
The latest version of HTTP is HTTP 1.1.
3. Introduction to DNS
The Domain Name System (DNS) is a hierarchical naming system built on a distributed
database for computers, services, or any resource connected to the Internet or a private network.
It associates various information with domain names assigned to each of the participating
entities. Most importantly, 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.
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. For
example, the domain name www.example.com translates to the addresses 192.0.32.10 (IPv4) and
2620:0:2d0:200:10 (IPv6).
The Domain Name System makes it possible to assign domain names to groups of Internet
resources and users in a meaningful way, independent of each entity's physical location. Because
of this, 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. Internet domain names are easier to remember than IP
addresses such as 208.77.188.166 (IPv4) or 2001:db8:1f70: 999:de8:7648:6e8 (IPv6). 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.
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.
Authoritative name servers are assigned to be responsible for their particular domains, and in
turn can assign other authoritative name servers for their sub-domains. 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.
In general, the Domain Name System also stores other types of information, such as the list of
mail servers that accept email for a given Internet domain. By providing a worldwide, distributed
keyword-based redirection service, the Domain Name System is an essential component of the
functionality of the Internet.
Other identifiers such as RFID tags, UPC codes, International characters in email addresses and
host names, and a variety of other identifiers could all potentially utilize DNS.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

The Domain Name System also specifies the technical functionality of this database service. It
defines the DNS protocol, a detailed definition of the data structures and communication
exchanges used in DNS, as part of the Internet Protocol Suite.
4. Introduction to Network Security
Network security involves all activities that organizations, enterprises, and institutions undertake
to protect the value and ongoing usability of assets and the integrity and continuity of operations.
An effective network security strategy requires identifying threats and then choosing the most
effective set of tools to combat them.
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, 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); access attacks (which exploit network vulnerabilities in
order to gain entry to e-mail, databases, or the corporate network); 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, such as posing as a technical support person and asking for people's passwords.
Network security tools include:
Antivirus software packages : These packages counter most virus threats if regularly updated
and
correctly
maintained.
Secure network infrastructure : Switches and routers have hardware and software features that
support secure connectivity, perimeter security, intrusion protection, identity services, and
security
management.
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.
Virtual private networks : These networks provide access control and data encryption between
two different computers on a network. This allows remote workers to connect to the network
without
the
risk
of
a
hacker
or
thief
intercepting
data.
Identity services : These services help to identify users and control their activities and
transactions on the network. Services include passwords, digital certificates, and digital
authentication
keys.
Encryption : Encryption ensures that messages cannot be intercepted or read by anyone other
than
the
authorized
recipient.
Security management : This is the glue that holds together the other building blocks of a strong
security solution.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

None of these approaches alone will be sufficient to protect a network, but when they are layered
together, they can be highly effective in keeping a network safe from attacks and other threats to
security. In addition, well-thought-out corporate policies are critical to determine and control
access to various parts of the network.

Lecture: 20 & 21
An Overview of C: Constants, Variables and Data types, operators and Expressions.
Contents
1. Introduction to C
2. C Programming
3. Introduction to Constants
Types of Constants
4. Introduction to Variables
Declaration of Variables
Constant Variables
5. Introduction to Data types
Types of Data types
About Data type conversion
Data type Modifiers
6. Introduction to Operators
Types of Operators
7. Introduction to Expressions
1. 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.
Although C was designed for implementing system software, it is also widely used for
developing portable application 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. C has greatly influenced many
other popular programming languages, most notably C++, which began as an extension to C.
2. C Programming
A SIMPLE C PROGRAM
The following program is written in the C programming language.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

#include <stdio.h>
main()
{
printf("Programming in C is easy.\n");
}

Sample Program Output


Programming in C is easy.
A NOTE ABOUT C PROGRAMS
In C, lowercase and uppercase characters are very important! All commands in C must be
lowercase. The C programs starting point is identified by the word
main()
This informs the computer as to where the program actually starts. The brackets that follow the
keyword main indicate that there are no arguments supplied to this program.
The two braces, { and }, signify the begin and end segments of the program. The purpose of the
statment
#include <stdio.h>
is to allow the use of the printf statement to provide program output. Text to be displayed by
printf() must be enclosed in double quotes. The program has only one statement
printf("Programming in C is easy.\n");
printf() is actually a function (procedure) in C that is used for printing variables and text. Where
text appears in double quotes "", it is printed without modification. There are some exceptions
however. This has to do with the \ and % characters. These characters are modifiers, and for the
present the \ followed by the n character represents a newline character. Thus the program prints
Programming in C is easy.
and the cursor is set to the beginning of the next line. As we shall see later on, what follows the \
character will determine what is printed, ie, a tab, clear screen, clear line etc. Another important
thing to remember is that all C statements are terminated by a semi-colon.
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, use lower-case and try not to capitalise variable names
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 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, as a number of well defined
sections.
/* HEADER SECTION
*/
/* Contains name, 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. Introduction to Constants

A constant can be defined as a quantity that does not change during the execution of a
program.
#include <stdio.h>
void main(void)
{
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

int a = 10;
printf(%d,a);
}
Program Output
10
Here we are declaring a variable a with its initial value 10. 10 here is an integer constant and
every time you try to execute this program, the output will always be 10.
Types of Constants
Integer Constant
An integer constant must have at least one digit and should not have decimal point. It could
either be positive or negative.
Real Constant
A real constant must have at least one digit and must have a decimal point.
Character Constant
A character constant should be only one character and must be enclosed in single quotes e.g.
A, b, etc.
4. Introduction to Variables
Variables must begin with a character or underscore, and may be followed by any combination
of characters, underscores, or the digits 0 - 9. The following is a list of valid variable names,
summary
exit_flag
i
Jerry7
Number_of_moves
_valid_flag
You should ensure that you use meaningful names for your variables. 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 .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. In C all the variables
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

should be declared before it can be used. Also you cannot re-declare a variable once it has been
already declared.
The general pattern for declaring a variable is as follows:
e.g.:
int age;
int age, count, i,j;
float amount, rateofinterest, totalbalance;
char ch;
Constant Variables
A constant variable is also called a named constant. A named constant is really a variable whose
content is read-only and cannot be changed while the program is running. Here is a declaration
of a named constant.
const float pi = 3.14;
It looks just like a regular variable declaration except that the word const appears before the data
type name. const is a qualifier that tells the compiler to make the variable read only. Its value
will remain constant throughout the programs execution.
An initialization value must be given when declaring a variable with the const qualifier, or an
error will result when the program is compiled. 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. Introduction to Data types
C language data types, Primary data type, Integer Type, Floating Point Types, Void Type,
Character Type, Size and Range of Data Types on 16 bit machine, derived data type, Declaration
of Variables, User defined type declaration, Declaration of Storage Class, auto, static, extern,
register, Defining Symbolic Constants, Declaring Variable as Constant and Volatile Variable
All C Compilers accept the following fundamental data types.
1.

Integer

int

2.

Character

char

3.

Floating Point

float

4. Double precision floating point double


5.

Void

void

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

The size and range of each data type is given in the table below.
DATA
TYPE

RANGE OF VALUES

char

-128 to 127

Int

-32768 to +32767

float

3.4 e-38 to 3.4 e+38

double

1.7 e-308 to 1.7 e+308

Types of Data Types


The four basic data types are:

INTEGER
These are whole numbers, both positive and negative. Unsigned integers (positive values
only) are supported. In addition, there are short and long integers.
The keyword used to define integers is,
int
An example of an integer value is 32. An example of declaring an integer variable called
sum is,
int sum;
sum = 20;

FLOATING POINT
These are numbers which contain fractional parts, both positive and negative. The
keyword used to define float variables is,
float
An example of a float value is 34.12. An example of declaring a float variable called
money is,
float money;
money = 0.12;

DOUBLE
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

These are exponetional numbers, both positive and negative. The keyword used to define
double variables is,
double
An example of a double value is 3.0E2. An example of declaring a double variable called
big is,
double big;
big = 312E+7;

CHARACTER
These are single characters. The keyword used to define character variables is,
char
An example of a character value is the letter A. An example of declaring a character
variable called letter is,
char letter;
letter = 'A';
Note the assignment of the character A to the variable letter is done by enclosing the
value in single quotes. Remember the golden rule: Single character - Use single quotes.

Sample program illustrating each data type


#include < stdio.h >
main()
{
int sum;
float money;
char letter;
double pi;
sum = 10;
money = 2.21;
letter = 'A';
pi = 2.01E6;

/* assign integer value */


/* assign float value */
/* assign character value */
/* assign a double value */

printf("value of sum = %d\n", sum );


printf("value of money = %f\n", money );
printf("value of letter = %c\n", letter );
printf("value of pi = %e\n", pi );
}
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Sample program output


value of sum = 10
value of money = 2.210000
value of letter = A
value of pi = 2.010000e+06
MORE ABOUT FLOAT AND DOUBLE VARIABLES
C displays both float and double variables to six decimal places. This does NOT refer to the
precision (accuracy) of which the number is actually stored, 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,
#include <stdio.h>
main()
{
int sum = 100;
char letter = 'Z';
float set1 = 23.567;
double num2 = 11e+23;
printf("Integer variable is %d\n", sum);
printf("Character is %c\n", letter);
printf("Float variable is %f\n", set1);
printf("Double variable is %e\n", num2);
}

Sample program output


Integer variable is 100
Character variable is Z
Float variable is 23.567000
Double variable is 11.000000e23
To change the number of decimal places printed out for float or double variables, modify the %f
or %e to include a precision value, eg,
printf("Float variable is %.2f\n", set1 );

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

In this case, the use of %.2f limits the output to two decimal places, and the output now looks
like

Sample program output


Integer variable is 100
Character variable is Z
Float variable is 23.56
Double variable is 11.000000e23
About Data Type Conversion
Consider the following program,
#include <stdio.h>
main()
{
int value1 = 12, value2 = 5;
float answer = 0;
answer = value1 / value2;
printf("The value of %d divided by %d is %f\n",value1,value2,answer );
}

Sample program output


The value of 12 divided by 5 is 2.000000
Even though the above declaration seems to work, it is not always 100% reliable. Note how
answer does not contain a proper fractional part (ie, all zero's).
To ensure that the correct result always occurs, the data type of value1 and value2 should be
converted to a float type before assigning to the float variable answer. The following change
illustrates how this can be done,
answer = (float)value1 / (float)value2;
Different Types of Integers
A normal integer is limited in range to +-32767. This value differs from computer to computer. It
is possible in C to specify that an integer be stored in four memory locations instead of the
normal two. This increases the effective range and allows very large integers to be stored. The
way in which this is done is as follows,
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

long int big_number = 245032L;


To display a long integer, use %l, ie,
printf("A larger number is %l\n", big_number );
Short integers are also available, eg,
short int small_value = 114h;
printf("The value is %h\n", small_value);
Unsigned integers (positive values only) can also be defined.
The size occupied by integers varies upon the machine hardware. ANSI C (American National
Standards Institute) has tried to standardise upon the size of data types, and hence the number
range of each type.
The following information is from the on-line help of the Turbo C compiler,
Type: int
Integer data type
Variables of type int are one word in length. They can be signed (default) or unsigned, which
means they have a range of -32768 to 32767 and 0 to 65535, respectively.
Type modifiers: signed, unsigned, short, long A type modifier alters the meaning of the base type
to yield a new type. Each of the above can be applied to the base type int. The modifiers signed
and unsigned can be applied to the base type char. In addition, long can be applied to double.
When the base type is ommitted from a declaration, int is assumed.
Examples:
long
x; /* int is implied */
unsigned char ch;
signed int
i; /* signed is default */
unsigned long int l; /* int ok, not needed */
Data type Modifiers
Let us consider an example of a program, which will accept an age from the user to do some
processing. Because the age is represented in numbers, so we will have to use the integer data
type int. We all know that even under exceptional case an age of a person cannot exceed more
than 150. Now, that we are using an integer data type it occupies 2 Bytes of memory, which
would not be required to represent the value 150. Instead the value 150 could easily be saved in
an integer of 1 Byte in size, but the default size of an integer is 2 Bytes. So we have a problem
here.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Well, not that we cant solve. To override the default nature of a data type, C has provided us
with data type modifiers as follows:
Signed
By default all data types are declared as signed. Signed means that the data type is capable of
storing negative values.
Unsigned
To modify a data types behavior so that it can only store positive values, we require to use the
data type unsigned.
For example, if we were to declare a variable age, we know that an age cannot be represented by
negative values and hence, we can modify the default behavior of the int data type as follows:
unsigned int age;
This declaration allows the age variable to store only positive values. 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. In such cases we use the data type modifier long. This doubles the storage
capacity of the data type being used. E.g. long int annualsalary will make the storage capacity of
variable annualsalary to 4 bytes.
The exception to this is long double, which modifies the size of the double data type to 10 bytes.
Please note that in some compilers this has no effect.
Short
If long data type modifier doubles the size, short on the other hand reduces the size of the data
type to half. Please refer to the example of age variable to explain the concept of data type
modifiers. The same will be achieved by providing the declaration of age as follows:
short int age;
This declaration above, will provide the variable age with only 1 byte and its data range will be
from -128 to 127.
6. Introduction to Operators
An operator is a symbol which helps the user to command the computer to do a certain
mathematical or logical manipulations. Operators are used in C language program to
operate on data and variables. C has a rich set of operators which can be explained as.
Types of Operators
ARITHMETIC OPERATORS
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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

Divide

sum = sum / 2; 4

Addition

sum = sum + 2; 4

Subtraction -

sum = sum -2;

Increment ++

++sum;

Decrement --

--sum;

Modulus

sum = sum % 3; 4

The following code fragment adds the variables loop and count together, leaving the result in the
variable sum
sum = loop + count;
Note: If the modulus % sign is needed to be displayed as part of a text string, use two, ie %%
#include <stdio.h>
main()
{
int sum = 50;
float modulus;
modulus = sum % 10;
printf("The %% of %d by 10 is %f\n", sum, modulus);
}

Sample Program Output


The % of 50 by 10 is 0.000000
Increment
The increment operator adds one to the value of the variable. The following code fragment (part
of a program) adds one to the value of count, so that after the statement is executed, count has a
value of 5.
int count = 4;
count++;
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Decrement
The decrement operator subtracts one from the value of the variable. The following code
fragment (part of a program) subtracts one from the value of count, so that after the statement is
executed, count has a value of 3.
int count = 4;
count--;
Modulus
The modulus operator assigns the remainder left over after a division the value of the variable.
The following code fragment (part of a program) uses the modulus operator to calculate the
modulus of 20 % 3. To work this out, divide 20 by 3.
PRE/POST INCREMENT/DECREMENT OPERATORS
PRE means do the operation first followed by any assignment operation. POST means do the
operation after any assignment operation. Consider the following statements
++count;
count++;

/* PRE Increment, means add one to count */


/* POST Increment, means add one to count */

In the above example, because the value of count is not assigned to any variable, the effects of
the PRE/POST operation are not clearly visible.
Lets examine what happens when we use the operator along with an assignment operation.
Consider the following program,
#include <stdio.h>
main()
{
int count = 0, loop;
loop = ++count; /* same as count = count + 1; loop = count; */
printf("loop = %d, count = %d\n", loop, count);
loop = count++; /* same as loop = count; count = count + 1; */
printf("loop = %d, count = %d\n", loop, count);
}

Sample Program Output


loop = 1, count = 1
loop = 1; count = 2
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

If the operator precedes (is on the left hand side) of the variable, the operation is performed first,
so the statement
loop = ++count;
really means increment count first, then assign the new value of count to loop.
7. Introduction to Expression
Expression in C programming language - Arithmetic Expressions, Evaluation of Expressions,
Precedence in Arithmetic Operators, Rules for evaluation of expression, Type conversions in
expressions, Implicit type conversion, Explicit Conversion and Operator precedence and
associativity.
Arithmetic Expressions
An expression is a combination of variables constants and operators written according to the
syntax of C language. In C every expression evaluates to a value i.e., every expression results in
some value of a certain type that can be assigned to a variable. Some examples of C expressions
are shown in the table given below.

Algebraic
Expression
axbc

C Expression
a*bc

(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;
Variable is any valid C variable name. When the statement is encountered, the expression is
evaluated first and then replaces the previous value of the variable on the left hand side. All
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

variables used in the expression must be assigned values before evaluation is attempted.
Example of evaluation statements are

x=a*bc
y=b/c*a
z = a b / c + d;
The following program illustrates the effect of presence of parenthesis in expressions.
.
main ()
{
float a, b, c x, y, z;
a = 9;
b = 12;
c = 3;
x = a b / 3 + c * 2 1;
y = a b / (3 + c) * (2 1);
z = a ( b / (3 + c) * 2) 1;
printf (x = %fn,x);
printf (y = %fn,y);
printf (z = %fn,z);
}
.
output
x = 10.00
y = 7.00
z = 4.00
Precedence in Arithmetic Operators
An arithmetic expression without parenthesis will be evaluated from left to right using the rules
of precedence of operators. There are two distinct priority levels of arithmetic operators in C.
High priority * / %
Low priority + -

Rules for evaluation of expression

First parenthesized sub expression left to right are evaluated.

If parenthesis are nested, the evaluation begins with the innermost sub expression. .
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

The precedence rule is applied in determining the order of application of operators in


evaluating sub expressions.
The associability rule is applied when two or more operators of the same precedence
level appear in the sub expression.
.
Arithmetic expressions are evaluated from left to right using the rules of precedence.
When Parenthesis are used, the expressions within parenthesis assume highest priority.

Type conversions in expressions


Implicit type conversion
C permits mixing of constants and variables of different types in an expression. C automatically
converts any intermediate values to the proper type so that the expression can be evaluated
without loosing any significance. This automatic type conversion is know as implicit type
conversion
During evaluation it adheres to very strict rules and type conversion. If the operands are of
different types the lower type is automatically converted to the higher type before the operation
proceeds. The result is of higher type.
The following rules apply during evaluating expressions

All short and char are automatically converted to int then


1. If one operand is long double, the other will be converted to long double and result will be
long double. .
2. If one operand is double, the other will be converted to double and result will be double.
3. If one operand is float, the other will be converted to float and result will be float.
4. If one of the operand is unsigned long int, the other will be converted into unsigned long int
and result will be unsigned long int.
5. If one operand is long int and other is unsigned int then
.....a. If unsigned int can be converted to long int, then unsigned int operand will be converted as
such and the result will be long int.
.....b. Else Both operands will be converted to unsigned long int and the result will be unsigned
long int.
.6. If one of the operand is long int, the other will be converted to long int and the result will be
long int. .
7. If one operand is unsigned int the other will be converted to unsigned int and the result will be
unsigned int.
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.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Consider for example the calculation of number of female and male students in a class
........................female_students
Ratio =........ ------------------........................ male_students
Since if female_students and male_students are declared as integers, the decimal part will be
rounded off and its ratio will represent a wrong figure. This problem can be solved by converting
locally one of the variables to the floating point as shown below.
Ratio = (float) female_students / male_students
The operator float converts the female_students to floating point for the purpose of evaluation of
the expression. Then using the rule of automatic conversion, the division is performed by
floating point mode, thus retaining the fractional part of the result. The process of such a local
conversion is known as explicit conversion or casting a value. The general form is
(type_name) expression
Operator precedence and associativity
Each operator in C has a precedence associated with it. The precedence is used to determine how
an expression involving more than one operator is evaluated. There are distinct levels of
precedence and an operator may belong to one of these levels. The operators of higher
precedence
are
evaluated
first.
The operators of same precedence are evaluated from right to left or from left to right depending
on the level. This is known as associativity property of an operator.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 23
Decision making & Looping.
Contents
1. Decision Making (Branching)
2. Looping
C provides two styles of flow control:
1. Decision making (Branching)
2. Looping
1. Decision Making (Branching)
Decision making (Branching) is deciding what actions to take and looping is deciding how many
times to take a certain action.
Branching:
Branching is so called because the program chooses to follow one branch or another.
if statement
This is the most simple form of the branching statements.
It takes an expression in parenthesis and an statement or block of statements. if the expression is
true then the statement or block of statements gets executed otherwise these statements are
skipped.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

NOTE: Expression will be assumed to be true if its evaulated values are non-zero.
if statements take the following form:
if (expression)
statement;
or
if (expression)
{
Block of statements;
}
or
if (expression)
{
Block of statements;
}
else
{
Block of statements;
}
or
if (expression)
{
Block of statements;
}
else if(expression)
{
Block of statements;
}
else
{
Block of statements;
}

? : Operator
The ? : operator is just like an if ... else statement except that because it is an operator you can
use it within expressions.
? : is a ternary operator in that it takes three values, this is the only ternary operator C has.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

? : takes the following form:


if condition is true ? then X return value : otherwise Y value;
switch statement:
The switch statement is much like a nested if .. else statement. Its mostly a matter of preference
which you use, switch statement can be slightly more efficient and easier to read.
switch( expression )
{
case constant-expression1:
[case constant-expression2:
[case constant-expression3:
[default : statements4;]
}

statements1;
statements2;]
statements3;]

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. This is achieved by
using break keyword.
What is default condition:
If none of the listed conditions is met then default condition executed.
2. Looping
Loops provide a way to repeat commands and control how many times they are repeated. C
provides a number of looping way.
while loop
The most basic loop in C is the while loop.A while statement is like a repeating if statement.
Like an If statement, if the test condition is true: the statments get executed. The difference is
that after the statements have been executed, the test condition is checked again. If it is still true
the statements get executed again.This cycle repeats until the test condition evaluates to false.
Basic syntax of while loop is as follows:
while ( expression )
{
Single statement
or
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Block of statements;
}
for loop
for loop is similar to while, it's just written differently. for statements are often used to proccess
lists such a range of numbers:
Basic syntax of for loop is as follows:
for( expression1; expression2; expression3)
{
Single statement
or
Block of statements;
}

In the above syntax:


expression1 - Initialisese variables.
expression2 - Condtional expression, as long as this condition is true, loop will keep
executing.
expression3 - expression3 is the modifier which may be simple increment of a variable.
do...while loop
do ... while is just like a while loop except that the test condition is checked at the end of the
loop rather than the start. This has the effect that the content of the loop are always executed at
least once.
Basic syntax of do...while loop is as follows:
do
{
Single statement
or
Block of statements;
}while(expression);
break and continue statements
C provides two commands to control how we loop:
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

break -- exit form loop or switch.


continue -- skip 1 iteration of loop.
You already have seen example of using break statement. Here is an example showing usage of
continue statement.
#include
main()
{
int i;
int j = 10;
for( i = 0; i <= j; i ++ )
{
if( i == 5 )
{
continue;
}
printf("Hello %d\n", i );
}
}
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 ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 24
Arrays, Character Arrays (Strings).
Contents
o
o

Arrays
Character Arrays (Strings)

1. Arrays
Arrays are a data structure which hold multiple variables of the same data type. Consider the
case where a programmer needs to keep track of a number of people within an organisation. So
far, our initial attempt will be to create a specific variable for each user. This might look like,
int name1 = 101;
int name2 = 232;
int name3 = 231;
It becomes increasingly more difficult to keep track of this as the number of variables increase.
Arrays offer a solution to this problem.
An array is a multi-element box, a bit like a filing cabinet, and uses an indexing system to find
each variable stored within it. In C, indexing starts at zero.
Arrays, like other variables in C, must be declared before they can be used.
The replacement of the above example using arrays looks like,
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

int names[4];
names[0] = 101;
names[1] = 232;
names[2] = 231;
names[3] = 0;
We created an array called names, which has space for four integer variables. You may also see
that we stored 0 in the last space of the array. This is a common technique used by C
programmers to signify the end of an array.
Arrays have the following syntax, 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. In C, array elements start with 0.
Assigning values to array elements is done by,
x[10] = g;
and assigning array elements to a variable is done by,
g = x[10];
In the following example, a character based array named word is declared, and each element is
assigned a character. The last element is filled with a zero value, to signify the end of the
character string (in C, there is no string type, so character based arrays are used to hold strings).
A printf statement is then used to print out all elements of the array.
/* Introducing array's, 2 */
#include <stdio.h>
main()
{
char word[20];
word[0] = 'H';
word[1] = 'e';
word[2] = 'l';
word[3] = 'l';
word[4] = 'o';
word[5] = 0;
printf("The contents of word[] is -->%s\n", word );
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Sample Program Output


The contents of word[] is Hello
Declaring Arrays
Arrays may consist of any of the valid data types. Arrays are declared along with all other
variables in the declaration section of the program.
/* Introducing array's */
#include <stdio.h>
main()
{
int numbers[100];
float averages[20];
numbers[2] = 10;
--numbers[2];
printf("The 3rd element of array numbers is %d\n", numbers[2]);
}

Sample Program Output


The 3rd element of array numbers is 9
The above program declares two arrays, assigns 10 to the value of the 3rd element of array
numbers, decrements this value ( --numbers[2] ), and finally prints the value. The number of
elements that each array is to have is included inside the square brackets.
Assigning Initial Values To Arrays
The declaration is preceded by the word static. The initial values are enclosed in braces, eg,
#include <stdio.h>
main()
{
int x;
static int values[] = { 1,2,3,4,5,6,7,8,9 };
static char word[] = { 'H','e','l','l','o' };
for( x = 0; x < 9; ++x )
printf("Values [%d] is %d\n", x, values[x]);
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Sample Program Output


Values[0] is 1
Values[1] is 2
....
Values[8] is 9
The previous program declares two arrays, values and word. Note that inside the squarebrackets
there is no variable to indicate how big the array is to be. In this case, C initializes the array to
the number of elements that appear within the initialize braces. So values consist of 9 elements
(numbered 0 to 8) and the char array word has 5 elements.
The following program shows how to initialise all the elements of an integer based array to
the value 10, using a for loop to cycle through each element in turn.
#include <stdio.h>
main()
{
int count;
int values[100];
for( count = 0; count < 100; count++ )
values[count] = 10;
}
Multi Dimensioned Arrays
Multi-dimensioned arrays have two or more index values which specify the element in the array.
multi[i][j]
In the above example, the first index value i specifies a row index, whilst j specifies a column
index.
Declaration and calculations
int
m1[10][10];
static int m2[2][2] = { {0,1}, {2,3} };
sum = m1[i][j] + m2[k][l];
NOTE the strange way that the initial values have been assigned to the two-dimensional array
m2. Inside the braces are,
{ 0, 1 },
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

{ 2, 3 }
Remember that arrays are split up into row and columns. The first is the row, the second is the
column. Looking at the initial values assigned to m2, they are,
m2[0][0] = 0
m2[0][1] = 1
m2[1][0] = 2
m2[1][1] = 3
2. Character Arrays (Strings)
#include <stdio.h>
main()
{
static char name1[] = {'H','e','l','l','o'};
static char name2[] = "Hello";
printf("%s\n", name1);
printf("%s\n", name2);
}

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, ie,
in name2[5], whilst name1 has not. This can often result in garbage characters being printed on
the end. To insert a null at the end of the name1 array, the initialization can be changed to,
static char name1[] = {'H','e','l','l','o','\0'};
Consider the following program, which initialises the contents of the character based array word
during the program, using the function strcpy, which necessitates using the include file string.h
#include <stdio.h>
#include <string.h>
main()
{
char word[20];
strcpy( word, "hi there." );
printf("%s\n", word );
}
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Sample Program Output


hi there.
Some Variations In Declaring Arrays
int numbers[10];
static int numbers[10] = { 34, 27, 16 };
static int numbers[] = { 2, -3, 45, 79, -14, 5, 9, 28, -1, 0 };
static char text[] = "Welcome to New Zealand.";
static float radix[12] = { 134.362, 1913.248 };
double radians[1000];
Reading Character Strings from The Keyboard
Character based arrays are often refered to in C as strings. C does not support a string type, so
character based arrays are used in place of strings. The %s modifier to printf() and scanf() is used
to handle character based arrays. This assumes that a 0 or NULL value is stored in the last
element of the array. Consider the following, which reads a string of characters (excluding
spaces) from the keyboard.
char string[18];
scanf("%s", string);
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'
....
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.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 25 & 26
Structure and Union in C : Defining structure, Declaring variables, Accessing structure
members, structure initialization
Contents
Introduction to Structure
Need of Structure
Defining Structure
Declaring Structure
Complex Structure
Accessing Structure Members
Structure initialization
Introduction to Union
1. Introduction to Structure
In some programming contexts, you need to access multiple data types under a single name for
easier data manipulation; for example you want to refer to address with multiple data like house
number, street, zip code, country. C supports structure which allows you to wrap one or more
variables with different data types. A structure can contain any valid data types like int, char,
float even arrays or even other structures. Each variable in structure is called a structure member.
2. 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. If we need to use a collection of
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

different data type items it is not possible using an array. When we require using a collection of
different data items of different data types we can use a structure. Structure is a method of
packing data of different types. A structure is a convenient method of handling a group of related
data items of different data types.
general format of structure definition
struct tag_name
{
data type member1;
data type member2;

}
Example:
struct lib_books
{
char title[20];
char author[15];
int pages;
float price;
};
The keyword struct declares a structure to holds the details of four fields namely title, author
pages and price. These are members of the structures. Each member may belong to different or
same data type. The tag name can be used to define objects that have the tag names structure.
The structure we just declared is not a variable by itself but a template for the structure.
We can declare structure variables using the tag name any where in the program. For example
the statement
struct lib_books book1,book2,book3;
declares book1,book2,book3 as variables of type struct lib_books each declaration has four
elements of the structure lib_books. The complete structure declaration might look like this
struct lib_books
{
char title[20];
char author[15];
int pages;
float price;
};
struct lib_books, book1, book2, book3;
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

structures do not occupy any memory until it is associated with the structure variable such as
book1. the template is terminated with a semicolon. While the entire declaration is considered as
a statement, each member is declared independently for its name and type in a separate statement
inside the template. The tag name such as lib_books can be used to declare structure variables of
its
data
type
later
in
the
program.
We can also combine both template declaration and variables declaration in one statement, the
declaration

struct lib_books
{
char title[20];
char author[15];
int pages;
float price;
} book1,book2,book3;
is valid. The use of tag name is optional for example
struct
{

}
book1, book2, book3 declares book1,book2,book3 as structure variables representing 3 books
but does not include a tag name for use in the declaration.
A structure is usually defines before main along with macro definitions. In such cases the
structure assumes global status and all the functions can access the structure.
3. Defining Structure
To define a structure, you use struct keyword. Here is the common syntax of structure
definition:
struct struct_name{ structure_member };
The name of structure follows the rule of variable name. Here is an example of defining address
structure:
struct address{
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

unsigned int house_number;


char street_name[50];
int zip_code;
char country[50];
};
The address structure contains house number as an positive integer, street name as a string, zip
code as an integer and country as a string.
4. Declaring Structure
The above example only defines an address structure without creating any structure instance. To
create or declare a structure instance, 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;
...
} instance_1,instance_2 instance_n;
In the second way, you can declare the structure instance at a different location in your source
code after structure definition. Here is structure declaration syntax :
struct struct_name instance_1,instance_2 instance_n;
5. Complex Structure
If a structure contains arrays or other structures, it is called complex structure. For example
address structure is a structure. We can define a complex structure called customer which
contains address structure as follows:
struct customer{
char name[50];
structure address billing_addr;
structure address shipping_addr;
};
6. Accessing Structure Member
To access structure we can use dot operator (.) between structure name and structure member as
follows:
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

structure_name.structure_member
For example to access street name of structure address we do as follows:
struct address billing_addr;
billing_addr.country=US;
If the structure contains another structure, we can use dot operator to access nested structure and
use dot operator again to access variables of nested structure.
struct customer jack;
jack.billing_addr.country=US;
7. 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;
char street_name[50];
int zip_code;
char country[50];
} address;
address billing_addr;
address shipping_addr;
8. Introduction to Union
Unions like structure contain members whose individual data types may differ from one another.
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. Thus unions are used to observe memory. They are useful for application involving
multiple members. Where values need not be assigned to all the members at any one time. Like
structures union can be declared using the keyword union as follows:
union item
{
int m;
float p;
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

char c;
}
code;
this declares a variable code of type union item. The union contains three members each with a
different data type. However we can use only one of them at a time. This is because if only one
location is allocated for union variable irrespective of size. 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. That is
code.m
code.p
code.c
are all valid member variables. During accessing we should make sure that we are accessing the
member
whose
value
is
currently
stored.

For example a statement such as


code.m=456;
code.p=456.78;
printf(%d,code.m);
Would prodece erroneous result.
In effect a union creates a storage location that can be used by one of its members at a time.
When a different number is assigned a new value the new value supercedes the previous
members value. Unions may be used in all places where a structure is allowed. The notation for
accessing a union member that is nested inside a structure remains the same as for the nested
structure.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 27
Copying and comparing structure variables, operations on individual members.
Contents
1. Copying and Comparing Structure variables
2. Operations on individual members
1. Copying and Comparing Structure variables

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

structclass
{
int number;
char name[20];
float marks;
};
main()
{
int x;
structclass student1 = {111,"Rao",72.50};
structclass student2 = {222,"Reddy", 67.00};
structclass student3;
student3 = student2;
x = ((student3.number ==
(student3.marks ==

student2.number) &&
student2.marks)) ? 1 : 0;

if(x == 1)
{
printf("\nstudent2 and student3 are same\n\n");
printf("%d %s %f\n", student3.number,
student3.name,
student3.marks);
}
else
printf("\nstudent2 and student3 are different\n\n");
}
Output
student2 and student3 are same

2. Operations on individual members

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Lecture: 28 & 29
Array of structure, structure with structure, Size of Structure.
Contents
1. Array of Structure
2. Structure with in Structure
3. Structure & sizeof Function
1. 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. We need to use an
array than single variables. We can define an array of structures as shown in the following
example:
structure information
{
int id_no;
char name[20];
char address[20];
char combination[3];
int age;
}
student[100];
An array of structures can be assigned initial values just as any other array can. Remember that
each element is a structure that must be assigned corresponding initial values as illustrated
below.

#include< stdio.h >


{
struct info
{
int id_no;
char name[20];
char address[20];
char combination[3];
int age;
}
struct info std[100];
int I,n;
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

printf(Enter the number of students);


scanf(%d,&n);
printf( Enter Id_no,name address combination age\m);
for(I=0;I < n;I++)
scanf(%d%s%s%s%d,&std[I].id_no,std[I].name,std[I].address,std[I].combination,&std[I].age);
printf(\n Student information);
for (I=0;I< n;I++)
printf(%d%s%s%s%d\n,
,std[I].id_no,std[I].name,std[I].address,std[I].combination,std[I].age);
}
2. Structure with in Structure
A structure may be defined as a member of another structure. In such structures the declaration
of the embedded structure must appear before the declarations of other structures.
struct date
{
int day;
int month;
int year;
};
struct student
{
int id_no;
char name[20];
char address[20];
char combination[3];
int age;
structure date def;
structure date doa;
}oldstudent, newstudent;
the sturucture student constains another structure date as its one of its members.
3. Structure & sizeof Function
sizeof is used to get the size of any data types even with any structures. Let's take a look at
simple program:
01
02

#include <stdio.h>

03
04

typedef struct __address{


int house_number;// 4 bytes

05

char street[50]; // 50 bytes


World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

06

int zip_code; // 4 bytes

07
08

char country[20];// 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",sizeof(address));

15
}
You will never get the size of a structure exactly as you think it must be. 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. So you should be careful when you read the
whole structure from file which was written from other programs.
Lecture: 30
Pointers in C: Introduction, Understanding Pointers
Contents
8. Introduction to Pointers
9. Pointer Declaration
10. Introduction to Address Operator
10. Introduction to Pointers
In c a pointer is a variable that points to or references a memory location in which data is stored.
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.
11. Pointer Declaration
A pointer is a variable that contains the memory location of another variable. The syntax is as
shown below. You start by specifying the type of data stored in the location identified by the
pointer. The asterisk tells the compiler that you are creating a pointer variable. Finally you
give the name of the variable.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

type * variable name


Example:
int *ptr;
float *string;
12. 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;
This places the address where num is stores into the variable ptr. If num is stored in memory
21260 address then the variable ptr has the value 21260.

/* A program to illustrate pointer declaration*/


main()
{
int *ptr;
int sum;
sum=45;
ptr=
printf (\n Sum is %d\n, sum);
printf (\n The sum pointer is %d, ptr);
}
We will get the same result by assigning the address of num to a regular(non pointer) variable.
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. 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.
This means place the value 45 in the memory address pointer by the variable ptr. Since the
pointer contains the address 21260 the value 45 is placed in that memory location. And since this
is the location of the variable num the value also becomes 45. this shows how we can change the
value of pointer directly using a pointer and the indirection pointer.
/* Program to display the contents of the variable their address using pointer variable*/
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

include< stdio.h >


{
int num, *intptr;
float x, *floptr;
char ch, *cptr;
num=123;
x=12.34;
ch=a;
intptr=&x;
cptr=&ch;
floptr=&x;
printf(Num %d stored at address %u\n,*intptr,intptr);
printf(Value %f stored at address %u\n,*floptr,floptr);
printf(Character %c stored at address %u\n,*cptr,cptr);
}

Lecture: 37
Dynamic Memory Allocation and File Management in C : Introductoin, Dynamic memory
allocation, allocating a block of memory: Malloc.
Contents
14. Introduction to Dynamic Memory Allocation
15. Various Functions for purpose of Memory Management
16. Introduction to file Management
17. File Operation Functions in C
18. Memory Management in C
19. Allocating a block of Memory: Malloc
15. Introduction to Dynamic Memory Allocation
In programming we may come across situations where we may have to deal with data, which
is dynamic in nature. The number of data items may change during the executions of a
program. The number of customers in a queue can increase or decrease during the process at
any time. When the list grows we need to allocate more memory space to accommodate
additional data items. Such situations can be handled move easily by using dynamic
techniques. Dynamic data items at run time, thus optimizing file usage of storage space.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Dynamic memory allocation:


The process of allocating memory at run time is known as dynamic memory allocation.
Although c does not inherently have this facility there are four library routines which allow
this function.
Many languages permit a programmer to specify an array size at run time. Such languages
have the ability to calculate and assign during executions, the memory space required by the
variables in the program. But c inherently does not have this facility but supports with
memory management functions, which can be used to allocate and free memory during the
program execution.
16. Various Functions for purpose of Memory Management
The following functions are used in c for purpose of memory management.
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.
17. Introduction to File management
C supports a number of functions that have the ability to perform basic file operations, which
include:
1. Naming a file
2. Opening a file
3. Reading from a file
4. Writing data into a file
5. Closing a file
Real life situations involve large volume of data and in such cases, the console oriented I/O
operations pose two major problems. It becomes cumbersome and time consuming to handle
large volumes of data through terminals. 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, without destroying the data.
This method employs the concept of files to store data.
18. File Operation Functions in C
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

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. 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. The memory space that is
located between these two regions in available for dynamic allocation during the execution of the
program. The free memory region is called the heap. The size of heap keeps changing when
program is executed due to creation and death of variables that are local for functions and blocks.
Therefore it is possible to encounter memory overflow during dynamic allocation process. In
such situations, the memory allocation functions mentioned above will return a null pointer.
20. Allocating a Block of Memory: Malloc
A block mf memory may be allocated using the function malloc. The malloc function reserves a
block of memory of specified size and returns a pointer of type void. This means that we can
assign
it
to
any
type
of
pointer.
It
takes
the
following
form:
ptr=(cast-type*)malloc(byte-size);
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.
Example:
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

x=(int*)malloc(100*sizeof(int));
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.

Lecture: 38
Allocating multiple blocks of memory: Calloc, Releasing the used space: Free,
Altering the size of Block: Realloc.
Contents
1. Allocating Multiple Blocks of Memory: Calloc
2. Releasing the Used Space: Free
3. Altering the Size of Block: Realloc
4. Example
1. 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. The general form of calloc is:
ptr=(cast-type*) calloc(n,elem-size);
The above statement allocates contiguous space for n blocks each size of elements size bytes. All
bytes are initialized to zero and a pointer to the first byte of the allocated region is returned. If
there is not enough space a null pointer is returned.
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

2. Releasing the Used space: Free


Compile time storage of a variable is allocated and released by the system in accordance with its
storage class. With the dynamic runtime allocation, it is our responsibility to release the space
when it is not required. The release of storage space becomes important when the storage is
limited. 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, we may release that block of memory for
future use, using the free function.
free(ptr);
ptr is a pointer that has been created by using malloc or calloc.
3. 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. This process is called reallocation of memory. The general statement of reallocation of
memory is:
ptr=realloc(ptr,newsize);
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. The allocated new block may be or may not be at
the same region.
4. Example
#include< stdio.h >
#include< stdlib.h >
define NULL 0
main()
{
char *buffer;
/*Allocating memory*/
if((buffer=(char *) malloc(10))==NULL)
{
printf(Malloc failed\n);
exit(1);
}
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

printf(Buffer of size %d created \n,_msize(buffer));


strcpy(buffer,Bangalore);
printf(\nBuffer contains:%s\n,buffer);
/*Reallocation*/
if((buffer=(char *)realloc(buffer,15))==NULL)
{
printf(Reallocation failed\n);
exit(1);
}
printf(\nBuffer size modified.\n);
printf(\nBuffer still contains: %s\n,buffer);
strcpy(buffer,Mysore);
printf(\nBuffer now contains:%s\n,buffer);
/*freeing memory*/
free(buffer);
}

Lecture: 39
Defining and opening file, closing file & I/O operation on files.
Contents
Defining and Opening file
Closing File
Various I/O Operation on files
1. Defining and Opening file
If we want to store data in a file into the secondary memory, we must specify certain things
about the file to the operating system. They include the fielname, data structure, purpose.
The general format of the function used for opening a file is
FILE *fp;
fp=fopen(filename,mode);
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

The first statement declares the variable fp as a pointer to the data type FILE. As stated earlier,
File is a structure that is defined in the I/O Library. The second statement opens the file named
filename and assigns an identifier to the FILE type pointer fp. This pointer, which contains all
the information about the file, is subsequently used as a communication link between the system
and
the
program.
The second statement also specifies the purpose of opening the file. The mode does this job.
R open the file for read only.
W open the file for writing only.
A open the file for appending data to it.
Consider the following statements:
FILE *p1, *p2;
p1=fopen(data,r);
p2=fopen(results,w);
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. In case the results
file already exists, its contents are deleted and the files are opened as a new file. If data file does
not exist error will occur.
2. Closing File
The input output library supports the function to close a file; it is in the following format.
fclose(file_pointer);
A file must be closed as soon as all operations on it have been completed. This would close the
file
associated
with
the
file
pointer.
Observe the following program.
.
FILE *p1 *p2;
p1=fopen (Input,w);
p2=fopen (Output,r);
.

fclose(p1);
fclose(p2)
The above program opens two files and closes them after all operations on them are completed,
once a file is closed its file pointer can be reversed on other file.

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

The getc and putc functions are analogous to getchar and putchar functions and handle one
character at a time. The putc function writes the character contained in character variable c to the
file associated with the pointer fp1. ex putc(c,fp1); similarly getc function is used to read a
character from a file that has been open in read mode. c=getc(fp2).
The program shown below displays use of a file operations. The data enter through the keyboard
and the program writes it. Character by character, to the file input. The end of the data is
indicated by entering an EOF character, which is control-z. the file input is closed at this signal.
#include< stdio.h >
main()
{
file *f1;
printf(Data input output);
f1=fopen(Input,w); /*Open the file Input*/
while((c=getchar())!=EOF) /*get a character from key board*/
putc(c,f1); /*write a character to input*/
fclose(f1); /*close the file input*/
printf(\nData output\n);
f1=fopen(INPUT,r); /*Reopen the file input*/
while((c=getc(f1))!=EOF)
printf(%c,c);
fclose(f1);
}
3. Various I/O Operation on files
The getw and putw functions:
These are integer-oriented functions. They are similar to get c and putc functions and are used to
read and write integer values. These functions would be usefull when we deal with only integer
data. The general forms of getw and putw are:
putw(integer,fp);
getw(fp);
/*Example program for using getw and putw functions*/
#include< stdio.h >
main()
{
FILE *f1,*f2,*f3;
int number I;
printf(Contents of the data file\n\n);
f1=fopen(DATA,W);
for(I=1;I< 30;I++)
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

{
scanf(%d,&number);
if(number==-1)
break;
putw(number,f1);
}
fclose(f1);
f1=fopen(DATA,r);
f2=fopen(ODD,w);
f3=fopen(EVEN,w);
while((number=getw(f1))!=EOF)/* Read from data file*/
{
if(number%2==0)
putw(number,f3);/*Write to even file*/
else
putw(number,f2);/*write to odd file*/
}
fclose(f1);
fclose(f2);
fclose(f3);
f2=fopen(ODD,r);
f3=fopen(EVEN,r);
printf(\n\nContents of the odd file\n\n);
while(number=getw(f2))!=EOF)
printf(%d%d,number);
printf(\n\nContents of the even file);
while(number=getw(f3))!=EOF)
printf(%d,number);
fclose(f2);
fclose(f3);
}
The fprintf & fscanf functions:
The fprintf and scanf functions are identical to printf and scanf functions except that they work
on files. The first argument of theses functions is a file pointer which specifies the file to be used.
The general form of fprintf is
fprintf(fp,control string, list);
Where fp id a file pointer associated with a file that has been opened for writing. The control
string is file output specifications list may include variable, constant and string.
fprintf(f1,%s%d%f,name,age,7.5);

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

Here

name

is

an

array

variable

of

type

char

and

age

is

an

The general format of fscanf is


fscanf(fp,controlstring,list);
This statement would cause the reading of items in the control string.
Example:
fscanf(f2,5s%d,item,&quantity);
Like scanf, fscanf also returns the number of items that are successfully read.
/*Program to handle mixed data types*/
#include< stdio.h >
main()
{
FILE *fp;
int num,qty,I;
float price,value;
char item[10],filename[10];
printf(Input filename);
scanf(%s,filename);
fp=fopen(filename,w);
printf(Input inventory data\n\n0;
printf(Item namem number price quantity\n);
for I=1;I< =3;I++)
{
fscanf(stdin,%s%d%f%d,item,&number,&price,&quality);
fprintf(fp,%s%d%f%d,itemnumber,price,quality);
}
fclose (fp);
fprintf(stdout,\n\n);
fp=fopen(filename,r);
printf(Item name number price quantity value);
for(I=1;I< =3;I++)
{
fscanf(fp,%s%d%f%d,item,&number,&prince,&quality);
value=price*quantity);
fprintf(stdout,%s%d%f%d%d\n,item,number,price,quantity,value);
}
fclose(fp);
}
World Institute Of Technology
8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

int

variable

UNIT 1

Random access to files:


Sometimes it is required to access only a particular part of the and not the complete file. 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,offset, position);
This function is used to move the file position to a desired location within the file. Fileptr
is a pointer to the file concerned. Offset is a number or variable of type long, and position in an
integer number. Offset specifies the number of positions (bytes) to be moved from the location
specified bt the position. The position can take the 3 values.
Value Meaning :
0 Beginning of the file
1 Current position
2 End of the file.

Lecture: 31
Pointers in C: Introduction, Understanding Pointers
Contents
11. Introduction to Pointers
12. Pointer Declaration
13. Introduction to Address Operator
13. Introduction to Pointers

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

UNIT 1

World Institute Of Technology


8km milestone ,Sohna Palwal Road , NH-71 B ,Sohna , Gurgaon ,Haryana.
E-mail : info@wit.net.in
Website : www.wit.net.in

Vous aimerez peut-être aussi