unit i introduction to computer and computing · 2015-01-21 · introduction to computer and...
TRANSCRIPT
1
Unit I
Introduction to computer and computing
1.0 Introduction
1.1 Objective
1.2 Basic structure and functioning
1.3 Types of Memory
1.4 I/O devices
1.4.1 Input devices
1.4.1.1 Keyboard
1.4.1.2 Point and draw devices
1.4.1.3 Data scanning devices
1.4.1.4 Digitizer
1.4.1.5 Electronic card reader
1.4.1.6 Voice recognition device.
1.4.1.7 Vision input system
1.4.1.8 Myc
1.4.2 Output devices
1.4.2.1 Monitor
1.4.2.2 Printer
1.4.2.3 Plotter
1.4.2.4 Computer output microfilm
1.4.2.5 Screen Image Projector
1.4.2.6 Voice response system
1.5 Storage Devices.
1.5.1 Magnetic tape
1.5.2 Hard disk
1.5.3 Floppy disc
1.5.4 Compact disc
1.5.5 Video CD
1.5.6 Zip drive
1.5.7 DVD
1.5.8 DVD-RW
1.6 Operating system
1.7 Computer languages
1.8 Data processing
1.9 Principles of programming
1.9.1Method of problem solving
1.9.2 Algorithm
1.9.3 Flowchart
Check your progress Answer key
2
1.0 Introduction
The basic logical structure of the computer based on the stored program concept, as proposed
by Von Neumann, has not changed over the years; though the size, shape, performance
reliability and cost of computer have all changed. All computer systems perform the
following five basic operations: inputting i.e. the process of entering data and instructions
into the computer system; storing i.e. saving data and instructions so that they are available
for initial or for additional processing as and when required; processing i.e. performing
arithmetic operations (add, subtract, multiply and divide etc.); outputting and controlling. In
this chapter we will discuss about all of the above basic functions of the computer and its
associated topics.
1.1 Objective
The goal of this unit is to familiarize you with the computer system . We will be
studying about the following :
1. The functions performed by computer system.
2. I/O devices.
3. Storage devices and the different types of memory.
4. Operating system concept and its goals.
1.2 Basic structure and functioning of a computer
A computer or a computer system is basically an electronic machine that can carry out
specific tasks by following sequences of instructions within a program. A program includes
such a sequence of instructions together with the data definition. The computer executes the
program by performing one instruction after the other in the specified order.
The programmer or any computer user needs knowledge of the basic computer
architecture concepts to clearly understand the structure of the computer, so as to be able to
use the computer or develop solutions to problems, and to use the computer as a tool to
execute the solutions to his problems.
All computer systems perform the fundamental functions i.e. input, processing, and output.
Input involves entering data into the computer for processing. Data is entered into the
computer with an input device (for example, the keyboard).
Processing executes the instructions in memory to perform some transformation and/or
computation on the data in the computer's memory. This emphasizes the fact that the
instructions and data must be located in memory in order for the processing to proceed.
3
Output involves transferring data from the computer to an output device such as the computer
screen or monitor.
Mainly there are two types of computers. They are digital and analog computer. The basic
differences between the two types are given below:
Analog Digital
1. It processes analog signals 1. It processes numbers
2. Accuracy is limited 2. It has unlimited accuracy
3. Operation is performed by very few devices 3. Operation is performed by many
devices
4. Basic building blocks are amplifiers 4. Basic building blocks are logic
gates
A computer automatically performs arithmetic & logic operation and gives output. It consists
of 5 functional units, which are as follows: -
1. Input
2. Output
3. Memory
4. C.U
5. A.L.U
1. Input: - The computer accepts coded information through input devices. The most
well known input device is the keyboard, which is electronically, connected to the
CPU. Many other kinds of input devices are also available such as joysticks, track ball
and mouse.
2. Memory: - The function of the memory is to store data and program.
3. Output: -The output is the counterpart of the input device. Its function is to send
processed data to the outside world. Such output devices are monitor, printer, plotters
etc.
4. Control unit: - Its function is to control the functions of input and output devices. The
C.U. is effectively the nerve centre that sends control signals to other units and senses
their states. Data transfer between the processor and memory is controlled by the
C.U. through timing signals. A large set of wires carries the signals to all units.
5. Arithmetic and Logic unit (A.L.U): -Most computer operations are executed in the
A.L.U of the processor. Any other operation is initiated by bringing the required
operands into the A.L.U where the necessary operations are performed.
4
Basic operational concepts: - The following block diagram shows flow of signals and data
between the various units of the computer.
Input unit
The input unit links the external environment with the computer. Data and
instructions are entered into the computer through the input device. Input unit transfers input
data into machine language i.e. binary code.
Following functions are performed by an input unit.
1. It accepts the list of instructions and data from the outside world.
2. It converts these instructions and data in computer acceptable form.
3. It supplies the converted instructions and data to the computer system for further
processing.
Output Unit
The output unit links the computer system with the external environment. It gives us
information, which is obtained as a result of data processing as computer work with binary
code. The result produced is also in the binary form. Hence it must be converted in human
readable form and this task is accomplished by the output interface.
Following functions are performed by an output unit:
5
1. It accept the result produced by computer.
2. It converts these coded result to human acceptable(readable) form.
3. It supplies the converted results to the outside world.
Storage unit
The data and instructions that are entered into the computer system through input
units have to be stored inside the computer before the actual processing starts. Similarly, the
result produced by the computer after processing is also kept somewhere inside the computer
system before being passed onto the output unit. The intermediate result produced by the
computer must also be preserved for ongoing processing, the storage unit of computer system
is designed to serve all these needs. It provides space for storing data and instructions space
for intermediate result and also space for the final result. In short the functions of the storage
unit are :
1. It stores (receives) the data to be processed and instructions required for processing.
2. It stores the intermediate result of processing.
3. It also stores the final result of processing before these results are released to an
output device.
The storage unit of all computers comprises of the following two types of storage:
Primary Storage:- The primary storage is also known as the main memory. It stores pieces of
program instructions and data, intermediate results of processing and the recently produced
result of processing of the job on which computer system was working currently. CPU
accesses the result with very fast speed. The primary memory is volatile and its contents
disappear when the computer is powered off.
Secondary storage:- Secondary storage is also known as auxiliary storage. The secondary
storage is used to supplement the limited storage and volatile characteristics of primary
storage. It is cheaper than primary storage, and can retain information even after the computer
system is switched off.
Central Processing Unit
The Control unit and arithmetic and logic unit of the computer system together make the
CPU i.e. Central processing unit. The CPU is the brain of the computer system. CPU is also
responsible for activating and controlling the operations of other units of the computer
system.
Arithmetic logic unit:- Actual execution of the instructions takes place in the arithmetic and
logic unit. The calculations and comparisons and other decision making is performed in the
ALU.
6
Control Unit:- Control unit maintains order and directs the operation of the entire system. The
control unit acts as the central nervous system for the other components of the computer
system.
Check your progress (1)
Fill in the blank:-
1. ..............................., ......................., ...............................,is fundamental function of
computer.
2. ...............................,unit accept data from outside world.
3. ................................,stores data.
4. Arithmatic nd logical operation done in.........................unit.
1.3 Types of Memory
Every computer has storage space known as memory. There are two types of memory
1. Main memory or Primary memory
2. Secondary memory or auxiliary memory.
Primary memory is of the following types:-
1. RAM
2. ROM
3. PROM
4. EPROM
Random access memory (RAM):It is a primary memory which is also of two types i.e. Static
RAM and Dynamic RAM.
Read only memory (ROM): Special type of random access memory called as read only
memory, is non volatile memory. Data stored on ROM is permanent and cannot be altered by
the programmer. ROM is mainly used to store programs and data which do not change and
are frequently used. ROM chip of the computer stores a set of instructions that are needed to
make the computer system ready for use when its power is switched on. There are two types
of ROM i.e. PROM and EPROM.
Programmable read only memory ( PROM): It is a type of ROM on which data can be written
only once . Once the chip has been programmed the recorded information cannot be changed.
PROM is also known as non volatile storage.
Erasable programmable read only memory (EPROM): In this type of ROM it is possible to
erase the information stored in the chip and can be reprogrammed to store new information,
this type of memory is called EPROM. EPROM are of two types i.e. UVPROM and
EEPROM.
1. UVPROM: Information stored in the chip can be erased by exposing the chip for
some time to ultraviolet light.
7
2. EEPROM: The information stored in the chip can be erased by using high electric
voltage.
Secondary Memory has been discussed under section 3.3
Check your progress (2)
Say whether true or false:-
1. Main memory also called primary memory.
2. RAM is random accept memory.
3. Information stored on EEPROM erased by high electric voltage.
1.4 Input Output Device
An I/O device( an input/output device) is a hardware device that provides the means
of communication between the computer and outer world. They are also known as peripheral
devices because they surround the CPU and the memory of the computer system. Input
devices are used to enter the data from outside world to primary storage and output devices
give results from primary storage to users.
1.4.1 Input Device
An input device is a hardware device that sends data to the computer. Without any
input device, a computer would only be a processing device and not allow users to interact
with it. In other words, an input device is an electromechanical device that accepts data from
outside world and translates them into a form the computer can interpret. Input devices are
broadly classified into following categories.
Keyboard
Point-and-draw device
Data scanning device
Digitizer
Electronic card-based device
Voice recognition device
Vision based device
Offline data entry device
1.4.1.1 Keyboard
The keyboard is the most commonly used input device today that allows data
entry into a computer by pressing a set of keys. Keyboard can be classified into two
types
General purpose keyboard
Special purpose keyboard
8
General purpose keyboard
General purpose keyboard is a standard keyboard that is most commonly used
as an input device. It has the set of typewriter-like keys that enables you to enter data
into a computer. Computer keyboards are similar to electric-typewriter keyboards but
contain additional keys. The keys on computer keyboards are often classified as
follows:
alphanumeric keys -- letters and numbers
punctuation keys -- comma, period, semicolon, and so on.
special keys -- function keys, control keys, arrow keys, Caps Lock key, and so on.
The standard layout of letters, numbers, and punctuation is known as a QWERTY
keyboard because the first six keys on the top row of letters spell QWERTY. The QWERTY
keyboard was designed in the 1800s for mechanical typewriters and was actually designed to
slow typists down to avoid jamming the keys. Another keyboard design, which has letters
positioned for speed typing, is the Dvorak keyboard.
There is no standard computer keyboard, although many manufacturers imitate the
keyboards of PCs. There are actually three different PC keyboards: the original PC keyboard,
with 84 keys; the AT keyboard, also with 84 keys; and the enhanced keyboard, with 101
keys. The three differ somewhat in the placement of function keys, the Control key, the
Return key, and the Shift keys.
In addition to these keys, keyboards contain the following keys: Page Up, Page Down,
Home, End, Insert, Pause, Num Lock, Scroll Lock, Break, Caps Lock, Print Screen.
Special purpose keyboard
This type of keyboard is specially designed and used for specific type of applications,
so it is called a special purpose keyboard. It makes possible data entry at a faster rate and
enables rapid interaction with computer system. It has only some special functional keys. For
example terminals used in supermarket, ATM etc.
1.4.1.2 Point-and-draw device
The GUI provides users a screen full of graphics icons or menus and allows them to
make a rapid selection from displayed icons or menus to give instruction to computer. Such
user interface computer requires an input device that can be used to rapidly point to and select
a particular graphic icon or menu item from the multiple options displayed on the screen.
Mouse, joystick, trackball, light pen, touch screen are some examples of point-and-draw
devices.
9
Mouse
A mouse is a hardware input device that was invented by Douglas Engel Bart in 1963.
The mouse allows an individual to control a pointer in a graphical user interface (GUI).
Utilizing a mouse, a user has the ability to perform various functions such as opening a
program or file and does not require the user to memorize commands, like those used in a
text-based command-line environment such as MS-DOS.
The mouse was originally referred to as an X-Y Position Indicator for a display system.
Xerox later applied the name mouse to its revolutionary Alto computer system in 1973.
Today, a pointing device is found on virtually every computer.
Trackball
A trackball is an input device that looks like an upside-down mouse. The on-screen pointer is
moved by the trackball with a thumb or finger. A trackball requires less arm and wrist motion
than a regular mouse takes and therefore is often less stressful for the user to use.
Joystick
The joystick is an input device that looks similar to a control device you would find on an
arcade game at your local arcades. A joystick allows an individual to easily move an object in
a game such as navigating a plane in a flight simulator
Light pen
A light pen is an input device that utilizes a light-sensitive detector to select objects on a
display screen. A light pen is similar to a mouse, except that with a light pen you can move
the pointer and select objects on the display screen by directly pointing to the objects with the
pen.
Touch screen
A touch screen is a computer display screen that is also an input device. The screens are
sensitive to pressure; a user interacts with the computer by touching pictures or words on the
screen.
1.4.1.3Data scanning devices
Data scanning devices are input devices that enable direct data entry into a computer
system from source documents thus eliminating the need to key-in text data into the
computer. Due to reduced human effort in data entry, they improve data accuracy and also
increase the timeliness of the information processed. They however demand high quality of
input documents. Some data scanning devices are also capable of recognizing marks or
characters.
1. Image Scanner
10
It is an input device that translates paper documents into an electronic format for
storage in a computer. Electronic format of a scanned image is its bitmap representation.
Stored images can be altered or manipulated with image-processing softwares.
Common Types of Image Scanners
Flat - bed Scanner
Hand - held Scanner
Flat - bed Scanner
It looks like a photocopy machine. It has a box with a glass plate on the top & a
lid. The document to be scanned is placed on the glass plate. A light source below
the glass plate moves from one line to another & scans all the lines within few
seconds.
Hand – held Scanner
It contains LEDs & can be held in hand. To scan, it is dragged slowly over the
document from one end to another. It has to be dragged very slowly & steadily. It
is used only when high accuracy is not needed. It is cheaper than a flatbed
scanner. It is used when volume of documents to be scanned is low.
Other scanners include: sheetfed scanner, which is a scanner that scans paper fed
into it, and a card scanner, which is a small scanner capable of scanning business
cards.
2. OCR – Optical Character Recognition
It is a scanner with character recognition software.
It uses OCR software that converts the bit map images of characters to
ASCII codes.
It enables word processing of input text and also requires less space for
storing the document.
OCR software is extremely complex because it is difficult to make a
computer recognize an unlimited number of fonts
Two standard OCR fonts are OCR-A (American standard) and OCR-B
(European standard)
3. OMR – Optical Mark Reader
11
It is a scanner capable of recognizing a pre-specified type of mark by a
pencil or pen
It is very useful for grading tests with objective type questions, or for any
input data that is of a choice or selection nature.
4. Bar Code Reader
It is a scanner used for reading (decoding) bar-coded data .
Bar codes represent alphanumeric data by a combination of adjacent
vertical lines (bars) by varying their width and the spacing between
them.
Scanner uses laser-beam to stroke across pattern of bar code. Different
patterns of bars reflect the beam in different ways sensed by a light-
sensitive detector.
Universal Product Code (UPC) is the most widely known bar coding
system.
Barcode Printer is a hardware device capable of printing out adhesive
barcodes that can be attached to a product. This helps identify the
product or a company keep to track of its inventory.
5. MICR – Magnetic Ink Character Recognition
MICR is used by banking industry for faster processing of large volume of
cheques.
Bank’s identification code (name, branch, etc.), account number and cheque
number are pre-printed (encoded)using characters from a special character
set on all cheques.
Special ink is used that contains magnetizable particles of iron oxide
MICR reader-sorter reads data on cheques and sorts them for distribution to
other banks or for further processing.
1.4.1.4 Digitizer
It is an input device used for converting (digitizing) pictures, maps and
drawings into digital form for storage in computers.
Commonly used in the area of Computer Aided Design (CAD) by architects
and engineers to design cars, buildings medical devices, robots, mechanical
parts, etc.
Used in the area of Geographical Information System(GIS) for digitizing
maps available in paper form.
1.4.1.5 Electronic Card Reader
Electronic cards are small plastic cards having encoded data appropriate for
the application for which they are used.
Electronic-card reader is used to read data encoded on an electronic card and
transfer it to the computer for further processing.
Used together as a means of direct data entry into a computer system.
12
Used by banks for use in automatic teller machines(ATMs) and by
organizations for controlling access of employees to physically secured areas.
1.4.1.6 Voice Recognition Devices
Input devices that allow a person to input data to a computer system by speaking
to it are called voice recognition devices. Today’s speech recognition systems are
limited to accepting few words within a relatively small domain and can be used
to enter only limited kinds and quantities of data.
Uses of Speech Recognition
For inputting data to a computer system by a person in situations where
his/her hands are busy.
For data input by dictation.
For authentication of a user by a computer system based on voice input.
For limited use of computers by individuals with physical disabilities.
1.4.1.7 Vision - Input Systems
Allow computer to accept input just by seeing an object.
Input data is normally an object’s shape and features in the form of an
image.
Digital camera
A digital camera stores the pictures or video it takes in electronic format
instead of to a film. There are several features that make digital cameras a popular
choice when compared to film cameras. First, the feature often enjoyed the most is
the LCD display on the digital camera. This display allows users to view photos or
video after the picture or video has been taken, which means if you take a picture
and do not like the results, you can delete it; or if you do like the picture, you can
easily show it to other people. Another nice feature with digital cameras is the
ability to take dozens, sometimes hundreds of different pictures. Digital cameras
have become the camera solution for most users today as the quality of picture they
take has greatly improved and as the price has decreased.
1.4.1.8 Myc
Sometimes abbreviated as mic, a microphone is a hardware peripheral originally
invented by Emile Berliner in 1877 that allows computer users to input audio into
their computers.
Check your progress (3)
Fill in the blanks:-
13
1. Flat panel display is ………………….device.
2. Com stands for……………………
3. To print engineering design application………………is used.
4. …………………converts text information into spoken sentence.
1.4.2 Output Devices
An output device is an electrometrical device that accepts data from a computer and
translates it into human understandable form and displays the result. It is also known as a
peripheral device. The output devices are broadly classified into the following categories :
Monitor
Printer
Plotter
Computer output microfilm
Screen image projector
Voice response system
1.4.2.1 Monitor
Monitor is also called a video display terminal (VDT) or video display unit (VDU).
In its most common usage, monitor refers only to devices that contain no electronic
equipment other than what is essentially needed to display and adjust the
characteristics of an image.
Like most TVs, the computer monitor has a CRT (Cathode Ray Tube) that is found
inside the computer monitor. The CRT is the main component and most expensive
part in the computer monitor.
Flat-panel display
Thin screen displays found with all portable computers are becoming the new
standard with desktop computers. Instead of utilizing the cathode-ray tube technology,
flat-panel displays use Liquid-crystal display (LCD) technology or other alternative
making them much lighter and thinner when compared with a traditional monitor
1.4.2.2 Printer
A printer is n external hardware device that is responsible for taking computer data
and generating a hard copy of that data. Printers are one of the most used peripherals
on computers and are commonly used to print text, images, or photos. Printers are of
the following types:
Dot Matrix printer
Inkjet printer
Laser printer
14
Thermal printer
LED printer
Dot-matrix printer
It is a type of printer that produces characters and illustrations by striking pins against
an ink ribbon to print closely spaced dots in the appropriate shape. Dot-matrix printers
are relatively expensive and do not produce high-quality output. However, they can
print to multi-page forms (that is, carbon copies), something laser and ink-jet printers
cannot do.
Dot-matrix printers vary in two important characteristics:
speed: Given in characters per second (cps), the speed can vary from about 50 to
over 500 cps. Most dot-matrix printers offer different speeds depending on the quality
of print desired.
print quality: Determined by the number of pins (the mechanisms that print the
dots), it can vary from 9 to 24. The best dot-matrix printers (24 pins) can produce near
letter-quality type, although you can still see a difference if you look closely.
Inkjet printer
The most popular printer for home computer users that prints by spraying streams of
quick-drying ink on paper. The ink is stored in disposable ink cartridges, often a
separate cartridge is used for each of the major colors. These colors are usually Black,
Red/Magenta, Green/Cyan, and Yellow (CYMK).
Although inkjet printers themselves are often relatively inexpensive, the ink
cartridges used in the printers can increase the overall cost of the printer.
Laser printer
First developed at Xerox PARC by Gary Starkweather and released in 1971, a laser
printer is a printer that utilizes laser technology to print images on the paper. Laser
printers are often used in corporate, school, and other environments that require print
jobs to be completed quickly and in large quantities.
Thermal printer
1. A thermal impact printer or electro thermal printer is a printer that uses heated
pins to "burn" images onto heat-sensitive paper. These printers are commonly used in
calculators and fax machines; and although they are inexpensive and print relatively
fast, they produce low resolution print jobs.
2. A thermal printer, thermal transfer printer, or thermal wax-transfer printer is a
high quality printer invented by Jack Kilby that commonly utilizes a thermal wax
ribbon that melts a colored wax onto the paper creating near photo-realistic images.
15
LED Printer
Short for light emitting diode printer, LED printers were developed by Casio and are
printers capable of printing at the same or close to the same quality as most laser
printers. LED printers work much like laser printers but utilize a LED panel that
recreates the image on a negatively charged drum. The areas where the light hits the
drum become less charged, which attracts the toner. The printer then transfers the
toner from the drum to the paper and applies intense heat to fuse the toner to the
paper.
1.4.2.3 Plotters
It is a device that draws pictures on paper based on commands from a computer.
Plotters differ from printers in that they draw lines using a pen. As a result, they can
produce continuous lines, whereas printers can only simulate lines by printing a
closely spaced series of dots. Multicolor plotters use different-colored pens to draw
different colors.
In general, plotters are considerably more expensive than printers. They are used in
engineering applications where precision is mandatory. There are two types of
plotters: drum plotter and flatbed plotter.
1.4.2.4 Computer Output Microfilm
COM (Computer Output Microfilm) is a process for copying data from electronic
media on computers onto microfilm. COM can be produced as microfiche or as
16mm-roll microfilm.
A high-speed recorder transfers machine-readable digital data onto human-readable
microfilm using laser technology and a processor, which develops the microfilm after it is
exposed to the light source. The recorder can operate off-line as a stand-alone device, or
on-line connected to a local or wide-area network. A COM recorder usually has a
duplicator connected to it that can create as many copies as needed. A sorter separates the
duplicate fiche cards into bins.
1.4.2.5 Screen image projector
A digital projector, also called a digital projection display system, is a specialized
computer display that projects an enlarged image on a movie screen. Such devices are
commonly used in presentations.
The term digital projector is sometimes used for a program that facilitates the viewing
of three-dimensional (3D), interactive, full-motion audio-visual files on a personal
computer. Versions are available for both IBM-compatible and Macintosh computers,
and can be downloaded from the Internet. They can be used as plug-ins for popular
browsers for viewing animated Web-page content. For optimum performance on the
16
Internet, a broadband connection should be used because of the high-speed,
interactive nature of the content, and because the transmitted files are often large
There are two main types of digital projection display systems. The older, less
expensive type employs three transparent liquid-crystal-display ( LCD ) panels, one
for each of the primary colors (red, green, and blue). The light transmittivity of each
pixel varies depending on the image data received from the computer. The light from
a lamp is directed through the LCD panels, collimated using a lens, and projected onto
a screen. The overall construction of the device is similar to that of a slide projector,
where the "slide" consists of the three LCD panels placed close together near the focal
point of the projection lens. Advantages of LCD technology include efficiency, ease
of brightness and contrast adjustment, and high image resolution.
A newer, more expensive scheme is known as Digital Light Processing (DLP), a
proprietary technology developed by Texas Instruments. In a DLP display, tiny
mirrors are used instead of transparent panels. Each mirror represents one pixel. The
light, rather than passing through the panel, is reflected from it. The mirrors move
back and forth, varying the amount of light that reaches the projection lens from each
pixel. Color is obtained by passing the light from the lamp through a rotating wheel
with red, green, and blue filters. This subjects the mirrors to light at each of the
primary colors in a rapid rotating sequence. The result is a color-modulated image that
the human eye sees as natural color. Advantages of DLP technology include light
weight, high contrast, and lack of pixelation.
1.4.2.6 Voice response system
A voice recognition system allows user to talk with the computer. It has an audio
response device that produce audio output, audio response device is basically of two
type one is Voice Reproduction System and other is Speech Synthesizer.
Voice Reproduction System
It produces audio output by selecting appropriate audio output from a set of
prerecorded audio responses.
Speech Synthesizer
A speech synthesizer converts text information into spoken sentences. To produce
speech, these devices combine basic sound units called phonemes. From a given text
information, sequence of words are combined into phonemes, amplified, and output
through the speaker attached to the system.
Check your progress (4)
Fill in the blanks:-
1. ………………device is used for converting picture, maps and drawing in digital
form.
2. Data code in form of small lines is known as ……………
17
3. ………………..are capable of recognize a pre specified type of mark made by
pencil or pen.
1.5 Storage devices
A storage device is a hardware device capable of storing information. There are two
storage devices used in computers: a primary storage device such as computer RAM
and a secondary storage device such as a computer hard disk drive.
Secondary storage device
Alternatively referred to as external memory and auxiliary storage, secondary storage
is a storage medium that holds information until it is deleted or overwritten regardless
of the computer being on or off. For example, a floppy disk drive and hard disk drive
are both good examples of secondary storage devices. There are three different types
of storage on a computer. Although primary storage is accessed much faster than
secondary storage because of the price and size limitations, secondary storage is used
with today's computers to store all programs and personal data.
1.5.1 Magnetic tape
Tapes for computers are similar to tapes used to store music. It is a coated strip of
plastic on which data is magnetically encoded
Storing data on tapes is considerably cheaper than storing data on disks. Tapes also
have large storage capacities, ranging from a few hundred kilobytes to several
gigabytes. Accessing data on tapes, however, is much slower than accessing data on
disks. Tapes are sequential-access media, which means that to get to a particular point
on the tape, the tape must go through all the preceding points. In contrast, disks are
random-access media because a disk drive can access any point at random without
passing through intervening points.
Because tapes are so slow, they are generally used only for long-term storage and
backup. Data to be used regularly is almost always kept on a disk. Tapes are also used
for transporting large amounts of data. Tapes come in a variety of sizes and formats.
Tapes are sometimes called streamers or streaming tapes.
1.5.2 Hard Disk
A magnetic disk is a device on which you can store computer data. The term hard is
used to distinguish it from a soft, or floppy, disk. Hard disks hold more data and are
faster than floppy disks. A hard disk, for example, can store anywhere from 10 to
more than 100 gigabytes, whereas most floppies have a maximum storage capacity of
1.4 megabytes.
A single hard disk usually consists of several platters. Each platter requires two
read/write heads, one for each side. All the read/write heads are attached to a single
access arm so that they cannot move independently. Each platter has the same number
of tracks, and a track location that cuts across all platters is called a cylinder. For
18
example, a typical 84 megabyte hard disk for a PC might have two platters (four
sides) and 1,053 cylinders.
In general, hard disks are less portable than floppies, although it is possible to buy
removable hard disks.
1.5.3 Floppy
A floppy is a soft magnetic disk. It is called a floppy because it flops if it is waved..
Unlike most hard disks, floppy disks (often called floppies or diskettes) are portable,
because you can remove them from a disk drive. Disk drives for floppy disks are
called floppy drives. Floppy disks are slower to access than hard disks and have less
storage capacity, but they are much less expensive. And most importantly, they are
portable.
Floppies come in three basic sizes: 8 ½”, 5 ¼” and 3 ½”.
1.5.4 CD-ROM
Pronounced see-dee-rom. Short for Compact Disc-Read-Only Memory, a type of
optical disk capable of storing large amounts of data -- up to 1GB, although the most
common size is 650MB (megabytes). A single CD-ROM has the storage capacity of
700 floppy disks, enough memory to store about 300,000 text pages.
CD-ROMs are stamped by the vendor, and once stamped, they cannot be erased and
filled with new data. To read a CD, you need a CD-ROM player. All CD-ROMs
conform to a standard size and format, so you can load any type of CD-ROM into any
CD-ROM player. In addition, CD-ROM players are capable of playing audio CDs,
which share the same technology.
CD-ROMs are particularly well-suited to information that requires large storage
capacity. This includes large software applications that support color, graphics, sound,
and especially video.
1.5.5 VCD
VCD stands for 'Video Compact Disc' and basically it is a CD that contains moving
pictures and sound. A VCD has the capacity to hold up to 74/80 minutes on
650MB/700MB CDs respectively of full-motion video along with quality stereo
sound. VCDs use a compression standard called MPEG to store the video and audio.
A VCD can be played on almost all standalone DVD Players and of course on all
computers with a DVD-ROM or CD-ROM drive with the help of software based
decoder / player. It is also possible to use menus and chapters, similar to DVDs, on a
VCD and also simple photo album/slide shows with background audio. The quality of
a very good VCD is about the same as a VHS tape based movie but VCD is usually a
bit more blurry.
VCD was introduced in 1993 by JVC, Philips, SONY and Matsushita .Video data is
demanding in terms of storage capacity; it requires approximately 5 MB of storage
19
per second of video, which would translate to about two minutes of video on a 680
MB CD. In order to store video information on a CD in a practical fashion, the data
must be compressed for storage and then decompressed for replay in real time.
1.5.6 Zip drive
A zip drive is a high-capacity floppy disk drive developed by Omega Corporation. Zip
disks are slightly larger than conventional floppy disks, and about twice as thick.
They can hold 100 or 250 MB of data. Because they're relatively inexpensive and
durable, they have become a popular media for backing up hard disks and for
transporting large files.
1.5.7 DVD
DVD stands for Digital Versatile/Video Disc, DVD-R stands for DVD-
Recordable and DVD-RW for DVD-Rewriteable. A recordable DVD stores up to 2
hours of very good quality DVD-Video, including several audio tracks in formats like
stereo, Dolby Digital or DTS and also advanced menu systems, subtitles and still
pictures that can be played by many standalone DVD players and most computer
DVD-ROMs. If you choose to lower the video quality it is possible to store several
hours video on a recordable DVD using low bit rates and low resolution. It is also
possible to have upto 4.37 GB ordinary data or mix DVD-Video and data on a
recordable DVD that can be played by most computer DVD-ROMs.
There are many competing DVD Recording standards, DVD-R / DVD-RW and
DVD+R / DVD+RW have pretty similar features and are compatible with many
standalone DVD Players and most DVD-ROMs while DVD-RAM has less DVD
Player and DVD-ROM compatibility but better recording features.
DVD-R and DVD-RW
DVD-R was the first DVD recording format released that was compatible with
standalone DVD Players.DVD-R is a non-rewriteable format and it is compatible with
about 93% of all DVD Players and most DVD-ROMs. DVD-RW is a rewriteable
format and it is compatible with about 80% of all DVD Players and most DVD-
ROMs. DVD-R and DVD-RW supports single side 4.37 GiB* DVDs(called DVD-5)
and double sided 8.75 GB* DVDs(called DVD-10).These formats are supported by
DVD Forum.
20
DVD+R and DVD+RW
DVD+R is a non-rewritable format and it is compatible with about 89% of all DVD
Players and most DVD-ROMs.DVD+RW is a rewritable format and is compatible
with about 79% of all DVD Players and most DVD-ROMs.DVD+R and DVD+RW
supports single side 4.37 GiB* DVDs(called DVD-5) and double side 8.75 computer
GB* DVDs(called DVD-10).These formats are supported by the DVD+RW Alliance.
DVD+R DL
DVD+R DL or called DVD+R9 is a Dual Layer writeable DVD+R. The dual layered
discs can hold 7.95 GiB* (called DVD-9) and dual layered with double sides 15.9*
GiB (called dvd-18).
DVD-R DL
DVD-R DL or called DVD-R9 is a Dual Layer writeable DVD-R. The dual layered
discs can hold 7.95 GiB* (called DVD-9) and dual layered with double sides 15.9*
GiB (called dvd-18).
DVD-RAM
DVD-RAM has the best recording features but it is not compatible with most DVD-
ROM drives and DVD-Video players. Think more of it as a removable hard disk.
DVD-RAM is usually used in some DVD Recorders.
Check your progress (5)
Say whether true or false:-
1. Magnetic tape is a storage device
2. Harddisk is less portable than floppy
3. Wc can store moving picture in VCD
1.6 Operating System
The operating system forms an integral part of the computer system. It is essential to
have knowledge about it, its components, goals, functions, importance etc. There are
varieties of operating systems prevalent around the world and many new ones keep coming
in. Each new developed operating system may have some new enhanced features and
functionality but the basic features of all operating systems remain the same. With newer
21
version, efforts are made to enhance features of the operating system in order to provide a
less troublesome session to the user. Here we will try to get a good understanding about the
basic functions of the operating system and its importance.
The most basic and simple definition of an operating system is “the software that
controls the hardware.” It is a set of programs that make the computer hardware useable. It
acts as an interface between the user and the hardware. It provides an environment within
which other programs can do useful work.
An operating system is a program designed to run other programs on a
computer. A computer’s operating system is its most important program. It is considered
the backbone of a computer, managing both software and hardware resources. Operating
systems are responsible for everything from the control and allocation of memory to
recognizing input from external devices and transmitting output to computer displays. They
also manage files on computer hard drives and control peripherals, like printers and
scanners.
The operating system of a large computer system has even more work to do.
Such operating systems monitor different programs and users, making sure everything runs
smoothly, without interference, despite the fact that numerous devices and programs are
used simultaneously. An operating system also has a vital role to play in security. Its job
includes preventing unauthorized users from accessing the computer system.
The abstract view of the components of a computer system shows the position of the
operating system as below:
USERS
Operating system is an essential part of every computer system. The users are able
to make efficient use of the basic computing resources available in the system with the help
Application s/w
Utility s/w, system program
Operating system
hardware
22
of the softwares especially the operating system. The operating system acts as an
intermediary between the user of a computer system and the hardware. It controls and
coordinates the use of hardware among the various application programs for the various
users. It provides an environment so that the user can do his work in an efficient manner
and also easily and conveniently
Some examples of operating systems are UNIX, Mach, MS-DOS, MS-Windows,
Windows/NT, Chicago, OS/2, MacOS, VMS, MVS, and VM.
Operating systems are classified on the basis of their mode of interaction with
the users as CUI (character user interface) and GUI (graphic user interface).
Under CUI, user has to type-in commands in proper syntax, for example DOS operating
system.
GUI provides a picture oriented interface that provides menus and icons which can be
selected by clicking on the icon with the help of a mouse. The user interacts with the
operating systems through the user interface and is usually interested in the “look and
feel” of the operating system, for example WINDOWS operating system.
The most important components of the user interface are the command interpreter, the
file system, on-line help, and application integration.
Operating systems are also differentiated as being real time, multi-programmed,
multiprocessing, multitasking, multithreading, networked, distributed, client- server,
multiuser, time shared, clustered etc.
A multiuser operating system enables multiple users to run programs simultaneously.
This type of operating system may be used for just a few people or hundreds of them.
In fact, there are some operating systems that are used to allow thousands of people to
run programs at the same time.
A multiprocessing operating system allows a program to run on more than one central
processing unit (CPU) at a time. This can come in very handy in some work
environments, at schools, and even for some home-computing situations. Multitasking
operating systems work a little differently; they make it possible to run more than one
program at a time. Multithreading operating systems are even more different, allowing
varied parts of one program to be used simultaneously.
23
Real-time operating systems are designed to allow computers to process and respond to
input instantly. Usually, general-purpose operating systems, such as disk operating
system (DOS), are not considered real time, as they may require seconds or minutes to
respond to input. Real-time operating systems are typically used when computers must
react to the consistent input of information without delay. For example, real-time
operating systems may be used in navigation, manufacturing units for controlling the
operation of machines.
Operating systems generally have following three major goals:
To hide details of hardware from the user through abstraction.
To allocate resources to processes.
Provide a pleasant and effective user interface
Operating system components: Even though, not all systems have the same
structure, many modern operating systems support the following system components:
process management, primary memory management, file management, i/o system
management, secondary storage management, security management and networking issues.
Operating system functions: Some of the operating system functions are listed as
below:
implementing the user interface,
sharing hardware among users,
allowing users to share data among themselves,
preventing users from interfering with one another,
scheduling resources among users,
facilitating input/output,
recovering from errors,
accounting for resource usage,
facilitating parallel operations,
organizing data for secure and rapid access, and
handling network communications
24
Prevalent operating systems: As already mentioned above, some of the commonly known
operating systems are UNIX, Linux, Mach, MS-DOS, MS-Windows, Windows/NT, OS/2,
MacOS etc. Some of the basic key features of these operating systems are given below for
study, knowledge and comparison.
DOS, short for "Disk Operating System", is a shorthand term for several closely
related operating systems that dominated the IBM PC compatible market between 1981
and 1995, or until about 2000 if we include the partially DOS-based Microsoft Windows
versions 95, 98 and Millennium Edition.
DOS is a single-user, single-task operating system with basic kernel functions that
are non-re-entrant: only one program at a time can use them. There is an exception with
Terminate and Stay Resident (TSR) programs, and some TSRs can allow multitasking. The
DOS kernel provides various functions for programs, like displaying characters on-screen,
reading a character from the keyboard, accessing disk files and more.
Microsoft Windows is a series of software operating systems and graphical user
interfaces produced by the Microsoft Company. Microsoft first introduced an operating
environment named Windows in November 1985 as an add-on to MS-DOS in response to
the growing interest in graphical user interfaces (GUIs). Microsoft Windows came to
dominate the world's personal computer market, overtaking MacOS, which had been
introduced previously. As of October 2009, Windows had approximately 91% of the
market share of the client operating systems for usage on the Internet. The NT family of
Windows systems was fashioned and marketed for higher reliability business use.
Windows 7 is the latest release of Microsoft Windows, in the series of operating
systems produced by Microsoft for use on personal computers, including home and
business desktops, laptops, net books, tablet PCs, and media center PCs. Windows 7 was
released on July 22- 2009, three years after the release of its predecessor, Windows Vista.
The most recent client version of Windows is Windows 7; the most recent server
version is Windows Server 2008 R2; the most recent mobile OS version is Windows
Mobile 6.5. Windows 8, the successor to Windows 7, is currently in development.
25
The UNIX Operating System is available on machines with a wide range of
computing power, from microcomputers to mainframes, and on different manufacture's
machines. No other operating system can make this claim. The reasons of popularity and
success of UNIX are explained below :
Portability: The system is written in high-level language making it easier to read,
understand, change and, therefore move to other machines. The code can be changed and
compiled on a new machine. Customers can choose from a wide variety of hardware
vendors without being locked in with a particular vendor.
Machine-independence: The system hides the machine architecture from the user,
making it easier to write applications that can run on micros, minis and mainframes.
Multi-User Operations: UNIX is a multi-user system designed to support a group of
users simultaneously. The system allows for the sharing of processing power and peripheral
resources, while at the same time it provides excellent security features.
Hierarchical File System: UNIX uses a hierarchal file structure to store information.
This structure has the maximum flexibility in grouping information in a way that reflects its
natural state. It allows for easy maintenance and efficient implementation.
UNIX shell: UNIX has a simple user interface called the shell that has the power to
provide the services that the user wants. It protects the user from having to know the
intricate hardware details.
Pipes and Filters: UNIX has facilities called Pipes and Filters which permit the user
to create complex programs.
Linux is the operating system that is now used on a majority of web servers. Linux
is an open operating system. This means the source code is freely available. Anyone
distributing machine executable versions of this code should also be able to provide the
source code. Also any changes to the source code should be available under the same
licensing conditions. Linux is mainly developed by volunteers all over the world.
Linux runs on widely differing hardware platforms ranging from small embedded
systems over commodity personal computers to huge clusters for processor intensive jobs
like scientific calculations or 3D rendering. The reasons of popularity and success of
LINUX are explained below :
Linux source code is freely distributed.
26
It has the best technical support available.
It has no vendor lock-in.
It runs on a wide range of hardware.
It is exceptionally stable.
It has the tools and applications you need.
It interoperates with many other types of computer systems.
It has a low total cost of ownership.
Check your progress (6)
Say whether true or false:-
1. Operating system is the backbone of computer system.
2. Multiuser OS allows a program to run on more than one CPU simaltanously.
3. Unix is single user OS.
1.7 Computer Languages
A language which is acceptable to the computer system is called as computer
language or programming language. computer languages are used to communicate
with computers.
Computer languages can be divided into two groups:
high-level languages
low-level languages.
High-level languages
High-level languages are designed to be easier to use, more abstract, and more
portable than low-level languages. Syntactically correct programs in some languages
are then compiled to low-level language and executed by the computer. Most modern
software is written in a high-level language, compiled into object code, and then
translated into machine instructions. By comparison, a high-level programming
language isolates the execution semantics of a computer architecture from the
specification of the program, which simplifies development. 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.
27
Every CPU has its own unique machine language. Programs must be rewritten or
recompiled, therefore, to run on different types of computer.
Low level languages
A low-level programming language is a programming language that provides little or
no abstraction from a computer's instruction set architecture. Generally this refers to
either machine code or assembly language. The word "low" refers to the small or
nonexistent amount of abstraction between the language and machine language;
because of this, low-level languages are sometimes described as being "close to the
hardware."
Low-level languages can be converted to machine code without using a compiler or
interpreter, and the resulting code runs directly on the processor. A program written in
a low-level language can be made to run very fast, and with a very small memory
footprint; an equivalent program in a high-level language will be more heavyweight.
Low-level languages are simple, but are considered difficult to use, due to the
numerous technical details which must be remembered.
Example of Low-level programming languages are assembly language & machine
language.
Assembly language
A programming language that is once removed from a computer's machine 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.
Machine language
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.
Check your progress (7)
Say whether true or false:-
1. Machine language and assembly language are low level language.
2. Machine language understand by computer easily.
1.8 Data processing
28
Computer data processing is any process that a computer program does to enter data
and summarize, analyze or otherwise convert data into usable information. The
process may be automated and run on a computer. It involves recording, analysing,
sorting, summarising, calculating, disseminating and storing data. Because data are
most useful when well-presented and actually informative, data-processing systems
are often referred to as information systems. Data-processing systems typically
manipulate raw data into information, and likewise information systems typically take
raw data as input to produce information as output.
Data processing may or may not be distinguished from data conversion, when the
process is merely to convert data to another format, and does not involve any data
manipulation.
Processing
Basically, data are nothing but facts (organized or unorganized) which can be
converted into other forms to make it useful, clear and pratically used. This process of
converting facts to information is called Processing. Practically all naturally occurring
processes can be viewed as examples of data processing systems where "observable"
information in the form of pressure, light, etc. are converted by human observers into
electrical signals in the nervous system as the senses we recognize as touch, sound,
and vision. Even the interaction of non-living systems may be viewed in this way as
rudimentary information processing systems.
Elements of data processing
In order to be processed by a computer, data needs first be converted into a machine
readable format. Once data are in digital format, various procedures can be applied on
the data to get useful information. Data processing may involve various processes,
including:
Data summarization
Data aggregation
Data validation
Data tabulation
Statistical analysis
Check your progress (8)
Say whether true or false:-
1. Process of converting text in information is called data processing.
2. Manipulation of data is done during processing.
3. Data validation is process of data processing.
29
1.9 Programming
Programming is the process of writing a sequence of instructions to be excuted by a
computer to solve a problem. It is also considered as the act of writing computer
programs. Computer programs are set of instructions that tell a computer to perform
certain operations. The instructions in programs are logically sequenced and
assembled through the act of programming. Computer programming has many facets:
It is like engineering because computer programs must be carefully designed to be
reliable and inexpensive to maintain. It is an art because good programs require that
the programmer use the intuition and a personal sense of style. It is a literary effort
because programs must be understood by computers, and this requires mastery of a
programming language. Programmers are people who write programs and use
different programming language to communicate instructions to the computer.
1.9.1 Method of Problem Solving
A computer is only a problem-solving tool. It is one of the many different tools
engineers use in solving problems.
A general method of problem solving may be described by the following steps:
1. Recognize and understand the problem.
2. Accumulate facts.
3. Select appropriate theory.
4. Make necessary assumptions.
5. Solve the problem.
6. Verify results.
Performing step 5 i.e. solve the problem may involve a computer. Given below are
five steps that are followed in using a computer as a problem-solving tool:
1. Develop an Algorithm and a Flowchart.
2. Write the program in a computer language. (i.e. Fortran, C)
3. Enter the program into the computer.
4. Test and debug the program.
5. Run the program, input data, and get the results from the computer.
1.9.2 Algorithm
The programmer begins the programming process by analyzing the problem, breaking
it into manageable pieces, and developing a general solution for each piece called an
algorithm. An Algorithm is a detailed sequence of simple steps that are needed to
solve a problem. Algorithm is the set of instructions written in plain English, for
solving a problem or sub-problem in a finite amount of time using a finite amount of
30
data. An algorithm may be a verbal or written description of a logical sequence of
actions applied to objects.
Suppose a programmer needs an algorithm to determine an employee's weekly wages.
The following algorithm reflects what would be done by hand:
1. Look up the employee's pay rate.
2. Determine the hours worked during the week.
3. If the number of hours worked is less than or equal to 40, multiply the hours by the
pay rate to calculate regular wages.
4. If the number of hours worked is greater than 40, multiply 40 by the pay rate to
calculate regular wages, and then multiply the difference between the hours worked
and 40 by 1 1/2 times the pay rate to calculate overtime wages.
5. Add the regular wages to the overtime wages (if any) to determine total wages
1.9.3 Flowchart
A Flowchart is a graphical representation of an algorithm. There are many basic
symbols available to depict the various actions performed in algorithm writing. Of the
many symbols available, these 6 basic symbols are used the most:
Start/Stop
Input/Output
31
Connector (connect one part of the flowchart to another)
Process, Instruction
Document
Preparation (may be used with "do loops" )
Decision
32
Terminator
Check your progress (9)
Say whether True Or False:
1. Program is a set of instructions.
2. Graphic representation of program is called Algorithm.
3. Rectangle symbol used for start in flowchart.
Check your progress ANSWER KEY
ANSWER 1
1. Input, output, processing. 2.Input unit. 3. Memory 4.ALU
ANSWER 2
1. True. 2. False. 3. True
ANSWER 3
1. Output. 2. Computer output microfilm. 3.Plotter 4.Speech synthesizer.
ANSWER 4
1. Digitizer. 2. Bar code. 3.OCR.
ANSWER 5
33
1. True. 2. True. 3. True.
ANSWER 6
1. True. 2. False. 3.True.
ANSWER 7
1. True. 2. True
ANSWER 8
1. False. 2. False. 3. True
ANSWER 9
1. True. 2. False. 3. False
34
Unit II : Computer Programming in Fortan /C / Basic
Structure :-
2.0 Introduction
2.1 Objectives
2.2 Constants, Variables and Data types
2.2.1 C Tokens
2.2.2 Keywords and Identifiers
2.2.3 Constants
2.2.4 Variable
2.2.5 Data types
2.2.6 C Instructions
2.2.7 Declaration of Variables
2.2.8 Where variables are declared
2.2.3 Basic Structure of C Program
2.3.1 The first C Program
2.4 Operators and Expressions
2.4.1 Arithmetic Operator
2.4.2 Relational Operator
2.4.3 Logical Operator
2.4.4 Assignment Operator
2.4.5 Increment and decrement Operator
35
2.4.6 Conditional Operator
2.4.7 Bitwise Operator
2.4.8 Special Operator
2.4.9 Precedence of Operator
2.5 Console I/O Functions
2.5.1 Formatted console I/O Functions
2.5.2 Unformatted console I/O Functions
2.6 Decision making and branching
2.7 The Loop Control Structure
2.7.1 The for Loop
2.7.2 The while loop
2.7.3 The do-while loop
2.7.4 The Break Statement
2.7.5 The continue Statement
2.8 The Case Control Structure
2.8.1 The Switch Statement
2.8.2 The Goto Statement
2.9 Array
2.10 Functions
2.11 Let Us Sum up
2.12 Check your Progress : The Key
36
37
2.0 Introduction :- A language is a means of communication. We use a natural language such as
English to communicate our ideas and emotions to others. Similarly, a computer language is
a means of communication used to communicate between people and the computer. With
the help of a computer language, a programmer tells a computer what he/she wants it to
do.
In Other words ''A language that is acceptable to a computer system is called a Computer
language or programming language, and the process of writing instructions in such a
language for an already planned program is called programming or coding.
C is a programming language developed at AT & T's Bell Laboratories of USA is 1972. It was
designed and written by a Man Dennis Ritchie. C Seems so popular is because it is reliable, simple
and easy to use. Programs written in C are efficient and fast. This is due to the variety of data types
and powerful operators. Several standard functions are available which can be used for developing
programs C is highly portable. The C character Set consists of alphabets (A,B,C ---- Z, a,b,______z,
digits (0-9), Special Symbol. ( ~, (, !, @, # etc.)
2.1 Objectives :- The main aim of this unit is to study C programming language, and its
application in the field of Chemistry to solve various Problems. Steps in learning C :
Alphabets
Digits
Special
Symbol
Constants
Variables
Keywords
Instruction Program
38
After going through this unit you should be able to develop small computer codes (Program)
involving simple formulae in chemistry such as vander waals equation, Evaluation of lattice energy,
sum of n number etc.
Implementing is C language :-
2.2 Constants, Variables and Keywords :- The alphabets, numbers and special symbols when
properly combined form constants, variables and keywords. A constant is a Quantity that
doesn't change. This quantity can be stored at a locations in the memory of the computer. A
variable can be considered as a name given to the location is memory where this constant is
stored. Naturally the contents of the variables can change.
For example in the equation.
3 x + y = 20
Since 3 and 20 cannot change, they are called constants, whereas the quantities x and y can
vary or change hence are called variables.
2.2.1 C Tokens :- In a C Program the Smallest individual units are known as C tokens. C has six types
of tokens as shown in Fig. 2.1
Chemical
equation
or
formulae
Implying Using
C varibles ,
keywords and
constants
(Declartion)
Transforming
required
equation as
'C' Statements
Executing the
'C' Statements
as sequence
of Program
C Tokens
Keywords
Eg. Float
Identifiers
Eg. Main
Constants
Eg. 15.5
Strings Eg
''ABC''
OperatorE
g +,-,*,/
Special
Symbols
39
2.2.2 Keywords and Identifiers :-
Keywords :- Keywords are the words whose meaning has already been explained to the C
compiler. The keywords cannot be used as variable names because if we do so we are trying to
assign a new meaning to the keyword, which is not allowed by the computer. The keywords are also
called 'Reserved words'
There are only 32 keywords available in C. Following is the list of keywords in C.
Identifies :- Identifiers are names that are given to various program elements such as variables,
functions and array. These are user defined names and consist of a sequence of letters and digits, in
auto double int struct
break else long Switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if slatic while
40
any order, except that the first character must be a letter. Both uppercase and lowercase letters are
permitted, although lowercase letters are commonly Used. The Underscore character is also
permitted in identifiers. It is usually used as a link between two words in long identifiers.
Ex - The following names are valid identifiers.
x y12 sun1
names area Table
2.2.3 Constants :- Constants in C refer to fixed values that do not change during the execution of a
program. Constant are also called literals.
Constants
Numeric Constants Character Constants
Integer Real Single Character String
Constant Constants Constants Constants
Integer Constants :- An integer constant is an integer valued number. Thus it consists of a sequence
of digits.
Rules for constructing Integer Constants :-
1. An integer constant must have at least one digit.
2. It must not have a decimal point.
41
3. It could be either positive or negative.
4. If no sign precedes an integer constants it is assumed to be positive.
5. No commas or blanks are allowed within an integer constant.
6. The allowable range for integer constants is - 32768 to + 32767.
Ex : 426
+ 782
-8000
-7605
Real Constants :- Real constants are often called floating point constants the real constants could be
written in two forms, Fractional form and Exponential form.
Rules for Constructing Real constants :- Following rules must be observed while constructing real
constants expressed in fractional form :
1. A real constants must have at least one digit.
2. It must have a decimal point.
3. It could be either positive or negative.
4. Default sign is positive.
5. No commas or blanks are allowed within a real constants.
Ex : + 325.34
426.0
- 32.76
- 48.5792
42
The exponential form of representation of real constants is usually used if the value of the
constant is either too small or too large. It however doesn't restrict us in any way from using
exponential form of representation for other real constants.
In exponential form of representation, the real constant is represented in two parts. The
part appearing before 'e' is called mantissa, whereas the part following 'e' is called exponent.
Following rules must be observed while construction of real constants in exponential form :
1. The mantissa part and the exponential part should be separated by a letter e.
2. The mantissa part may have a positive or negative sign.
3. Default sign of mantissa part is positive.
4. The exponent must have at least one digit which must be a positive or negative integer,
Default sign is positive.
5. Range of real constants expressed in exponential form is - 3.4 e 38 to + 3.4 e 38.
Ex : + 3.2e - 5
4. 1 e 8
- 0.2e + 3
- 3.2. e - 5
Character constant :- A single character constant (or simply character constant) contains a single
character enclosed within a pair of single quote marks.
Ex :- '5', 'x', ' '
Note that the character constant '5' is not the same as the number 5. The last constant is a
blank space.
Rules for constructing Character constants :-
43
1. A character constant is either a single alphabet, a single digit or a single special symbol
enclosed within single inverted commas. Both the inverted commas should point to the left.
For example 'A' is a valid character constant whereas ‘A’ is not.
2. The maximum length of a character constant can be one character.
Ex: 'A'
'I'
'5'
'='
String Constants :- A string constant is a sequence of characters enclosed in double quotes. The
characters may be letters, numbers, special characters and blank space.
Examples are : ''Hello'', ''1987'', ''Well done'' Remember that a character constant (eg. 'x') is not
equivalent to the single character string constant (eg ''x'') further a single character string constants
does not have an equivalent integer value while a character constant has on integer value.
Backslash Character Constants :- C Supports some special backslash character constants that are
used in output function. for example the symbol '\n'' stands for newline character. A list of such
backslash character constants is given in following table. Note that each one of them represents one
character, although they consists of two characters. These characters combinations are known as
Escape sequences.
Table Backslash Character constants
Constants Meaning
'a' Audible alert (bell)
'b' backspace
'f' from feed
'n' new line
'r' carriage return
44
'v' Vertical tab
'\' ' Single Quote
'\'' ' Double Quote
'\?' Question Mark
'\\' Backslash
'\o' null
2.2.4 Variables :- A quantity which may vary during program execution is called a variable.
A variable is a data name that may be used to store a data value. Unlike constants that
remain unchanged during the execution of a program, a variable may take different values
of different times during execution.
A variable name can be chosen by the programmer is a meaningful way so as to reflect its
function or nature in the program. Some examples of such name are :-
Average
Height
Total
Counter
Class_2
Rules for Constructing variables Names :-
1. A variable name is any combination of 1 to 8 alphabets, digits or underscore. some
compilers allow variable name whose length could be upto 40 characters. Still, it would be
safer to stick to the rule of 8 characters.
2. The first character in the variable name must be an alphabet. Some systems permit
underscore as the first character.
3. No commas or blanks are allowed within a variable name.
4. No Special Symbol other than an underscore (eg. gross_sa) can be used in a variable name.
45
5. Keyword cannot be used as a variable name. This rule means we cannot give a variable a
reserved name such as int, if.
6. The compiler treats uppercase and lowercase letters as different, although both may be
used in constructing variable names. Therefore the variable names SUM, Sum and sum are
regarded as the Separate variables in C. Usually however, Variable names in C are entirely in
lowercase.
Some examples of valid variable names are :-
John Value T_raise
Delhi X l ph_value
Mark Sum1 Distance
Invalid examples include :
123 (area)
25 cm
Further examples of variable names and their correctness are given in following table 1.1
Table 1.1 Examples of Variable Names
Variable Name Valid ? Remark
1) First_tag Valid -
2) char Not Valid char is a keyword
3) Price$ Not Valid Dollar Sign is illegal
46
4) Group one Not Valid Blank Space is not permitted
5) averagenumber Valid First Eight Characters are significant
6) int_ type Valid Keyword may be part of a name
2.2.5 Data Types :- Data types are the way to identify the type of data and associated operations
of Handling it when variables are declared of a particulars data type ; then the variable
becomes the place where the data is stored and data types is the type of value (data)stored
by the variable.A good programmer language supports the programmer by giving. Such data
types in which a control on a range of values and storage space is given to use. Finally we
can say data types determine the three things
- Memory limit
- Values Limit
- Operations Limit
Data can be classified into many types such as character, integer, real etc. Since the data to
be deal with are of many types, a programming language must provide different data types. In C
language, data types can be classified in so many ways but here we are classifying the data types
into three main categories :
1. Fundamental
2. Built in derived data type.
3. User defined derived data type.
C Data Types
Fudament
al Data
types Built in
derived
data types
User defined
derived Data
types
47
Character Structure
Integer Union
Float Array Enum Double
Pointer Typedef
Void
Generally in C four main data types are, used which may be represented differently within
the computer memory. The basic data types are :-
Data type Description Memory consumed
1. int integer Quantity 2 byte
2. char Single Character 1 byte
3. float real number 4 bytes
4. double real number with 8 bytes
more precision
Data types its format string and their Ranges
Data type Format String (Conversion
Character
Range
int % d -32768 to 32767
char % c -128 to 127
float % f - 3.4e 38 to 3.4e38
48
double % lf -1.7e 308 to 1.7e308
2.2.6 C Instructions :- Now that we have seen the different types of constants, variables and
keywords the next logical step is to learn how they are combined to form instructions. There
are basically four types of instructions in C :
1. Type declaration instruction
2. Input/Output instruction
3. Arithmetic Instruction
4. Control Instruction
The purpose of each of these instructions is given below :-
1. Type declaration Instruction :- To declare the type of variable used in a C
program.
2. Input/Output Instruction :- To perform the function of supplying input data to a
program and obtaining the output results from it.
3. Arithmetic instruction :- To perform arithmetic operations between constants
and variables.
4. Control instructions :- To control the sequence of execution of various statements
in a C program.
2.2.7 Declaration of Variables :- After designing suitable variable names, we must declare them to
the complier. Declaration does two things :
1. It tells the complier what the variable name is.
2. It specifies what types of data the variable will hold.
The declaration of variables must be done before they are used in the program.
49
Type declaration :- A variable can be used to store a value of any data type. That is, the name has
nothing to do with its type. The syntax for declaring a variable is as follows :
Data type V1, V2 - Vn,
V1, V2, ---Vn are the names of variables. Variable are separated by commas. A declaration statement
must end with a semicolon, For example, valid declarations are :
int count ;
int number, total ;
double ratio ;
char ch ;
int, double, and char are the keywords to represent integer type, real type and character type data
values respectively.
2.2.8 Where variables Are declared :- Variables will be declared in three basic places :
inside functions, in the definition of function parameters and Outside of all functions. These
are local variable, formal parameters and global variables.
Local Variables : Variable that are declared inside a function are called local variables. Local
Variables exist only while the block of code in which they are declared is executing. That is, a local
variable is created upon entry into its block and destroyed upon exit. The most common code block
in which local variables are declared is the functions.
Formal Parameters :- If a function is to use arguments, it must declare variables that will accept the
valves of the arguments. These variables are called the formal parameters of the functions. They
behave like any other local variables inside the function.
50
Check your progress 1 Notes :
i) Write your answer in the space given below.
ii) Compare your answer with those given at the end of the unit.
Fill in the Blanks.
a) A character variable can at a time store____________.
b) A C Variable cannot start with___________and__________.
c) The escape sequence character___________causes the cursor to move to the next
line on the screen.
d) Every program statement in a C program must end with a__________.
Global Variables :- Unlike local variables, global variables are known throughout the program and
may be used by any piece of code. Also, they will hold their value throughout the program's
execution. You Create global variables by declaring them outside of any function, Any expression
may access. then, regardless of what block of code that expression is in.
Basic Structure of C Program :-
Documentation Section
Link Section
Definition Section
Global Declaration Section
main ( ) Function Section
{
Declaration Part
51
The Documentation : Section consists of a set comment lines giving the name of the program, the
author and other details, Which the programmer would like to use later. The Link section provides
instruction to the complier to link functions from the system library.
The Definition Section defines all symbolic constants.
Global Declaration Section :- There are some variables that are used in more than one function.
Such variables are called global variables and are declared in the global declaration section that is
outside of all the functions. This section also declares all the user defined functions.
Every C Program must have one main ( ) function section. This section contains two parts,
declaration part and executable part.
The declaration part declares all the variables used in the executable part. There is at least
one statement in the executable part. These two parts must appear between opening and the
closing braces. The program execution begins at the opening brace and ends at the closing brace.
The closing brace of the main function section is the logical end of the program. All statements in the
declaration and executable parts end with a Semicolon.
Function 1
Function 2
'
Function N
52
The Subprogram Section contains all the user defined functions that are called in the main (
) function. User defined functions are generally placed immediately after the main ( ) function,
although they may appear is any order.
All sections, except the main () function section may be absent when they are not required.
2.3.1 The First C Program :- Each instruction is a C Program is written as a Separate statement.
Therefore a complete C program is written as a separate statement. Therefore a complete C
Program will comprise of a series of statements. These statements must appear in the same
order in which we wish them to be executed ; unless of course the logic of the problem
demands a deliberate 'jump' or transfer of control to a statement which is out of sequence.
However big a program, the following rules are applicable to all C Statements :
1. Blank spaces may be inserted between two words to improve the readability of the
statement. However, no blank spaces are allowed within a variable, constant or keyword.
2. Usually all statements are entered in Small case letters.
3. C has no specific rules for the position at which a statements is to be written. That's why it is
often called a Free - Form Language.
4. Any C statements always ends with a ; (Semicolon).
Let us now write down a simple C program to Calculate simple interest.
/ * Calculation of Simple Interest * /
main ( )
{
int p, n ;
float r, si ;
P = 1000 ;
n = 3 ;
r = 8.5 ;
53
si = (P * r * n) / 100 ;
printf (''Simple interest = %f'', si) ;
}
This program when executed will produce the following output.
Now a few useful tips about the program.
- Comment about the program should be enclosed within /* * /. For example the first
statement in our program are comments.
- Any number of comments can be given at any place in the program.
- Comment cannot be nested. For example
/*Cal of SI/*Author san date 11/11/11 */*/.
- A Comment can be split over more than one line, as in,
/* This is
a jazzy
comment */
Although a lot of comments are probably not necessary in this program, it is usually the case that
programmers tend too many. Comments should be used at any place where there is a possibility of
confusion.
- Any C Program is nothing but a combination of functions. main ( ) is one such function.
Empty parentheses after main are necessary and they are indicating that the function main
has no arguments or parameters. (The concepts of parameters will be discussed in detail
later when we discuss function).
Simple Interest = 255.000000
54
The main ( ) is a special function used by the C system to tell the computer where the
program starts. Every program must have exactly one main function, If we use more than one main
function, the complier cannot tell which one marks the beginning of the program.
- The set of statements belonging to a function are enclosed within a pair of braces. For
example,
main ( )
{
Statements 1 ;
Statement 2 ;
Statement 3 ;
}
- Any variable used in the program must be declared before using it.
For example.
int p, n ;
float r, si ;
- Any C statements always ends with a ; (Semicolon) For example,
float r, si ;
r = 8.5 ;
- In the statements
Si = (P* r* n) / 100 ;
* and / are the arithmetic operators.
- printf ( ) is a predefined standard C function for printing output. Predefined complied means
that it a function that has already been written and linked together with our program at the
time of linking.
55
- printf ( ) is a function which is used to print on the screen the value contained is a variable.
The general form of
printf ( ) statement is
printf (''<Format String'', <list of variables>) ;
printf (''message'') ;
Above two general form of printf can be merged.
For Example,
printf (''Simple interest = %f'', si) ;
The output of
printf ('' Principal = % d \n Rate = % f'', P,r ) ;
would look like Principal = 1000
Rate = 8.5
What is '\n' doing is the above printf statement ?
It is called newline and it takes the cursor to the next line. Therefore, you get the output split
over two lines. '\n' is one of the several escape sequences available in C.
2.4 Operator and Expressions :- An Operator is a symbol that perform specific mathematical or
logical manipulations in program. Operators are used in Programs to manipulate data and
variable. They usually form a part of the mathematical or logical expressions.
C Operators can be classified into a number of categories. They include :
1. Arithmetic Operator
2. Relational Operator
3. Logical Operator
4. Assignment Operator
5. Increment and decrement operators
56
6. Conditional Operators
7. Bitwise Operators
8. Special Operators
Operand :- An Operand is a constant value or Variable on which operator performs the operation.
An Operator cannot perform any operation without operand. To perform on operation, an operator
requires at least one operand. On the basis of operand used in the expression ; we can categories
the operators in another way.
- Unary Operator :- That operates on a single operand.
- Binary Operator :- When operator requires at least two operands to perform its specific
operation then is called Binary operator.
- Ternary Operator :- When Operator requires at least three operands to perform its
specific operation then it is called Ternary operator.
2.4.1 Arithmetic Operator :- Symbols that are used to perform or represent arithmetic operations
are known as Arithmetic Operator some arithmetic operations and their operators are given
in the following table.
Operator Meaning
+ Addition or Unary Plus
- Subtraction or Unary minus
* Multiplication
/ Division
% Modulo Division
Integer division truncates any fractional part The modulo division operation produces the
remainder of an integer division. Examples of use of arithmetic operators are :
57
a - b a + b
a x b a / b Here a and b are operands.
. The modulo division operator cannot be used on floating point data.
Arithmetic Expression : is a combination of variables, constants and operators arranged as per the
syntax of the language.
2.4.2 Relational Operators :- The operators proceed about the relationship between two
operands are known as relational operators. There are the binary operators that compare
the values of both operands aside itself.
An expression such as a < b or 1 < 20 containing a relational operator is termed as a
relational expression. The value of a relational expression is either one or zero. It is one if the
specified relation is true and zero if the relation is false.
For example
10 < 20 is true
but 20 < 10 is false
C Supports six relational operators These operators and their meaning are shown in table.
Operator Meaning
< is less than
< = is less than or equal to
> is greater than
> = is greater than or equal to
58
= = is equal to
! = is not equal to
A simple relational expression contains only one relational operator and takes the following form:-
ae -1 relational operator ae - 2
ae - 1 and ae - 2 are arithmetic expression, which may be simple constants, variables or combination
of them. Given below are some examples of simple relational expression end their values :
4.5 < = 10 True
4.5 < = 10 False
-35 > = 0 False
10 < 7 + 5 True
a + b = = c + d True only if the sum of values of a and b is equal to the sum of values of c and
d.
When arithmetic expressions are used on either side of a relational operator, the arithmetic
expressions will be evaluated first and then the results compared. That is, arithmetic operators have
a higher priority over relational operators.
Relational expressions are used in decision statement such as if and while to decide the
course of action of a running program.
2.4.3 Logical Operators :- To form the Complex relational expressions we use the logical operators
&& (And) and || (OR) they work as connectors for more than one expression to make
comparison more precise. There are three types of logical operators.
Symbol Name Meaning
1. & & Logical AND True when all conditions are true
59
2. || Logical OR True when one of them is true.
3. ! Logical Not Negation
The logical operator && and || are used when we want to test more than one condition and
make decisions. An example is :
a > b && x = = 10
An expression of this kind, which combines two or more relational expressions, is termed as
a logical expression or a compound relational expression.
2.4.4 Assignment Operator :- The operators are used to assigning a value of variable, constant or
expression to a variable, known as Assignment Operators.
The General form of the assignment operator is.
Variable_name = expression ;
Where an expression may be as simple as a single constant or as complex as you require.
Ex : a = 5 ;
An expression of the form variable = expression is called as assignment expression and when it is
followed by the semicolon ( ; ) it is called as assignment statement.
Compound Assignment Operators :- For compounding the expression compound assignment
operators are Used C contains the following five compound assignment operators +=, - =, *=, /= and
% = To see how they are used, consider the first operator +=,
The assignment expression
expression 1 + = expression 2 ;
is equivalent to
expression 1 = expression 1 + expression 2 ;
60
Example :- a + = 5 ;
is equivalent to a = a + 5 ;
and so on for all five operators.
Usually expression 1 is an identifiers.
2.4.5 Increment and Decrement Operators :- C allow two very useful operator not generally
found in other languages. These are the increment and decrement operators : ++ and --.
The Operator ++ Order adds 1 to the operand, while -- Subtracts 1, Both are unary operators
and takes the following form :
++ m ; or m ++ ;
- - m ; or m --;
Prefix Notation :- In prefix form operator Occurs before the operand.
Postfix Notation :- In Postfix form operator occurs after the operand.
While ++ m and m++ mean the same thing when they form statements independently, they behave
differently when they are used in expressions on the right - hand side of an assignment statement.
Consider the following :-
m = 5 ;
y = ++ m ;
In this case, the value of y and m would be 6. Suppose, If we rewrite the above statements as
m = 5 ;
y = m + + ;
then, the value of y would be 5 and m would be 6. A Prefix Operator first adds 1 to the operand and
then the result is assigned to the variable on left. On the other hand, a postfix Operator first assigns
the value to the variable on left and then increments the operand.
61
Rules for ++ and -- Operators :-
1. Increment and decrement operators are unary operators and they require variable as
their operands.
2. When postfix ++ (or--) is used with a variable is an expression, the expression is evaluated
first using the original value of the variable and then the variable is incremented (or
decrement) by one.
3. When prefix ++ (or --) is used in an expression, the variable is incremented (or
decrement) first and then the expression is evaluated using the new value of the variable.
4. The precedence and associatively of ++ and -- operators are the same as those of
unary + and Unary -.
2.4.6 Conditional Operator :- A ternary operator pair ''? :'' is available in C to construct
conditional expression of the form.
exp 1 ? exp 2 : exp 3
Where exp1, exp2 and exp3 are expression The Operators ? : Works as follows :-
exp1 is evaluated first. If it is nonzero (true) the exp2 is evaluated and becomes the valve of the
expression, IF expl is False, exp3 is evaluated and its valve becomes the value of the expression. Not
that only one of the expression (either exp2 or exp3) is evaluated.
For example, consider the following statements
a = 10 ;
b = 15 ;
x = (a > b) ? a : b ;
2.4.7 Bitwise Operators :- C has a die of supporting special operators known as bitwise operators
for manipulation of data at bit level. These operators are used for testing the bits, or shifting
them right or left. Bitwise operators may not be applied to float or double.
62
Table : Bitwise Operators
Operator Meaning
& Bitwise AND
! Bitwise OR
^ Bitwise Exclusive OR
<< Shift left
>> Shift right
2.4.8 Special Operators :- C Supports Some Special operators of interest such as Comma Operator
and Size of Operator.
Comma Operators :-The Comma Operator can be used to link the related expression
together. A comma linked list of expressions are evaluated left to right and the valve of right
most expression is the value of right most expression is the value of the combined
expression. For Example, the statement
Value = (x = 10, y = 5, x + y) ;
First assigns the value 10 to x, then assigns 5 to y, and finally assigns 15 (i.e. 10 + 5) to value.
Since comma operator has the lowest precedence of all operators, the parentheses are necessary.
The size of Operator :- The size of is a compile time operator and, when used with an operand, it
returns the number of bytes the operand occupies. The operand may be a variable, a constant or a
data type Qualifier.
Examples : m = sizeof (Sum) ;
n = sizeof (long int) ;
k = sizeof (235.5) ;
63
The sizeof Operator is normally used to determine the lengths of arrays and structures when their
sizes are not known to the programmer. It is also used to allocate memory space dynamically to
variables during execution of a program.
2.4.9 Precedence of Operators :- The order or priority in which the operations are performed in
an expression is called precedence.
Hierarchy of Operations :- The priority of precedence in which the operations in an arithmetic
statement are performed is called the hierarchy of operations. The hierarchy of commonly used
operators is shown in following table :
Priority Operators Description
Ist / * % Division, multiplication, Modular division
2nd + - Addition, Subtraction
3rd = Assignment
Now a few tips about usage of operators in general.
a) In case of a tie between operations of same priority preference is given to the operator
which occurs first. for example Z = a * b + c/d ; Here a * b will be performed before c/d
even though * and / has same or equal priority, This is because * appears prior to the /
operation.
b) If there are more than one set of parentheses the operations within the innermost
parentheses will be performed first, followed by the operations within the second innermost
pair and so on.
c) We must always remember to use pairs of parentheses. A careless imbalance of the right
and left parentheses is a common error.
Example :- Determine the hierarchy of operations and evaluate the following expression ;
i = 2 * 3/4 + 4/4 + 8-2 + 5/8
64
Stepwise evaluation of this expression is shown below :-
i = 2 * 3/4 + 4/4 + 8 - 2 + 5/8
i = 6/4 + 4/4 + 8 - 2 + 5/8 Operation : *
i = 1 + 4/4 + 8 - 2 + 5/8 Operation : /
i = 1 + 1 + 8 - 2 + 5/8 Operation : /
i = 1 + 1 + 8 - 2 + 0 Operation : /
i - 2 + 8 - 2 + 0 Operation : +
i = 10 - 3 + 0 Operation : +
i = 8 + 0 Operation : -
i = 8 Operation : +
Note that 6/4 gives 1 and not 1.5 This so happens because 6 and 4 both are integers and
therefore would evaluate to only an integer constant. Similarly 5/8 evaluates to zero, since 5 and 8
are integer constants and hence must return an integer value.
2.5 Console I/O Functions :- Functions to receive input from keyboard and write output to VDU
are known as console I/O Functions. This can be classified into two categories : Formatted
Check your progress 2
Notes : i) Write your answer in the space given below.
ii) Compare your answer with those given at the end of the unit.
Determine the hierarchy of operations and evaluate the following expression :
KK = 3/2 * 4 + 3/8 + 3
65
and Unformatted console I/O functions. The basic difference between them is that the
formatted as per our requirements. For example, if values of average marks and percentage
marks are to be displayed on the screen, the detail like where this output would appear on
the screen, then the details like where this output would be present between the two
values, the number of places after the decimal points etc. can be controlled using formatted
functions. The functions available under each of these two categories are shown in figure
2.2.
Fig 2.2
2.5.1 Formatted Console I/O Functions :- As can be seen from figure 2.2 the functions printf ( )
and scanf( ) fall under the category of formatted console I/O Functions. These functions
allow us to supply the input in a fixed format and let us obtain the output in the specified
form.
printf Function :- The general form of Printf Statement is
Console Input/Output Fnuctions
Formatted Functions
Type Input Output
char scanf() printf( )
int scanf() printf( )
float scanf() printf( )
double scanf() printf()
Unformatted Functions
Type Input Output
Char getch() putch( )
getche() putchar( )
getchar()
String gets() puts()
66
printf (''Format String'', list of variables).
or
printf (''Control String'', arg1, ang2........argn) ;
The format string (Control String) consists of three types of items :-
1. Characters that will be printed on the Screen as they appear.
2. Format Specifications that define the output format for display of each item.
3. Escape Sequence characters such as\n,\t and\b.
The Control String indicates how many arguments follow and what their types are. The
arguments arg1, arg2...........argn are the variables whose values formatted and printed according to
the specification of the control string. The arguments should match in number, order and type with
the format specifications.
Examples of printf () Statement are :-
1. printf (''Programing in C'');
2. printf ('' %d'', x) ; where x is a integer variable.
3. printf (''Sum = % f'', total) ; Where total is a float variables.
4. printf ('' \n'') ;
scanf () Functions :- The general form of Scanf ( ) Statements is as follows :-
scanf (''format string'', list of addresses of variables) ;
or
scanf (''Control String'', ang1, ang2..........angn) ;
67
The Control String Specifies the field format in which the data is to be entered and the
arguments arg1, arg2........................., argn, Specify the address of locations where the data is stored.
control string and arguments are separated by Commas.
Control string (also known as format string) contains field specifications, which direct the
interpretation of input data. It may include :
- Field (or format) specifications, consisting of the conversion character %, a data type
character (or type specifies), and an optional number, specifying the field width.
- Blanks, tabs or newlines.
Blanks, tabs and newlines are ignored The data type character indicates the type of data that
is to be assigned to the variable associated with the corresponding argument. The field width
specifier is optional.
For Example :- Scanf (''%d% f%c'', &ab, &b, &ch);
where int ab ;
float b ;
char ch ;
Note that we are sending addresses of variables (addresses are obtained by using & the address of
operator) to scanf () function. This is necessary because the values received from keywords must be
dropped into variables corresponding to these addresses.
2.5.2 Unformatted Console I/O Functions :- There are several standard library functions available
under this category - those which can deal with a single character and those which can deal with a
string of character.
(i) getchar () Function :- Reading a single character can be done by using the function getchar.
The general form of getchar () function is as follows :-
Variable _ Name = getchar () ;
68
Variable name is a valid C name that has been declared as char type. When this statement is
encountered, the computer waits until a key is pressed and then assigns this character as a
value to getchar () function, since getchar() is used on the right hand side of an assignment
statement, the character value of getchar ( ) is in turn assigned to the variable name on the
left. For example
char Name ;
Name = getchar ( );
will assigns the character 'H' to the variable name when we press the key 'H' on the
keyboard.
(ii) putchar ( ) Function :- It is used for writing character one at a time to the Screen. The
general form of putchar ( ) function is as follows.
putchar (Variable Name) ;
Where variable name is a type char variable containing a character. This statement displays
the character contained in the variable name at the terminal (Screen). For example, the
statements
char answer = 14' ;
putchar (answer) ;
Will display the character 4 on the Screen.
2.6 Decision making and Branching :- A decision control instruction can be implemented in C
using :
(a) The if statement
69
(b) The if-else statement
(c) The Conditional Operators
These statements are popularly known as Decision making statements. Since these
statement control the flow of execution, they are also known as control statements.
(a) The if statement :- C uses the keyword if to implement the decision control instruction. The
general form of if statement looks like this :
if (test expression)
{
Statement - block ;
}
The statement block may be a single statement or a group of statements. If the test
expression is true, the statement block will be executed ; otherwise the statement block will
be skipped and the execution will jump to the next statement. Remember, when the
condition is true both the statement block and the next statement are executed in
sequence.
(b) The if.....else statements :- The if-else statement is an extension of the simple if statement.
The general form is.
if (test expression)
{
True- block statements (s)
}
else
70
{
False - Block Statement (s)
}
If the test expression is true, then the true block statements (s), immediately following the if
statements are executed ; otherwise, the false - block statement (s) are executed. In either
case, either true-block or false-block will be executed, not both.
Example :-
Write a program to find given number is even or ODD.
main ( )
{
int num ;
printf (''Enter any Number'') ;
scanf (''%d''', &num) ;
if (num % 2 = = 0)
{
printf (''Even number'').
}
else
{
printf (''ODD Number'') ;
}
getch ( ) ;
71
}
(c) The conditional Operator :- The conditional operator ? and : are sometimes called ternary
operators since they take three arguments. In fact, they form a kind of fore shortened if-
else. Their general form is,
expression 1 ? expression 2 : expression 3
What this expression says is : ''if expression 1 is true (i.e. if its value is non-zero), then the
value returned will be expression2 otherwise the value returned will be expression3''.
Nesting of if ---- else statements :- If is perfectly alright if we write an entire if-else
construct within either the body of the if statement or the body of an else statement. This is
called Nesting of ifs.
if ( test condition )
{
if (test condition2)
{
Statement 1 ;
}
else {
72
Statement 2 ;
}
{
else
{
statements 3 ;
}
2.7 The Loop Control Structure :- The versatility of the computer lies in its ability to perform a
set of instruction repeatedly. This involves repeating some portion of the program either a
specified number of times or until a particular condition is being satisfied. This repetitive
operation is done through a loop control structure.
There are three methods by way of which we can repeat a part of a program.
They are :
a) Using a for statement.
b) Using a while statement.
c) Using a do-while statement.
A looping process, in general, would include the following four steps :
1. Setting and initializations of a condition variables.
2. Execution of the statement in the loop.
3. Test for a specified value of the condition variable for execution of the loop.
4. Incrementing or updating the condition variables.
The test may be either to determine whether the loop has been repeated the specified
number of times or to determine whether a particular condition has been met.
73
2.7.1 The for loop :- The general form of the for loop is :
for (initialization ; test - condition ; increment/decrement)
{
body of the loop
}
The execution of the for statement is as follows :
1. Initializations of the Control variables is done first, using assignment statements such as i =
1 and count - 0. The variables i and count are known as loop control variables.
2. The value of the control variable is tested using the test condition. The test-condition is a
relational expression, such as i < 10 that determines when the loop will exit. If the condition
is true, the body of the loop is executed ; otherwise the loop is terminated and the execution
continues with the statement that immediately follows the loop.
3. When the body of the loop is executed, the control is transferred back to the for statement
after evaluating the last statement in the loop, Now, the Control Variable is
increment/decrement using an assignment statement such as i = i + 1 or i = i-1 and the new
value of the control variable is again tested to see whether it satisfies the loop condition. If
the condition is satisfied, the body of the loop is again executed. This process continues till
the value of the control variable fails to satisfy the test-condition.
Example :-
Write a program to print counting form 1 to 50.
main ( )
{
int i ;
for ( i = 1 ; i < = 50 ; i + + )
74
{
printf I''/n%d'', i ;
}
getch ( ) ;
}
2.7.2 The While loop :- The general form of while statement is :
initialize loop counter ;
while (test condition )
{
do this ;
body of the loop ;
increment/decrement loop counter ;
}
The while is an entry controlled loop statement. The test condition is evaluated and if the
condition is true, then the body of the loop is executed. After incrementing/decrementing loop
counter, the test condition is once again. This process of repeated execution of the body continues
until the test condition finally becomes false and the control is transferred out of the loop. On exit,
the program continues with the statement immediately after the body of the loop.
The body of the loop may have one or more statements. The braces are needed only if the
body contains two or more statements. However, it is a good practice to use braces even if the body
has only one statement.
Example :-
Write a program to print table of n.
main ( )
75
{
int i, n, i ;
printf (''/n Enter the value of n'') ;
scanf (''%d'', & n) ;
for (i = 1 ; i <= 10 ; i + +)
{
j = n * i ;
print f ('' \n %d'', j) ;
}
getch ( ) ;
}
2.7.3 The do-while loop :- The general from of do-while loop is.
do
{
body of the loop
}while (test-condition) ;
The while loop construct that we have discussed in are previous section makes a test
of condition before the loop is executed. Therefore the body of the loop may not be executed at all
if the condition is not satisfied at the very first attempt. On some occasion it might be necessary to
executed the body of the loop before the test is performed. Such situation can be handled with the
help of the do statement.
On reaching the do statement, the program proceeds to evaluate the body of the loop first.
At the end of the loop, the test conditions in the while statement is evaluated. If the conditions is
true, the program continues to evaluate the body of the loop once again. This process continues as
76
long as the condition is true. When the condition become false, the loop will be terminated and the
control goes to the statement the appears immediately control goes to the statement that appears
immediately after the while statement.
Since the test-condition is evaluated at the bottom of the loop, the do-while construct provides an
exit controlled loop and therefore the body of the loop is always executed at least once.
2.7.4 The Break statement :- We often come across situations where we want to jump out of a
loop instanlly, without waiting to get back to the conditional test. The keyword break allows
us to do this. When the keywords break is encountered inside any C loop, control
automatically passes to the first statement after the loop. A break is usually associated with
an if.
2.7.5 The Continue Statement :- In some programming situations we want to take the control to
the beginning of the loop, bypassing the statement inside the loop which have not yet been
executed. The keyword continue allows us to do this. When the keyword continue is
encounter inside any C loop, Control automatically passes to the beginning of the loop. A
continue is usually associated with an if.
2.8 The case control structure :- C provides a special control statements.
Check your progress 3
Notes :-
i) Write your answer in the space given below :
ii) Compare your answer with those given at the end of the unit.
Write a program to find factorial of given number.
77
1) Switch statements.
2) goto statements.
2.8.1 The switch statements :- The control statements which allows us to make a decision from
the number of choices is called switch, or more correctly a switch-case-default, since these
three keywords go together to make up the control statement they most often appear as
follows :
switch (integer expression)
{
case constant 1 :
do this ;
case constant 2 :
do this ;
case constant 3 :
do this ;
default :
do this ;
}
The integer expression following the keyword switch is any C expression that will yield an
integer value. It could be an integer constant like 1, 2, or 3 or an expression that evaluates an
integer.
78
The keyword case in followed by integer or a character constant. Each constant in each case
must be different from all the others. The ''do this'' lines in the above form of switch represent any
valid C statement.
2.8.2 The goto statements :- C supports the goto statement to branch unconditionally from one
point to another in the program. The goto requires a label in order to identify the place
where the branch is to be made. A label is any valid variable name, and must be followed by
a colon. The label is placed immediately before the statement where the control is to be
transferred. The general form of goto and label statements are shown below :
Forward Jump Backword Jump
The label : Can be anywhere in the program either before or after the goto label ;
statement, During running of a program when a statement like goto begin ; is met the flow of
control will jump to the statement immediately following the label begin :. This happens
unconditionally.
Note that a goto breaks the normal sequential execution of the program. If the label : is
before the statement goto label ; a loop will be formed and some statements will be executed
repeatedly. such a jump is known as a backward jump. On the other hand, if the label : is placed
goto label ;
......................
......................
......................
Label :
Statemnt ;
Label ;
statement ;
......................
......................
......................
goto label ;
79
after the goto label ; Some statements will be skipped and the jump is known as a forward jump.
Consider the following example :
main ( )
{
int goals :
printf (''Enter the number of goals scored against india'') ;
scanf (''%d'', & goals) ;
if (goals < = 5)
goto sos ;
else
{
printf (''About time soccer players learnt C'') ;
printf ('' n and said goodbye addieu to soccer'') ;
}
sos :
printf (''To err is human'') ;
getch ( ) ;
}
And here are two sample runs of the Program.
Enter the number of goals scored against India 3 to err is human!
80
Enter are number of goals scored against India 7 about time soccer player learnt C and said
good bye adieu to soccer. A few remarks about the program would make the things cleaner.
- If the condition is satisfied the goto statements transfer control to the label 'sos', causing
printf() following sos to be executed.
- The label can be on a separate line or on the same line as the statement following it, as in,
sos : printf (To err is human") ;
- Any number of goto's can take the control to the same label.
- The exit ( ) function is a standard library function which terminates the execution of the
program. It is necessary to use this function since we don't want the statements.
printf (''To err is human'') ;
to get executed after execution of the else block.
- The big problem with goto's is that when we do use them we can never be sure how we got
to a certain point in our code. They obscure the flow of control. So as far as possible skip
them. You can always get the job done without them.
- The only programming situation in favour of using goto is when we want to take the control
out of the loop which is contained in several other loops.
2.9 Array :- The C language provides a capability that enables that user to design a set of similar
data types, called array.
An array is a fixed. size sequenced collection of elements of the same data type. It is simply a
grouping of like-type data. In its simplest form, an array can be used to represent a list of numbers,
or a list of names.
Thus, an Array is a collection of similar elements. These similar elements could be all ints or
all floats or all chars etc. Usually the array of characters is called a 'String', whereas an array of ints
or floats is called simply an array. Remember that all elements of any given array must be of the
same type i.e. we cannot have an array of 10 numbers, of which 5 are ints and 5 are floats.
The general form of array is
Data type variable name [size] ;
81
example : int a [10] ;
Important point about Array: -
1- The first element in the array is numbered O, so the last element is 1 less than the size of the
array.
2- Before using an array its types and dimension must be declared.
3- However big an array its elements are always stored in contiguous memory locations.
4- C performs no bounds checking and, therefore care should be exercised to ensure that the
array indices are within the declared limits.
5- It is also possible for arrays to have two or more dimensions.
(A) Simple Program Using array:- Let us try to write a program to find average marks obtained
by a class of 30 students in a test.
main ()
{
float avg, sum=o;
int i ;
float marks [30] ; / * array declaration 8/
for (i=0 ; i< = 29 ; i++)
{
printf (" in Enter marks") ;
scanf (" % ƒ", & marks [i];), /* store data in array*/
}
for ( i = 0 ; i<=29 ; i ++)
{
82
sum = sum + marks [i] ; / * read data from an array */
}
avg = sum / 30;
printf (" \n Average marks = % ƒ", avg);
getch () ;
}
2.10 Functions: - " A function is a self contained block of statements that perform a coherent task
of some kind" . using a function is sometimes like hiring a person to do a specific job for you. A
function groups a number of program statements into a unit and gives it a name .This unit can then
be invoked from other parts of the program.
Functions
Library Functions User defined functions
Library Function :- Library functions are nothing but commonly required functions grouped together
and stored in what is called a Library. This Library of functions is present on the disk and is written
for us by people who write compilers for us. Almost always a compiler comes with a library of
standards functions. Example : printf( ) , scanf ( ) , sqrt ( ), cos ( ) etc.
User defined functions:- User defined function has to be developed by the user to be developed by
the user at the time of writing a program. However, a user defined function can later become a part
of the C program library. In fact, this is one of the strengths of C language.
In order to make use of a user defined function, we need to establish three elements that
are related to function.
1- Function definition
2- Function call
83
3- Function declaration
The Function definition is an independent program module that is specially written to
implement the requirements of the function. In order to use this function we need to invoke it at a
required place in the program. This is known as the Function Call. The program (or a function) that
calls the function is referred to as the calling program or calling function. The calling program
should declare any function (like declaration of a variable) that is to be used later in the program.
This is known as the Function declaration or Function prototype.
Example:-
main ( )
{ int calsum (int x , int y, int z) l /* function declaration*/
int a, b, c, sum ;
printf ( " \n Enter three numbers"):
scanf (" % d % d % d" , &a, &b, &c);
sum = calsum ( a, b, c) ; /* calling of function */
printf (" Addition of entered nnumbers is % d", sum);
getch();
}
int calsum (int x, int y, int z) /* function definition*/
{
int d ;
d= x+y+z i
returen (d) ;
}
some important points about function :-
84
1- C program is a collection of one or more function. If a program contains only one function, it must
be main ( ), because program execution always begins with main ( ).
2- There is no limit on the number of functions that might be present in a C program.
3- A function gets called when the function name is followed by a semicolon. Each function in a
program is called in the sequence specified by the function calls in main ( ) . After each
function has done its thing, control returns to main ( ). When main ( ) runs out of function
calls, the program ends.
4- Any function can be called from any other function. Even main ( ) can be called form other
functions.
5- A function can be called any number of times. A function can call itself such a process is
called 'Recursion' .
6- A function cannot be defined in another function.
2.11 Let Us Sum up :- C is a general purpose structured programming language that is powerful,
efficient and compact. We have introduced some of the most fundamental parts of C : Constant (
Quantity that doesn't change) , Variable ( Change or Vary the value) , Keywords ( whose meaning is
predefined to complier), Arithmetie intruction and Input/Output instructions. Every program
statement in a C language must be end with a semicolon. All variables must be declared for. their
types before they are used in the program. An Operator is a symbol that perform specific
mathematical or logical manipulations in program. C supports arithmeter, relational, logical,
increment/ decrement, assignment and bitwise operators. Associativity is applied when more than
one operator of the same precedence are used is an expression. If, If-else, switch , goto and
conditional operator statments are popularly known as decision making statements .Perform a set
of instruction repeatedly is known as loop. For loop while loop and do- while loops are supported
by C Language. Collection of similar data types is known as array .A function is a self contained block
of statements that perform a coherent task of some kind.
2.12 Check your Progress : The key
1- a) 1 Character
b) A number and a special symbol
85
c) '\n'
d) Semicolon
2- kk =7
3- main ( )
{
int i, fact = 1, n :
clrscr ( ) ;
printf (" \n Enter number = ")
scanf ( " %d", &n);
for ( i = 1 ; i<=n ; i ++)
{
fact = fact * i;
}
printf(" \n Factorial of given number= % d", fact);
getch ( ) ;
}
86
UNIT-III
PROGRAMMING IN CHEMISTRY
1. Introduction
2. Computing techniques used in chemistry
2.1 Vander Waals equation
2.2 pH titration
2.3 Kinetics
2.4 Radioactive decay
2.5 Evaluation of lattice energy and ionic radii
3 Huckel theory
a) Linear equation
b) Secular equation
4 Cambridge data base
5 Let us sum up
6 Check your progress: The key
1. INTRODUCTION
87
The use of computers is well known in the scientific researches. Chemistry applications are not
exception for the use of computers. The chemical industry is also affected by the computer to get
fast and accurate results.
The computer plays an important role for solving the chemical-numeric problems by using various
software's. Now-a-days the instruments used in chemical industry are also handled by the
computers. So, we can say that the computer is becoming an integral part of the chemical industry
with reference to the software as well as hardware. On the basis of computers use in chemistry, we
can classify it as two main heads:
(i) Software's useful for numerical calculations of chemistry.
(ii) Hardware's useful for handling laboratory instruments.
These two main heads are briefly discussed in the following section of the chapter.
1. COMPUTER SOFTWARES AND CHEMISTRY
The use of Computer software in chemistry is very helpful to solve the tough and large numerical
problems. So, some software programs are required to develop for the numerical problems. The
computer programmers are able to develop these kind of application software programs.
Computer programs are already in market for the use in chemical calculations, there are some
organizations set-up for the supply of best quality software for reasonable rates. Some of these
organizations are QCPE (Quantum Chemistry Program Exchange ) and Conduit. QCPE has a software
library required for complex calculations. CONDIT provides software based on education. Some
commonly available software for chemical calculations are CIS, MSDS database, electronic
handbook, NUTRICHEM, TAPP, pKa database, molecular modeling pro, CHEMOFFICE98, SCIENTIST,
etc. The following list shows various softwares useful for chemistry.
1.1 IMCS SOFTWARE PROGRAM
IMCS (Instrument Maintenance and Calibration System) is a database program designed by
Microsoft for Windows. It is used to maintain the list and other details of the instruments and
equipments required for chemistry labs/industry. This database is able to manage the large data
items also provides user-friendly environment. The database mangos the instrument details as :
serial number, property number, manufacture, model number, description, warranty, vendor, type
etc. It can also maintain the status of instrument (available, signed out, retired) , department name,
user, location, etc. IMCS requires Windows for its processing.
1.2 HPLC OPTIMIZATION PROGRAM
HPLC optimization software is used to optimize the isocratic or gradient separations. This program is
based on the solvent strength equation. It maps the relative resolution of two initial gradients to
calculate the optimized isocratic and gradient conditions. It requires the input data as column
88
parameters, mobile phase conditions, peak names, retention times and areas. The optimal mobile
phase composition is calculated. The optimal mobile phase composition is calculated. This program
can run on Windows.
1.3 GC-SOS PROGRAM
GC-SOS is a Gas Chromatography simulation and Optimization software program. It is used to
develop the solution for the high efficiency capillary gas chromatography methods. The
chromatograms of popular formats can be imported into GC-SOS. It is useful for solving gas
chromatography retention principles and requires Windows.
1.4 HPLC CALCULATIONS ASSISTANT
This software tool is very useful for laboratory calculations. This software provides 33 built in
functions. The calculator is used to do calculations. There are 23 separate calculators used for peak
section, band spreading, resolution, detection, etc. The calculator in various sections perform
various calculations. The calculator of peak section is used to calculate retention time, peak velocity,
retention volume, selectivity, plates, asymmetry. The calculation results are stored in electronic
notebook.
1.5 MASS SPEC CALCULATOR
It is utility software which is used to observe the mass-spectrum of chemical structure. The program
is able to draw molecules on screen quickly. It automatically updates the molecular weight,
molecular formula, elemental composition and valence of hydrogen's of each atom in molecule.
2. COMPUTING TECHNIQUES USED IN CHEMISTRY
Various computing techniques are used in chemical laboratories to handle the chemical instruments.
Some chemical areas like chromatography, Spectroscopy, Spectrometry, etc. use the computing
techniques for easy and fast calculations. Let us have a look for some of these techniques.
CHROMATOGRAPHY
There are three major uses for computes in chromatographic instrumental method development.
(i) Instrumental Control : The use of microprocessor for instrumental control is now and
important feature of modern instrumental systems. For example, in HPLC, microprocessors are used
in solvent metering systems to blend solvents and provide precise flow control, in detectors to
maximize signal to noise ratio, and select the wavelength, in ovens to control and change
temperature, in auto samplers to control and change temperature, in auto samplers to reproducibly
inject various samples onto the column at selected times. All of these features increase both the
precision and accuracy of HPLC instrument, which are the critical features for any method
development procedure.
89
(ii) Data Acquisition and Analysis : A second important use of computers is for the analysis of
raw data from the detector, to provide the final information needed for method development.
Modern data systems supply software for determining band width, peak height and peak area and
for simple calculations such as K', Rs, etc. Such capabilities often are essential because method
development procedures require a measurement of separation quality for various peak pairs in the
chromatogram.
(iii) Prediction of separation as a function of experimental conditions : Most of the software for
optimization and method development emphasize the predictive aspects.
SPECTROSCOPIC LIBRARY SEARCHING AND STRUCTURE ELUCIDATION
The elucidation of the molecular structure of an unknown compound is a common task for chemists.
A variety of approaches can be taken and a variety of data can be used both physical and chemical
methods are available and spectroscopic techniques are almost universally employed. The process of
elucidating unknown molecular structures involves the repeated applications of three steps:
(i) Posing of candidate structure
(ii) Comparing them against available data.
(iii) Narrowing the list of candidate structure.
These steps can be called the posing, testing and rejecting of hypothesis. The methods used in
routine structure elucidation include infrared spectroscopy, visible ultraviolet spectroscopy, NMR
spectroscopy and mass spectroscopy.
MASS SPECTROMETRY
The variation of experimental design and data interpretation have led major enhancement in the
utility of Mass Spectrometry (MS) for structure elucidation. The ionization methods now include
electron impact, chemical ionization, fast atom bombardment, ion-molecule reactions in MS/MS
instruments and so on. One direct approach of structure elucidation involves searching through a file
of reference spectra in a library. To perform a library search, one must have a reference library of
reasonable size, quality and standardized format, and a searching algorithm that includes an
effective method for assessing the degree of similarity between two spectra.
The experimentally determined spectrum of the unknown compound is compared to each spectrum
in the reference file. A list of best matches is presented as the output. Mass spectra are very well
suited for computer-aided information. Some reasons for this assertion are that mass spectral peaks
occur at discrete value of mass and for low resolution mass spectra. They even occur at integral
mass to charge (m/c) ratios (except for meta stable ion peaks and in some advance mass
spectrometry techniques). The mass spectra are rich in structural information since the ions
observed are due to uni-molecular decomposition reaction.
90
INFRARED SPECTRA
The infrared spectrum of a compound provides structural information that is complimentary to that
contained in the mass spectrum. It provides a method for "fingerprinting" organic compounds with
regard to their functional groups. The presence of certain atom types, certain bond types and
functional groups can be confirmed by comparing the observed spectrum with the correlation
charts. The rules obtained in correlation charts have be built up over many years by experimentalists
by empirical observation.
The most desirable way to use an infrared spectrum of an unknown compound is to compare it to
the members of a file of unknown and one of the file spectra is strong evidence of structural
similarity of even identity. This searching option is only available if one has access to a large file of
identified spectra of similar structural type of the unknown.
Vander Waals Equation
The Vander Waals equation is an equation of state for a fluid composed of particles that have a non-
zero volume and a pair wise attractive inter-particle force (such as the Vander Waals force.) It was
derived by Johannes Diderik Vander Waals in 1873, who received the Nobel prize in 1910 for "his
work on the equation of state for gases and liquids". The equation is based on a modification of
the ideal gas law and approximates the behavior of real fluids, taking into account the nonzero size
of molecules and the attraction between them.
Equation
The first form of this equation is
where
p is the pressure of the fluid, v is the volume of the container holding the particles divided by the
total number of particles, k is Boltzmann's constant, T is the absolute temperature, a' is a measure
for the attraction between the particles, b' is the average volume excluded from v by a particle.
Upon introduction of the Avogadro constant NA, the number of moles n, and the total number of
particles nNA, the equation can be cast into the second (better known) form
Where p is the pressure of the fluid, V is the total volume of the container containing the fluid , a is a
measure of the attraction between the particles , b is the volume excluded by a mole of
91
particles , , n is the number of moles, R is the universal gas constant, , T is
the absolute temperature.
A careful distinction must be drawn between the volume available to a particle and the volume of a
particle. In particular, in the first equation refers to the empty space available per particle. That
is, is the volume V of the container divided by the total number nNA of particles. The parameter b',
on the other hand, is proportional to the proper volume of a single particle - the volume bounded by
the atomic radius. This is the volume to be subtracted from because of the space taken up by one
particle. In Van der Waals' original derivation, given below, is four times the proper volume of the
particle. Observe further that the pressure p goes to infinity when the container is completely filled
with particles so that there is no void space left for the particles to move. This occurs when V = n b.
(1) Computer Pressure from Van der Waal's Equation P =
Flowchart
Program
#include<stdio.h>
#include<conio.h>
void main()
{
End
Start
Input values a, b
r = 0.0821
Input number of moles (n)
volume v), temperature in
Kelvin(t)
p= ((n*r*t)/(v-n*b)) – ((n*n*a)/(v*v)
Print Pressure (P)
92
int n;
float a, b, r, v, t, p
clrscr();
printf("\n Enter value of 'a' for the given gas:");
scanf("%f"; &a);
printf("\n Enter value of 'b' for the given gas:");
scanf(%f", & b);
r= 0.0821;
printf("\n Enter no. of moles of gas:");
scanf("%d", & n));
printf("\ n Enter the volume of gas");
scanf("\%f"; v);
print*"\Enter the temperature in Kelvin:");
scanf("%f", & t);
P= ((n*r*t)/(v-n*b)) – ((n*n*a)/(v*v));
Printf("/n The calculated pressure is = % f atm", p);
getch ();
}
(2) Computer Van der Waal's constants 'a' and 'b' for a gas by :
Flowchart
Start
Input the pressure (P), Volume
(V)
number of moles (n)
a = ((p*v*v)/(n*n))
b=(v/n)
Print a and b
End
93
Program
#include <stdio.h>
#include <conio.h>
{
int n;
float P,V, a,b;
clrscr( ) ;
printf("\n Enter the pressure of gas:");
scanff("%f", &P);
printf("\n Enter volume of gas:");
scanf("%f", &P) ;
printf("%f", &v);
printf("\n enter the number of moles:");
scanf("%d", &n);
a=((p*v*v)/(n*n));
b=(v/n);
printf("\n The value of van der waals contestants for given gas is –
\na = a%f \nb =% f", a, b);
getch ( );
}
2.2 pH Titration
Titrations are often recorded on titration curves, whose compositions are generally identical:
the independent variable is the volume of the titrant, while the dependent variable is
the pH of the solution. The equivalence point is a significant point on the graph (the point at
which all of the starting solution, usually an acid, has been neutralized by the titrant, usually
a base).
94
In monoprotic acids, the point halfway between the beginning of the curve (before any titrant
has been added) and the equivalence point is significant: at that point, the concentrations of
the two species (the acid and conjugate base) are equal. Therefore, the Henderson-
Hasselbalch equation can be solved in this manner:
Therefore, one can easily find the pKa of the monoprotic acid by finding the pH of the point
halfway between the beginning of the curve and the equivalence point, and solving the
simplified equation.
Calculate pH of a solution and find that it is basic, acidic or neutral by
pH = - log[H+]
Flowchart
Program
# include <stdio.h>
No
No
Start
input hydrogen concentration (H1)
and power of 10 in it (H2)
H=H1*(pow(10, H2)
pH=(loh(H)*(-1)
Print pH
End
is
pH<7
is
pH>7
solution is basic
Solution is neutral
solution is acidic
95
#include <conio.h>
#include<math.h>
void main ()
{
clrscr ();
float pH,H;
int H2;
printf("\n Enter the hydrogen ion concentration besides the power 10:");
\* if H=3.3 ×10-2 then H1 =3.3 and H2= - 2*/
scanf("%f", % H1);
printf("\n Enter the power of 10 in hydrogen ion concentration :");
scanf("%f", H1);
printf("\n Enter the power of 10 in hydrogen ion concentration:");
scanf("%d", &H2);
pH=(log (H)* (-1);
printf("\n pH value of solution = %f", pH);
if (pH < 7)
printf("\n Solution is acidic");
else if (pH>7)
printf("\n Solution is basic");
else
printf("\n solution is neutral");
getch ();
}
Calculate pH of a solution by pH = pKa + log find that it is basic or acidic.
Program
96
# include <stdio.h>
#include <conio.h>
#include<math.h>
void main ()
{
clrscr ();
float K1, Ka, pKa, pH, salt, acid;
int K2;
printf("\n Enter the value of Ka besides the power of 10:");
scanf("%f", & K1) /*if =1.8 ×10-5, than K1 = 1.8, K2 = -5*/
printf("\n Enter the power of 10 in ka:");
scanf("%d", & K2);
Ka = K1 * (pow (10, K2));
pKa=log(ka) * (-1);
printf("\n Enter the salt concentration mole per litre:");
scanf("%f", & acid);
pH= pKa + (log (salt/acid));
printf("\n Value of pH of the solution = %f", pH);
if (pH <7)
print ("\n Solution is acidic");
else if (pH > 7)
print ("\n Solution is basic");
else
printf("\n solution is neutral");
getch ();
}
Flowchart
Start
input ka (k1) and powers of 10 in it
(k2)
Ka = K1 * (pow(10, K2))
97
yes
No
Yes
No
2.3 Calculate kinetic energy of a gas by E = 3/2 nRT where R = 8.324 JK-1, mol-1
T = temperature in kelvin (0C + 273) n = given number of moles of gas
Flowchart
End
is
pH<7
is
pH>7
solution is basic
Solution is neutral
solution is acidic
pH = pKa + (log (salt/acid))
Print pH
Start
Input the number of moles(n),
temperature in centigrade
T = T ÷ 273
E = (3 * n * R * T)/2
98
Program
# include < stdio . h >
# include < conio . h >
main()
{
int T, n;
float R, E;
clrscr();
R = 8.324;
printf(''\n Enter the number of moles:'');
scanf(''% f'', &n);
printf(''\n Enter the temperature in centigrade:'');
scanf(''%d'', &T);
T = T + 273;
E = (3 * n * R * T)/2;
printf(''\n The kinetic energy of given no. of moles of gas = %f joule'',E);
getch();
}
2.4 Radioactive decay is the process by which an atomic nucleus of an unstable atom loses
energy by emitting ionizing particles (ionizing radiation). The emission is spontaneous, in that the
atom decays without any interaction with another particle from outside the atom (i.e., without
a nuclear reaction). Usually, radioactive decay happens due to a process confined to the nucleus of
the unstable atom, but, on occasion (as with the different processes of electron capture and internal
conversion), an inner electron of the radioactive atom is also necessary to the process.
Print E
End
99
Radioactivity was first discovered during 1896 by the French scientist Henri Becquerel, while working
on phosphorescent materials. These materials glow in the dark after exposure to light, and he
suspected that the glow produced in cathode ray tubes by X-rays might be associated with
phosphorescence. He wrapped a photographic plate in black paper and placed various
phosphorescent salts on it. All results were negative until he used uranium salts. The result with
these compounds was a blackening of the plate.
Particular radionuclide’s decay at different rates, each having its own decay constant (λ). The
negative sign indicates that N decreases with each decay event. The solution to this first-
order differential equation is the following function:
Where N0 is the value of N at time zero (t = 0). The second equation recognizes that the
differential decay constant λ has units of 1/time, and can thus also be represented as 1/τ, where τ is
a characteristic time for the process. This characteristic time is called the time constant of the
process. In radioactive decay, this process time constant is also the mean lifetime for decaying
atoms. Each atom "lives" for a finite amount of time before it decays, and it may be shown that this
mean lifetime is the arithmetic mean of all the atoms' lifetimes, and that it is τ, which again is related
to the decay constant as follows:
Compute the decay constant by K=
Flowchart
Program
# include <stdio.h>
k = (2.303/t)*(log(No/n))
Print k
End
Start
input initial amount of radioactive substance (No)
and remaining amount(N), time interval (t)
100
#include <conio.h>
#include <math.h>
void main ( );
{
clrscr ( );
float K, t, No, N;
printf("\n Enter the initial amount of radioactive substance :");
scanf("%f", & No);
printf("\n Enter the remaining amount of radioactive substance:");
scanf("%f", &N);
printf("\n Enter the time interval:");
scanf("%f", &t);
K= (2.303/t)*(log(No/N));
printf("\n Decay constant = %f", K);
getch () ;
}
Half-life
A more commonly used parameter is the half-life. Given a sample of a particular radionuclide, the
half-life is the time taken for half the radionuclide's atoms to decay. The half-life is related to the
decay constant as follows:
This relationship between the half-life and the decay constant shows that highly radioactive
substances are quickly spent, while those that radiate weakly endure longer. Half-lives of known
radionuclide’s vary widely, from more than 1019years (such as for very nearly stable nuclides,
e.g., 209Bi), to 10−23 seconds for highly unstable ones.
The factor of ln2 in the above relations results from the fact that concept of "half-life" is merely a
way of selecting a different base other than the natural base e for the lifetime expression. The time
constant τ is the "1/e" life (time till only 1/e = about 36.8% remains) rather than the "1/2" life of a
101
radionuclide where 50% remains (thus, τ is longer than t½). Thus, the following equation can easily
be shown to be valid.
Since radioactive decay is exponential with a constant probability, each process could as easily be
described with a different constant time period that (for example) gave its "1/3-life" (how long until
only 1/3 is left) or "1/10-life" (a time period till only 10% is left), and so on. Thus, the choice
of τ and t½ for marker-times, are only for convenience, and from convention. They reflect a
fundamental principle only in so much as they show that the same proportion of a given radioactive
substance will decay, during any time-period that one chooses.
Compute the number of half life n by N=N0
Flowchart
Program
# include <stdio.h>
#include <conio.h>
#include <math.h>
main()
{
float N, No.;
int n;
clrscr ();
n= log(N/No)/(log(0.5))
Print n
End
Start
input initial amount (No.) and
remaining (N) of radioactive
substance
n= log(N/No)/(log(0.5))
Print n
End
Start
input initial amount (No.) and
remaining (N) of radioactive
substance
102
printf("\n Enter the initial amount of radioactive substance:");
scanf("%f", & No);
printf("\n The remaining of radioactive substance:");
scanf("%f", & N);
n= ((log N/No)) / (log (0.5));
print ("\n Number of half lives = %d",n);
getch ( ) ;
}
Compute average life period by T=
Flowchart
Program
# include <stdio.h>
#include <conio.h>
void main ( );
{
float t, T;
clrscr ( );
printf("\n Enter the value of half life period:");
scanf("%f", & t);
T= (1.44 * );
printf("\ n Average life period = %f", T);
getch ( );
}
T = (1.11 * t)
Print t
End
Start
input half life period t
103
Compute the half life by t½=
Flowchart
Program
# include <stdio.h>
#include <conio.h>
void main ( );
{
float t, k;
clarcr ( );
printf("\n Enter the decay constant of Radioactive Reaction :");
scanf("%f", & k");
t= (0.6931/k);
printf("\n The half life period of given substance = %f", t);
getch ( );
}
2.5 Compute lattice energy by �0=
Flowchart
t = (0.6931 /k)
Print t
End
Start
input decay constant (k) for the reaction
u= (n*A*e*e*Z1*Z2*(1-n))/(r*n)
Print u
End
Start
input Avagadro Number (N), Madlung constant (A),
Electrial Charge (C) Charge on Cation (Z1)charge on
Anion (Z2) distance (r) , born exponent (n)
104
Program
# include <stdio.h>
#include <conio.h>
main ( );
{
clrsc ( );
long double u, N, A, e, Z1, Z2, r;
int n;
printf("\n Enter Avogadro Number:");
scanf("%Lf", & N);
printf ("\n Enter Madlung Constant:");
scanf("% Lf', & A);
printf("\n Enter Electrical Charge:");
scanf("/%Lf", & e);
printf("\n Enter Charge on cations:");
scanf("%Lf", &Z1);
printf("\n Enter charge Anions:");
scanf("%Lf",& Z2)
Printf("/n Enter minimum distance between cation and anion at which potential energy becomes
minimum:");
scanf("%Lf", &r);
printf ("\n Enter Born Exponent:");
105
scanf("%d", & n);
u=(N*A*e*e*Z1*Z2*(1-n))/r*n);
printf("\n lattice energy = %Lf", u);
getch ( );
}
Find radius of an orbit by r = , where m = mass of electron
= 9.1 x 10-31, v = velocity of electron, h = 6.6256 x 10-2 erg sec.
Flowchart
Program
# include < stdio . h >
# include < conio . h >
# include < math . h >
main()
{
clrscr();
Start
Input velocity of electron (V)
number of orbit (n)
h = 6.6256*(pow(10,-2))
pie = 3.14
m = 9.1*(pow(10,-31))
r = (n*h)/(2*pie*m*V) Print r
End
106
float v, pie, h; long double m, r;
int n;
h = 6.6256*(pow(10,-2));
pie = 3.14;
m = 9.1*(pow(10,-31));
printf(''\n Enter the value of velocity of electron in cm/sec:'');
scanf(''% f'', &v);
printf(''\n Enter the number of orbit:'');
scanf(''%d'', &n);
r = (n*h)/(2*pie*m*v);
printf(''\n The radius of the orbit = % Lf'', r);
getch();
}
Calculate Bohr's radii for given orbit number r = n2 * 0.529 * 10 -8 where
n = number of orbit.
Flowchart
Program
Start
Input number of orbit (n)
r = n * n * 0.529 * (pow(10,-8))
Print r
End
107
# include < stdio . h >
# include < conio . h >
# include < math . h >
main()
{
clrscr();
int n;
float r;
printf(''\n Enter the number of orbit:'');
scanf(''%d'', &n);
r = n * n* 0.529 * (pow(10, -8));
printf(''\n The Bohr radii of given orbit = %f cm.'',r);
getch();
}
Check your progress: 1
1. Name the database program designed by Microsoft for Windows which is used to maintain the list
and other details of the instruments and equipments required for chemistry labs/industry.
2. Who received the Nobel prize in 1910 for "his work on the equation of state for gases and
liquids"?
3. Name the point at which all of the starting solution, usually an acid, has been neutralized by the
titrant, usually a base.
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
------------------------
3. Huckel Theory
This theory was originally introduced to permit qualitative study of the π-electron systems in planar,
108
conjugated hydrocarbon molecules (i.e. in "flat" hydrocarbon molecules which possess a mirror
plane of symmetry containing all the carbon atoms, and in which the atoms of the carbon skeleton
are linked by alternating double and single carbon-carbon bonds when the bonding is represented in
a localised fashion). It is thus most appropriate for molecules such as benzene or butadiene, but the
approach and concepts have wider applicability.
Assumptions of Hückel theory. In Hückel theory, we do not actually evaluate the integrals
represented by the Hs and Ss above. Furthermore, we make a set of assumptions to reduce the
complexity of the linear equations. These assumptions are as follows:
1. The integrals of type Hij, where i = j, are related to the energy of an electron in an isolated carbon 2p orbital. They are called Coulomb integrals.
o we assume they all are equal, regardless of the molecular environment of the particular carbon
o we use for all of them the symbol a. 2. The integrals of the form Hij, where i is not equal to j, are related to the energy lowering that
occurs upon allowing an electron to occupy both orbitals. o this energy is dependent upon the distance between the orbitals o Hückel theory assumes that if i and j are on adjacent atoms (| i - j | = 1), the
interaction will be the same o these integrals are represented by b; they are the resonance integrals. o If i and j are not adjacent, we assume there is no energy gain, and set these integrals
equal to zero. 3. The S type integrals are called overlap integrals. They are related to the energy of interaction
between electrons in i and j. We assume they can be divided into two groups. o If i = j, we set the integrals = 1 o If i does not equal j, we set them = 0 o This trick, of ignoring differences in interaction between orbitals, is called neglect of
differential overlap, or NDO.
We can summarize the assumptions in the form of a table:
Substituting the values into the set of simultaneous equations yields:
109
Such a set of equations has a solution (other than the trivial one of all unknowns equal to
zero) only if the determinant formed from the coefficients of the unknowns is equal to zero:
This determinant is called the secular equation.
Returning to ethylene, we find that the secular equation comes out to be:
which has two solutions: e1 = a + b and e2 = a - b. With a taken as the energy of an electron
isolated in a carbon 2p orbital, the energy changes associated with the formation of the p-
bond can be shown as:
The two electrons occupy the lower level, and the p-bond energy can be calculated as:
To get the coefficients, c1 and c2, we can substitute the values for e in the linear equations,
and make use of the additional equation:
110
This expression is called the normalization condition, and it amounts to saying that the
fractional AO contributions to one MO have to add up to one. Solving the expressions for
ethylene lead to two sets of coefficients:
c1 = c2 = 0.707 and c1 = -c2 = 0.707
so we can write the two wavefunctions corresponding to the two energies above as:
The change of sign in the second expression indicates an inversion of the phase relationship
between the two AOs: a node. Pictorially, this can be represented in the familiar diagrams:
Check your progress: 2
4. Which theory was originally introduced to permit qualitative study of the π-electron systems in
planar, conjugated hydrocarbon molecules?
5. Which integrals for all the carbon atoms are assumed to be identical?
6. Which elements have different row numbers and column numbers and are equal to the relevant
resonance integrals?
………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………
111
4. The Cambridge Structural Database
The Cambridge Structural Database (CSD) is the principal product of the CCDC. It is the central focus
of the CSD System, which also comprises software for database access, structure visualisation and
data analysis, and structural knowledge bases derived from the CSD.
The CSD records bibliographic, chemical and crystallographic information for:
organic molecules metal-organic compounds whose 3D structures have been determined using X-ray
diffraction neutron diffraction .The CSD records results of: single crystal studies powder diffraction
studies which yield 3D atomic coordinate data for at least all non-H atoms. In some cases the CCDC is
unable to obtain coordinates, and incomplete entries are archived to the CSD.
The CSD includes crystal structure data arising from: publications in the open literature Private
Communications to the CSD (via direct data deposition) .The Cambridge Structural Database (CSD) is
distributed as part of the CSD System which includes software for: search and information retrieval
(ConQuest) structure visualisation (Mercury)numerical analysis (Vista)
The Cambridge Structural Database (CSD) is the only comprehensive collection of small-molecule
organic and organometallic crystal structures determined by X-ray and neutron diffraction
techniques. It is maintained at the Cambridge Crystallographic Data Centre (CCDC).
As such, the CSD is one of the most important sources of experimental data on the shape and
dimensions of molecules and a unique source of data on intermolecular interactions. A set of
specialised programs developed at the CCDC enable searching of the database and the statistical
analysis and visual display of results and structures.
The CSD and the software together constitute the CSD System.
The CSD System is widely used by over 100 industrial companies in many areas of research including
rational drug and agrochemical design, formulation of novel non-linear optical materials and design
of catalysts for the petrochemical industry. It is also used for fundamental research in some 1,000
universities and research institutes, worldwide.
The following pages provide a brief account of the different parts of the CSD System. The main
database (the CSD) is searched by the program QUEST. Statistical analysis of the resultant hits is
carried out using the program VISTA. Individual molecular structures and their environment in the
crystal is visualised with the program PLUTO.
This data field incorporates all of the bibliographic material for the particular entry and summarises
the structural and experimental information for the crystal structure. The text and numerical
112
information includes the authors names and the full journal reference, as well as the crystallographic
cell dimensions and space group.
2D Information
A conventional chemical diagram of the molecule is stored in this information field. This is encoded
as a chemical connection table comprising atom and bond properties. Atom properties include
element symbol, number of connected non-hydrogen atoms, number of connected hydrogen atoms,
and the net charge. Seven different bond types can be specified in bond properties.
3D Information
A 3D representation of the molecule can be generated from the information stored in this field. This
data includes the atomic coordinates, the space group symmetry, the covalent radii and the
crystallographic connectivity established by using those radii. The 3D representation is matched with
the 2D chemical structure.
QUEST
The QUEST program is the basic search engine for the CSD. It allows the user to design and specify a
query which is then used to interrogate the database. The database is searched sequentially until
the program locates a CSD entry which matches the search criteria. QUEST can be used to search the
database for textual and numerical information and 2D structures and substructures. It can also be
used for 3D (geometric) searches and to search the extended crystal structure for inter- and intra-
molecular non-bonded interactions. Various geometric parameters (bond lengths, bond angles etc.)
can be defined for a search and values will be tabulated for subsequent analysis with VISTA.
QUEST allows the user to view all of the information available for a hit entry. The 3D representation
can be manipulated and analysed using the tools available in the 3D display window. These include
viewing the packing diagram, performing a variety of geometry calculations and having the ability to
rotate, translate and enlarge the molecule.
The user can elect to keep or reject a hit and the search then continues until the next hit is located.
This process is repeated until the end of the database is encountered or until the user stops the
search. At any stage the user can elect to allow the search to run non-interactively, in which case all
hits located by QUEST will be retained.
Check your progress:
7. The …………………………program is the basic search engine for the CSD.
8. Various geometric parameters (bond lengths, bond angles etc.) can be defined for a search and
values will be tabulated for subsequent analysis with …………………..
113
9. Which program visualized individual molecular structure and their environment in the crystal?
…………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………
………………………………………………………………………….
5. Let us sum up
The use of computers is well known in the scientific researches. Chemistry applications are not
exception for the use of computers. The chemical industry is also affected by the computer to get
fast and accurate results. some computer programs are already in market for the use in chemical
calculations, there are some organizations set-up for the supply of best quality software for
reasonable rates. Some of these organizations are QCPE (Quantum Chemistry Program Exchange )
and Conduit. QCPE has a software library required for complex calculations. CONDIT provides
software based on education. Some commonly available software for chemical calculations are CIS,
MSDS database, electronic handbook, NUTRICHEM, TAPP, pKa database, molecular modeling pro,
CHEMOFFICE98, SCIENTIST, etc. The following list shows various softwares useful for chemistry.
The Cambridge Structural Database (CSD) is the principal product of the CCDC. It is the central focus
of the CSD System, which also comprises software for database access, structure visualisation and
data analysis, and structural knowledge bases derived from the CSD.The CSD records bibliographic,
chemical and crystallographic information .
6. Check your progress: The key
1. Instrument Maintenance and Calibration System
2. Johannes Diderik Vander Waals
3. Equivalence point
4. Huckel theory
5. Coulomb Integrals
114
6. Off diagonal elements
7. QUEST
8. VISTA
9. PLUTO
115
UNIT-IV
USE OF COMPUTER PROGRAMS
4.1 How to operate a PC
4.2 Execution of linear regression
4.3 X-Y Plot
4.4 Numerical Integration and Differentiation
4.4.1 Differential equation solution programs
4.5 Monte Carlo and molecular dynamics
4.6 MATLAB
4.7 FOXPRO
4.8 MS-WORD
4.9 Let us sum up
4.10 Check your progress: The key
116
4.1 How to operate a PC
This procedure attempts to outline the basics in operating a computer system based on the
assumption that it is running under the Microsoft Windows XP Operating System platform
with normal components such as CD or DVD drive installed in the CPU.
Step 1
Prior to powering up the computer system, make sure that the power cord is firmly
connected to the back panel of the CPU and is plugged into the wall socket.
Step 2
Check if the video cable is firmly screwed to the port of the video card with the other end
connected to the back panel of the monitor.
Step 3
Make sure that both the keyboard and mouse pointing device are securely plugged to the
back panel. Also, check if they are connected to the correct port by checking on the
markings. Steps 1 to 3 are essentially easy to do because aside from the mouse and
keyboard devices, other components can only be plugged into their proper ports preventing
the novice user from interchanging them.
Step 4
117
When all connections are secure, start up the machine by pressing the power button
normally located in the front panel of the CPU.
Step 5
Depending on the configuration of the machine, a username and password may be
requested; otherwise, the Operating System may be loaded directly to display the desktop
to the user.
Step 6
Other basic operations that can be done include adjusting monitor settings in Step 8.
Installation and launching of software is outlined in Step 10. Navigation of the file system is
detailed from Step 15.
Step 7
The proper way to shut down or turn off the computer system is by clicking on the 'Start'
button and choosing the 'Turn Off Computer' option. This will display the options to
'Standby', 'Restart', or 'Turn Off' the machine.
Step 8
To adjust the monitor settings, right click on any blank portion of the desktop and select the
'Properties' option from the context menu.
Step 9
On the 'Display Properties' window, select the 'Settings' tab to adjust the resolution of the screen.
The 'Themes' tab will allow the loading of pre-designed Windows themes. The 'Desktop' tab provides
the way for changing the color of the desktop as well as the displayed wallpaper. The 'Appearance'
tab provides the various options of changing the behavior of the windows, icons, and other elements
of the platform, while the 'Screen Saver' tab shows the option to allow the monitor to go on standby
or display animation.
Step 10
To extend the functionality of any computer system, software is normally installed into the local
hard drive. A software installer may be through some media like a CD or DVD or from being
downloaded from the Internet.
Step 11
For CD or DVD installers, insert the installation disk in the CD or DVD drive of the machine. This will
be automatically read and launched by the Operating System.
Step 12 When the installation process is initiated, a new window will normally be displayed to the
user. Majority of newer installers provide either a default or an advanced installation procedure. In
118
most cases, simply click on the default process to allow the installer to complete the entire process
with minimum user intervention.
Step 13
Upon completion of the installation process, a user may be prompted to reboot the machine. Follow
the guide in Step 7 to accomplish this task.
Step 14
To launch the software, simply click on the 'Start' Menu, choose 'All Programs' and select from the
menu the program intended to be run. An alternative to this process is to check if a shortcut link is
created on the Desktop. Clicking this icon will also launch the associated program.
The Mouse
The Mouse is the device you will use for most of your interactions with your PC. It is
primarily used to move the pointer arrow around the screen and to select and activate options.
The mouse buttons are used to interact with whatever is on the screen where the pointer is
located. The left mouse button is the one you will use most often. Clicking this tells the PC to
select an item and is called 'left-clicking'. To activate an item and use it, you will often need
to click the button twice or 'double-click'.
If you click and hold the left button and move the mouse, this has the effect of 'dragging' a
selected object about the screen until you release the button.
Left-clicking on text in a document will place a flashing cursor at that point, which allows
you to begin typing there.
The right mouse button is usually used to bring up a small menu window that gives options
specific to the selected object. To use a particular option you just left-click it.
Common right-click menu options for an object include: Open (activate, same as if you
double-click), Cut (remove to be placed elsewhere), Copy (make a copy of this object)
,Create Shortcut (create a shortcut link elsewhere to give quick access to this
object), Delete (remove permanently), Rename (give a new name), and Properties (find out
information).
You may have a third smaller button in the center of your mouse that can be rolled forwards
and backwards. This mouse-wheel can be used to move up and down through documents.
The Keyboard
Keyboards can come in a number of different layouts. QWERTY keyboards are so-called
because the top line of letters, underneath the number line, begins with those six letters.
There are a number of other useful keys too. The Enter key confirms a selection, and pressing
the Shift or Caps Lock keys activates uppercase letters when you type, or special characters
on number keys.
There are a number of function keys beginning with F1, F2 and so on, and these are used to
access different options in different programs. Other keys such as Home, End and Page
Up and Page Down allow you to quickly move about within a document.
The arrow keys move the text typing cursor up, down, left or right.
You may have a number keypad too. This acts as an alternative to the number keys above the
main letter keys. Pressing the Num Lock button will switch between using the keypad as
number keys, or arrow keys.
119
The Desktop
The Desktop is the main background on your screen when you are working on your PC. It
consists of a background picture or 'wallpaper', any program shortcuts you have created, and
the Taskbar.
The Taskbar runs along the bottom of the screen (or the side, or top - you can click and drag
it wherever you want to place it) and shows the date and time as well as giving you access to
the Start menu. You can also put program shortcuts on the taskbar so that one click will
activate a particular program.
Left-clicking on the Start menu brings up the All Programs list of shortcuts to programs you
have on your computer. These are often arranged in 'folders', so that you can find all the
programs made by one company under a folder in their name.
By holding the mouse pointer over a folder you will see a new list appear of whatever
programs are within that folder. Some programs will have several related entries - so you
might see a README (a document that has instructions for using the program), or an option
to Uninstall (remove the program from your PC).
You can access your Desktop settings by right-clicking anywhere on the background
wallpaper and then clicking on Properties.
Windows
The operating system that runs all your programs and allows you to easily interact with your
PC is called Windows for a good reason. It allows you to work with several different items
and programs at once, all in their own 'window'. A window is like a smaller screen contained
within a box on your main screen.
When you are working with a window it is brought to the 'front' of the screen, overlapping
the Desktop and any other items behind it, so that you can focus on whatever is in the
window.
My Documents
Bank of texts locations
Work in home
My Document
In this way, you can have several windows open at the same time containing different
programs that can be opened, closed, and re-arranged across the screen. This means you can
do multiple tasks at the same time, such as playing your favorite music while writing an e-
mail for example.
Files And Folders
Every item stored on your PC, whether it is a document, picture, song, game or whatever, is
a file. A file can only be activated by programs that understand and are able to use it.
For example, you cannot use a music program to open a letter document. Each program on
your computer understands what type of file it can or cannot use by the fact that every file has
a file type given to it.
120
This takes the form of a few extra letters or numbers added on to its name after a full stop. So
for example, 'myletter.doc' is a file named 'my letter' with the file type '.doc', meaning it will
require a program that understands doc (document) files, such as Microsoft Word.
There are many different file types. Read Common File types for a list of the more common.
Any one single program or application can actually consist of many different files, all
working together to achieve the same task.
This means modern computers can have millions of files spread across different
locations. Folders help organize these files, so that for each particular program there can be
one folder that contains all the files it needs in one place.
A folder can even contain other folders inside it called 'sub-folders'. For example, to
organize your holiday pictures together you might have a folder called 'Holidays 2006' and
then other sub-folders within that for each particular holiday destination, for example 'France
2006'.
You can create your own folders. You can also create shortcuts to make it easier to find
particular files.
You can take a look at an example of a folder now. On your Desktop you should see a
shortcut icon called My Documents. Double-clicking this will open a new window showing
the contents of the My Documents folder.
My Documents
My Documents is a folder on your computer that is automatically created for you, so that you
can store all your own files in one place away from all the program and system folders,
making them easier to find.
Double-click the My Documents shortcut on the Desktop and you will see a list of folders,
within which are your files. To see what is inside a folder, double-click on it and the current
window will change to show the contents.
You may see some other folders which have been automatically created for you to help you
store certain types of files, such as My Music, My Pictures and My Videos. However, you do
not have to use these, and you can store any of your files in any folder you want to. You don't
even have to use My Documents, though it is usually easier if you do.
My Computer
Close any open windows by clicking the X button in the top-right. On your Desktop, double-
click the My Computer shortcut and you will see a list of locations where files are stored on
your PC's disk drives.
If you double-click the Local Disk (your Hard Disk, usually C: ) you can see all the
folders that are stored on your Hard Disk - this will be the part of your PC where all your files
are usually kept, unless you have extra disk drives.
The Program Files and Windows folders here are especially important, and should usually not
be changed as they contain the files necessary for programs and Windows to run.
All files take up 'disk space' and your computer only has so much room to store them all. If
you want to see how much of your Hard Disk you have used up so far, and how much space
you have left, double-click My Computer again and this time, instead of double-clicking
the Local Disk, right-click it and select Properties.
If you find you are running out of disk space, you should try to clean up some unnecessary
files.
If you decide you need a lot more space than you have, it is possible to buy extra Hard
Drives and connect them to your computer.
121
If you right-click the My Computer icon on the Desktop rather than double-clicking it, and
then click on Properties, you can see detailed information about your PC including your
hardware devices and performance settings.
The Control Panel
The Control Panel is a collection of all the important options you will need when you want to
change settings on your computer. You can find control icons for display, sound, Internet,
hardware, programs, security and system settings. To access the Control Panel, click the Start
menu and then click Control Panel.
Changing settings in the Control Panel can make big changes to your PC's setup. For
example, the Appearance and Themes or Display options in the Control Panel can affect the
quality of your screen and the size of text.
4.2 EXECUTION OF LINEAR REGRESSION
Equation of the Line of Regression
Let y = ax + b is the given equation of straight line. The method of least square can be used to fit a
straight line to the set of points given on the scatter diagram. Now, transfer the origin to the points
where and ( are the means of x-series and y-series, respectively.
Suppose that x, y be the deviation from the respective means .
Therefore, x = X – x
y= Y- y
Let Y= a X + b be the equation of the line of best fit of x, changing the origin to (x, y), we get the
form.
y= ax + b
where y = Y –y and x = X – x
Let P be any dot, then the difference between P and the line is
Let I denote the sum of the squares of such distances given by
Now, using the principle of least squares, choose a and b such that I is minimum.
For minima of I, we must have.
and
since, x = 0, y = 0, then we get
122
Therefore, the line of bit is
now, recharging the origin, we get
this is known as regression line of Y on x.
If X is taken to be dependent variable, then the regression line is
This is called the regression line of X on Y.
Least Square Regression
The approach discussed above, is known as least square regression.
Here, if y= a+bx= f(x) is the given equation then, using the principle of least square and principle of
maxima and minima, we may find the normal equations, given by
Solving the above equations for a and b, we get
where x, y are the means of x-series and y-series respectively.
Fitting a polynomial Function
If a given set of data does not appear to satisfy a liner equation, then we try a suitable polynomial as
a regression curve to fit the data. The least squares technique can be used to fit data to a
polynomial.
Let y = f(x) be a polynomial of degree (m -1) such that
Now, since f(x) is a polynomial and contains coefficients find all
the coefficents
Using the principle of maxima and minima of I, we have, from (2)
123
..........................................................................
Which gives the general term
therefore , we have
(by substituting the value of f(x)
Then, we get the following normal equations :
.......................................................................
The above set of normal equation can be written as in matrix form as follows:
CA = B
124
Where
Here, the elements of the matrix C is
j= 1, 2, ...., m
k= 1, 2, ......, m
Similarly
NON – LINEAR REGRESSION
Fitting Transcendental Equations
Since the relationship between the dependent and independent variables is not always linear. The
non-linear relationship between them may exist in the form of transcendental equations.
For example (1), consider the equation for population growth given by
P= P0ekt (1)
where P0 is the initial value of the population P, k is the growth rate and 't' is the time (2) Consider
the equation of gas law relation to the pressure and volume, given by
P = avb
Let I be sum of the square of the deviation, then we have
which gives
125
use iterative technique to solve for a and b.
We get
(i) Regression equation of y on x :
The regression equation of y on x is given by
y = a + bx
where the values of a and b are given by the normal equation
y = na + bx2
⇒ 16 = 8a + 23 b (i)
36 = 23 a + 99 b (ii)
Solving (i) and (ii) for a and b, we get
a= 2.874
b= - 0.0304
Hence, the regression equation of y on x is
y = 2.874 – (0.304) x
(ii) Regression equation of x on y
The regression equation of x on y is given by
x= c + by (i)
When c and b are given by normal equations
n = nc + b y
xy = cy + by2
⇒ 23 = 8c + 16 b (ii)
and 36 = 16c + 68 b (iii)
Now, solving (ii) and (iii) for b and c, we get
c = 3.431
and b= - 0.278
Therefore, the required regression equation of x and y is given by
x = 3.431 – 0.278 y
126
The following statements define a module named REGRESS to perform linear regression:
> start regress; /* begin module */
> xpxi=inv(t(x)*x); /* inverse of X'X */
> beta=xpxi*(t(x)*y); /* parameter estimate */
> yhat=x*beta; /* predicted values */
> resid=y-yhat; /* residuals */
> sse=ssq(resid); /* SSE */
> n=nrow(x); /* sample size */
> dfe=nrow(x)-ncol(x); /* error DF */
> mse=sse/dfe; /* MSE */
> cssy=ssq(y-sum(y)/n); /* corrected total SS */
> rsquare=(cssy-sse)/cssy; /* RSQUARE */
> print,"Regression Results",
> sse dfe mse rsquare;
> stdb=sqrt(vecdiag(xpxi)*mse); /* std of estimates */
> t=beta/stdb; /* parameter t tests */
> prob=1-probf(t#t,1,dfe); /* p-values */
> print,"Parameter Estimates",,
> beta stdb t prob;
> print,y yhat resid;
> finish regress; /* end module */
Submit the module REGRESS for execution as follows:
> reset noprint;
> run regress; /* execute module */
4.3 Creating x-y Plots in Microsoft Excel
To create a plot of one variable against another using Microsoft Excel, take the following
steps:
Step1: Enter your data as two columns of numbers.
Step2: Click on the "charting tool" icon located in the top right hand side of the toolbar (it has
a colored histogram on it).
Step 4: Follow the "chart wizard" instructions that appear as dialog boxes. The first option
selects the chart type, click on 'XY (scatter)" and then click on "Next" to continue.
Step 5: If you want to connect the lines between the points, click on the appropriate option
127
(option 2), otherwise click on the first option which just does a scatter plot of the data. Then
click on 'Next" to continue.
Step 6: The next dialog box allows for input of the data ranges and shows how the plot will
appear. You want to be sure that the option button is clicked to specify that the data series are
in columns. The "Series" tab will confirm that the first column has been assigned to the x-
series and the second column to the y-series. Click 'Next" to continue.
Step 7: The next dialog box allows you to add legends to the plot. You may add a title to be
centered above the plot, a legend on the x-axis, and/or a legend on the y-axis. Click 'Finish"
when done. You can also edit the chart later to include these legends.
Step 8: The plot will show as a chart region on your worksheet. It may be moved for
positioning, and the "handles" or square dots at the corners or sides may be dragged to
change the plot size. Double click on the chart itself or click on the right mouse button to
select objects in the chart to edit.
1. Check your progress:
1. Which panel can affect the quality of your screen and the size of text?
2. Which icon helps us to make histograms?
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
----------------------------------------------------------------
4.4 NUMERICAL INTEGRATION AND DIFFERENTIATION
Numerical Integration with C++
There are actually two ways to integrate function, one is by processing the function as a
string and obtaining the antiderivative and solving the problem using the second fundamental
theorem of calculus. However, this would be tedious. Basically, a Riemann sum is used. The
limit definition of a definite integral is:
128
Basically, the Riemann sum with an infinite amount of subintervals can find the definite
integral. Code consist of two functions (excluding the main function). One function is the
function that had to be integrate then use:-
The other is a function to integrate. Just hard code the antiderivative and solve from there?”
Hard coding the function is for the sake of simplicity. In reality, the end result should allow
the end-user to manually type in a function as a string in the form: “f(x) = x^2″. However,
this would require us to parse the string, and that’s not the topic of this tutorial. Moving on,
here is current C++ code:
#include <iostream>
// taking advantage of some math functions
#include <math.h>
using namespace std;
double xSquared(double x)
{ // power function, can be replaced with x * x return pow(x, 2);}
double integrate(double (*pFunc)(double), double nLowerBound,
double nUpperBound, long nIntervalPer = 500)
{ // this is where we integrate}
int main(int argc, char *argv[])
{ return 0;}
Okay, nothing too difficult. I added the function we’re going to integrate and the function to
integrate. In our integrate function we have several parameters. First, we specify a function
pointer which points to the function we’re going to integrate. The next two parameters are the
lower and upper bounds respectively, and the last parameter is optional and specifies the
number of intervals per every 1 unit interval. More intervals means better accuracy at the
expense of a slower processing time.
Before we fill in our integrate function, we need to understand how we’re going to find the
definite integral. First of all, as previously stated, we will use a Riemann sum with a large
amount of subintervals, but we’re not going to use the right, left, or middle sums, we’re going
to use the trapezoidal rule to further improve our accuracy. Below is a mathematical
representation of what we’re going to do.
Now to our code!
double integrate(double (*pFunc)(double), double nLowerBound,
double nUpperBound, long nIntervalPer = 500)
{
// Get the total number of intervals we'll be using
double nIntervals = abs(nUpperBound - nLowerBound) * nIntervalPer;
// Specify the width of each interval (delta x)
double nIntervalWidth = (nUpperBound - nLowerBound) / nIntervals;
// variable to hold our total sum
129
double nTotalSum = 0;
for(double i = 0, j = nLowerBound; i < nIntervals; i++)
{
// temp variable to hold our next subinterval
double k = j + nIntervalWidth;
// add to sum
N Total Sum += (n Interval Width / 2) * ( pFunc(j) + pFunc(k) );
// set j to the next subinterval
j = k;
}
return n Total Sum;
}
And thats basically it. One thing to mention is the use of n Intervals. We cannot use a fixed
set of intervals because it would result in an inaccurate answer when the gap between our
bounds is large, so thats why we use n Intervals Per to fix this.
Below is a download link to the finished code. I added a little to the main function to display
our final result.
Integration Source Code
Another last thing to mention, is that this will only work with definite and proper integrals.
Improper or indefinite integrals would have to be solved using a different method such as the
first one messaged at the beginning.
Numerical Differentiation
Let y = f(x) be the given function. The process of evaluating the derivatives of a function f(x) with the
help of the given set of value of that function is knows as numerical differentiation. This may be
done by first approximating the function by a suitable approximating formula and then
differentiation it as many times as desired.
If the derivative at a point near the beginning of a set of values given by a table is required then we
use Newton forward formula, and if the same is required at a point the end of the set of given
tabular values, than we use Newton's backward interpolation formula. The central difference
formula (Bessel's and Sterling's) used to calculate value for points near the middle of the set of given
tabular values. If the values of x are not equally spaced, we use Newton's divided difference
interpolation formula or Lagrange's interpolation formula to get the required value of the derivative.
NOTATIONS :
f(x) = f(x + h) – f(x)
f(x + h) = f(x + 2h) – f(x + h)
130
............. ............ ...........
............. ............ ........... and so on
Also f(x + h) = f(x + h) – f(x)
f(x + 2h) = f(x + 2h) – f(x + h)
............. ............ ...........
............. ............ ........... and so on
and f(x) = .................. and so on
Derivative Using Newton's Forward Interpolation Formula
Newton's forward interpolation is given by
y = yo + u yo + y0 + y0 + ........ (1)
where u =
Differentiating equation (1) with respect to u, we get
+ ........... (2)
Now
= .
Therefore
(3)
As x = xo, u = 0, therefore, putting u = 0 in (3), we get
(4)
131
Differentiating equation (3) again w. r. t. x, we get
= (5)
Putting u = 0 in (5), we get
(6)
Similarly
and so on
Derivative Using Backward Difference Formula
Newton's backward interpolation formula is given by
y = yn + u yn + yn + yn + ........ (1)
where u =
Differentiating both sides of equation of equation (1) with respect to x, we get
.........] (2)
At x = xn, u = 0, therefore, putting u = 0 in (2), we get
(3)
Again, differentiating both side of equation (2) again w. r. t. x, we get
At x = xn, u = 0, Therefore, putting u = 0 in (3), we get
(4)
Similarly
132
and so on
Derivative Using Newton's Divided Difference Formula
In this case we apply Newton's divided difference formula for finding the successive differentiation
at the given value of x, Let us consider a function f(x) of degree n, then
y = f(x) = f(xo) + (x - xo) + f(xo) + (x - xo)(x – x1) f(xo) + (x - xo)(x - x1)
(x – x2) f(xo) + (x - xo)(x – x1)........(x – xn-1) f(xo)
Differentiate this equation w. r. t. x as many times as we require and put x = x1 , we get the required
derivatives.
(3) NUMERICAL DIFFERENTIATION -(1) Flowchart (Backward Method)
Start
Input "Enter value of x"
Input "Enter no. of terms", n
c[j] = b(z)
End for j
133
134
Program :
#include <stdio.h>
#include<conio.h>
#include (math.h>
void main ( )
{
float a [20].b[20],c[20],e[20][20]x1,h,y1=0.0, y2=0.0;
int i,n,j,z,k,w;
clrscr( );
printf("\n enter the number of terms");
scanf ("%d", &n);
printf("enter the values of x\n");
for(i=o;i++)
{
printf("x[%d]=", i+1);
scanf("%f", &b[i]);
}
printf("\n Enter The value of x for computing (backward)");
scanf(%f", & x1);
for (i=0; i<n; i++)
{
if (a[i]==x1)
{
z=i;
135
break
}
}
for (j=o; j< n-1; j++)
{
for i=n-1; i>o; i --)
{
b [i] = b[i] – b[i-1];
}
c[j] = b[z];
}
for (i=z; i<n-1; i ++)
c[i] = 0.0;
h=a[1]-a[0];
print ("h%f", h);
for (i=0; i<n-1;i++);
y1+= c[i]/(i+1);
y1=yi/h
printf ("\n\n The value of dy/dx at X=% f" IS: %f", x1, y1);
y2=c[1]+c[2]+(11.0/12.0) *c[3]+5.0/6.0/*c[4];
y2=y2/(h*h);
printf("\n\n The value of d^2y/dx^2at X= %f IS: % f", x1, y2);
getch( );
}
136
NUMERICAL DIFFERENTIATION (FORWARD) METHOD
(1) Flowchart
Start
Delare the variables
Read N
for i= 0 to n
e[0] [i] = a[i]
Print value of y
for i = 0 to n
Read b [i]
e[1] [i] = b[i]
for i= 0 to n
Read x1
Print value of x for computing
is
a[i] ==x1
is
(i+1) % 2
y1 = y1+ c[i]/(i+1]
137
(2) Program
Formula : [
#include <stdio.h>
#include <conio.h>
#include<math.h>
void main( )
{
float a [20] b[20], c[20], e[20] [20], x1,h,y1 =0.0, y2=0.0;
int i, n, j, z, k, w;
clrscr ( ) ;
prinf("\n enter the number of terms");
scanf("=%d", &n);
printf("enter the values to x\n");
for (i=0; i++)
{
pirntf("x[%d]=",i+1);
for (i=0; i<n, i++)
{
printf("y[%d]=", i=1);
scanf ("%f", &b[i]);
e[1][i] = b [i];
z= i, w=n
138
}
print ("Enter the value of x for computing")
scanf("%f", &x1)'
for (i=o; i<n; i++);
{
if (a[i] == x1)
{
z=i;
break;
}
}
w=n;
printf("tabulated values are:");
printf("\nX Y");
printf("\n");
for (j=0; j<n-1; j ++)
{
for (i+0; i<w; i ++)
{
b[i] = b[i +1] –b[i];
e[j+2] [i] = b[i];
}
w--;
c[j] = b[z];
}
139
w = n;
for (i=0; i<n; i++)
{
for (j=o; j<w; j ++)
print ("%f", e [j][i]; if (if(i<<=n-2)
w--;
printf('\n");
}
for(i=n-1-z' o<n-1; i++)
c[i] =0.0; h=a[1]-a[0];
print ("h=%f", h);
for (i=0; i<n-1; i++)
if ((i+1) %2)
y1+ = c[i]/(i+1);
}
y1 =y1/h;
printf ("The values of dy/dx at x=%t IS : %f", x1, y1);
y2 = c[1]-c[2]+(11.0/12.0)*c[3]-[5.0/6.0]*c[4];
y2= y2/(h*4);
printf("\n the value to d^ 2y/dx^2 at x= % IS : f", x1, y2);
getch ( ) ;
}
2. Check your progress:
140
3. In numerical integration the code consist of two function what are they?
4. Which rule is used to improve the accuracy in numerical integration?
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------
4.5 Molecular Dynamics and Monte Carlo
The true picture of a molecular system is far from the static, idealized image provided by
molecular mechanics. The atoms and groups in molecules are in constant motion, and,
especially in the case of biological macromolecules, these movements are concerted
(correlated) and may be essential for biological function. The direct proof of this behavior is
provided by X-ray and NMR experiments. In molecular mechanics, the information is
derived from a single geometry of the molecule. Simulation methods require thousands to
millions of geometries to produce meaningful results. The biological action of molecules
frequently involves large amplitude motions (biochemists often call them ``conformational
transitions'' or ``changes''), resulting in abrupt changes in the geometry of the protein/ligand
molecule as well as rearrangement of solvent molecules. The thermodynamic and energetic
parameters of such systems can only be derived by realistic and explicit simulation, i.e., by
leaving the potential energy minimum and probing the energy surface of the molecular
system. Molecular simulations are a recent addition to molecular modeling systems and are
still in active stages of development. They are also more complex conceptually than
molecular mechanics.
There are essentially two approaches to performing molecular simulations: the stochastic and
the deterministic. The stochastic approach, called Monte Carlo, is based on exploring the
energy surface by randomly probing the geometry of the molecular system (or, in a statistical
mechanics language, its configuration space). It is essentially composed of the following
steps:
1. Specify the initial coordinates of atoms .
2. Generate new coordinates by changing the initial coordinates at random. 3. Compute the transition probability W(0,a). 4. Generate a uniform random number R in the range [0,1]. 5. If W(0,a) < R, then take the old coordinates as the new coordinates and go to step 2. 6. Otherwise accept the new coordinates and go to step 2.
The most popular realization of the Monte Carlo method (though not the only one !) for
molecular systems is the Metropolis method:
141
1. Specify the initial atom coordinates (e.g., from molecular mechanics geometry optimization).
2. Select some atom i randomly and move it by random displacement: , ,
and . 3. Calculate the change of potential energy corresponding to this displacement.
4. If accept the new coordinates and go to step 2.
5. Otherwise, if , select a random number R in the range [0,1] and:
A.
if accept the new coordinates and go to step 2,
B.
if keep the original coordinates and go to step 2.
As a result of a stochastic simulation, the large number of configurations (geometries) are
accumulated and the potential energy function is calculated for each of them. These data are
used to calculate thermodynamic properties of the system. The basic statistical mechanics
formulae will be given later in this section. The Monte Carlo method is accepted more by
physicists than by chemists, probably because MC is not a deterministic method and does not
offer time evolution of the system in a form suitable for viewing. It does not mean however,
that for deriving the thermodynamic properties of systems molecular dynamics is better. In
fact many chemical problems in statistical mechanics are approached more efficiently with
MC, and some (e.g., simulations of polymers chains on a lattice) can only be done efficiently
with MC.
The deterministic approach, called Molecular Dynamics (MD), actually simulates the time
evolution of the molecular system and provides us with the actual trajectory of the system .
The information generated from simulation methods can in principle be used to fully
characterize the thermodynamic state of the system. In practice, the simulations are
interrupted long before there is enough information to derive absolute values of
thermodynamic functions, however the differences between thermodynamic functions
corresponding to different states of the system are usually computed quite reliably.
Based on the potential energy function V, we can find components, , of the force acting
on an atom as:
This force results in an acceleration according to Newton's equation of motion:
142
By knowing acceleration, we can calculate the velocity of an atom in the next time step. From
atom positions, velocities, and accelerations at any moment in time, we can calculate atom
positions and velocities at the next time step. Integrating these infinitesimal steps yields the
trajectory of the system for any desired time range. There are efficient methods for
integrating these elementary steps with Verlet and leapfrog algorithms being the most
commonly used. For the details of these algorithms, interested readers can consult Hermans
(1985) and the references therein.
To start the MD simulation we need an initial set of atom positions (i.e., geometry) and atom
velocities. In practice, the acceptable starting state of the system is achieved by
``equilibration'' and ``heating'' runs prior to the ``production'' run. The initial positions of
atoms are most often accepted from the prior geometry optimization with molecular
mechanics. Formally, such positions correspond to the absolute zero temperature. The
velocities are assigned randomly to each atom from the Maxwell distribution for some low
temperature (say 20 K). The random assignment does not allocate correct velocities and the
system is not at thermodynamic equilibrium . To approach the equilibrium the
``equilibration'' run is performed and the total kinetic energy (or temperature) of the system is
monitored until it is constant. The velocities are then rescaled to correspond to some higher
temperature, i.e., the heating is performed. Then the next equilibration run follows. The
absolute temperature, T, and atom velocities are related through the mean kinetic energy of
the system:
where N denotes the number of atoms in the system, represents the mass of the i-th atom,
and k is the Boltzmann constant. By multiplying all velocities by we
can effectively ``heat'' the system. Heating can also be realized by immersing the system in a
``heat bath'' which stochastically (i.e., randomly) accelerates the atoms of the molecular
system. These cycles are repeated until the desired temperature is achieved and at this point a
``production'' run can commence. In the actual software, the ``heating'' and ``equilibration''
stages can be introduced in a more efficient way by assigning velocities in such a way that
``hot spots'' (i.e., spots in which the neighboring atoms are assigned high velocities) are
avoided.
Molecular dynamics for larger molecules or systems in which solvent molecules are
explicitly taken into account, is a computationally intensive task even for the most powerful
supercomputers, and approximations are frequently made. The most popular is the SHAKE
method which in effect freezes vibrations along covalent bonds. This method is also applied
sometimes to valence angles. The major advantage of this method is not the removal of a
number of degrees of freedom (i.e., independent variables) from the system, but the
elimination of high frequency vibrations corresponding to ``hard'' bond stretching
interactions. In simulations of biological molecules, these modes are usually of least interest,
but their extraction allows us to increase the size of the time step, and in effect achieve a
longer time range for simulations.
143
Figure 6.24: Periodic boundary conditions in molecular dynamics.
In the case of periodic boundary conditions we are actually simulating a crystal comprised of
boxes with ideally correlated atom movements. Longer simulations will be contaminated with
these artificially correlated motions. The maximum length for the simulation, before artifacts
start to show up, can be estimated by considering the speed of sound in water ( 15 Å/ps at
normal conditions). This means that for a cubic cell with a side of 60 Å, simulations longer
than 4ps will incorporate artifacts due to the presence of
images.
Stochastic boundary conditions in molecular dynamics.
144
In the other popular approach, stochastic boundary conditions allow us to reduce the size of
the system by partitioning the system into essentially two portions: reaction zone and
a reservoir region. The reaction zone is that portion of the system which we want to study
and the reservoir region contains the portion which is inert and uninteresting. For example, in
the case of an enzyme, the reaction zone should include the proximity of the active center,
i.e., portions of protein, substrate, and molecules of solvent adjacent to the active center. The
reservoir region is excluded from molecular dynamics calculations and is replaced by random
forces whose mean corresponds to the temperature and pressure in the system. The reaction
zone is then subdivided into a reaction region and a buffer region. The stochastic forces are
only applied to atoms of the buffer region, in other words, the buffer region acts as a ``heat
buffer''. There are several other approximations whose description can be found in the
molecular dynamics monographs quoted here.
Molecular dynamics, contrary to energy minimization in molecular mechanics, is able to
climb over small energy barriers and can drive the system towards a deeper energy minimum.
The use of molecular dynamics allows probing of the potential energy surface for deeper
minima in the vicinity of the starting geometry. It is exploited in a simulated
annealing method, where the molecular system is first heated to an artificially high
temperature and then snapshots of the trajectory at high temperature are taken as a starting
state for cooling runs. The cooled states obtained from hot frames correspond frequently to
much deeper potential energy minima than the original structure taken for dynamics. It is
particularly suitable for imposing geometrical constraints on the system. Such constraints
may be available from experimental results.
3. Check your progress:
5. The stochastic approach is having a reaction zone and is subdivided into which two region?
6. The stochastic approach is called …………………………………………….
7. What are the essentially two approaches to perform molecular simulations?
……………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………
……………………………………………………………………
4.6 MATLAB
MATLAB family of products, the language of technical computing. It helps us to write the useful
programs of technical work as, Physical Chemistry, Physics, Mathematics etc. You need to install the
MATLAB software versions of the software are MATLAB-5 & MATLAB-6. The latest versions of the
software is MATLAB-6. In this section we will deal with the MATLAB-6 version.
145
1. Basic Instructions
Before installing the MATLAB software program on PC we have to follow some instructions as
follows:
Turn off any Anti Virus software.
Exit any programs running, especially existing copies of MATLAB if there.
Make sure that you have the Personal License Password (PLP) received from the Math works
(MATLAB producer) via e-mail when you purchase your software. If you do not have your
PLP, then once more read the "Product Licensing" for more information.
Make sure your system satisfies the requirements of the software you intend to install,
otherwise read the "System Requirements".
To install MATLAB on Microsoft Windows 2000 system, one must have administrator
privileges.
When any person purchases products with in individual license, the Math works sends a
"Personal License Password" [PLP] by e-mail or Fax. The PLP indentifies the products
licensing to install. A PLP is a series of five-digit numbers, prefixed with a two-digit release
code, such as.
12-12345-12345-12345-12345-12345.....
If you did not receive the PLP, it can be obtained during the installation procedure by clicking
on the "Get my PLP" button on the "Personal License Password" dialog box through the
Internet connection and the MATLAB Access number.
2. System Requirements for MATLAB
The most up-to-date information about system requirements for the installment of MATLAB
software on the PC are follows:
Pentium, Pentium Pro, Pentium II, Pentium III, or AMD Athlon processor.
Microsoft Windows 95, Windows 98, (Original and Second Edition), Win'NT 4.0 (with
Service Pack 5 for Y2K Compliancy) or Windows 2000.
CO-ROM drive (For installation).
64 MP RAM (minimum) for Windows 95, 98, NT4.0 and 2000; 128 MB RAM.
Strongly Recommended:
Disk space varies depending on size of partition and installation of online help files.
146
8-bit graphics adapter and display (For 256 simultaneous colors).
One of the following is required to build the important MEX-files (during the programming):
Compaq Visual Fortran 5.0 or 6.1.
Microsoft Visual C/C++ version 5.0 or 6.0.
Borland C/C++ version 5.0, 5.02.
Borland C++ builder version 3.0, 4.0, or 5.0.
LCC 2.4 (bundled with MATLAB).
Adobe Acrobat Reader is required to view and print the MATLAB online
Documentation in PDF format.
MATLAB can also be set up to work on a network via the TCP/IP communications
protocol.
3. Starting MATLAB
There are several way to start MATLAB, we can use any of the following method:
Double-click on the MATLAB icon ("SHORTCUT") created by the installer on the
desktop.
Click on the start button.
Then from the programs menu, click on the MATLAB release 12 entry and select
MATLAB R12 from this menu.
By default, when the user starts MATLAB using a shortcut, the initial current
directory is the "#MATLAB/work" directory, where #MATLAB represents the
installation directory. The user can, use any directory as the MATLAB initial current
directory. To specify another directory as the initial current directory, right-click on
the MATLAB short cut present on desktop and select the properties option. Then
specify the name of the directory in the start in field of the properties Dialog Box.
To include any other change in default definitions, or any MATLAB expressions that
the user want to execute every time MATLAB is invoked, there is create a file named
"startup.m" in the "toolbox/local directory" MATLAB executes this file each time this
software is invoked. For example, to change the default paper size used for printing
to A4,
Include the following line in the "startup.m" file: :
Set (0, 'DefaultFigurePaperType', 'a4')
147
4. MATLAB Directory Structure
After installation, the MATLAB installation directory contains the following directories and
executable files:
A text file, named license.txt, which contains the MATLAB software license
agreement.
A shortcut to the MATLAB executable.
Operators used in MATLAB
In the below table, all the operators used for the MATLAB programming are described, which are
very much similar to other programming languages like C, C++, VB etc.
Operator Function
a + b (+) Addition
a – b (-) Subtraction
a .*b (*) Multiple times
a . / b (/) Divide by (Real)
a. \ b (\) Divide by (Integer)
a / b mrdivide
\ mldivide
a' ctranspose
a .' transpose
a : b : c colon
a<b It (Lesser Than)
a <=b le (Lesser Than or equals to)
a>b gt (Greater Than)
a >=b ge (Greater Than or equals to)
a==b eq (Equals to)
a~=b ne (Not equals to)
a – b or (OR)
148
a & b and (AND)
~a not (NOT)
! cmd System command
( ) Parentheses
[a b ...] Brackets
[a; b...] Brackets
a {b} Braces
{ } Braces
Now we will discuss about some of these operations briefly:
(1) and (Logical AND):
The expression given below:
z=x&y&...&p&q.
returns logical x&y. z will be 1 if and only if x and y are both true (non-zero). Only two argument are
allowed in the and (x, y) form of the command, the arguments may be vectors or arrays. More
arguments can also be used in the following format of and() operator.
z=x&y&...&p&q.
Where the input arguments are vectors or arrays, and return the logical AND of corresponding
elements of the arrays.
(2) braces (Create or index cell arrays):
Assume the expression:
y = {a b ....}
Which creates a cell array y with a, b, .... in its cells. Cell arrays created by this syntax can have up to
two dimensions, i.e.,
y={a b; c d} creates a 2 x 2 cell array
y=a {b},
149
Where a is a cell array, returns the contents of the cell array a in position b. in contrast, a(b) returns
of cell array, whose contents are the variable b.
(3) brackets (Concatenate matrices):
The expression ;
[a b] returns the matrices a and b concatenated horizontally.
a and b must have the some number of rows.
The expression ;
[a ; b] returns the matrices a and b concatenated vertically
a and b must have the same number of columns.
(4) colon (Colon operator):
Consider the following expression:
y = colon (j, i, k), or y = j : i : k.
Which returns a row vector ranging from j to k with i increments. k will not necessarily be the last
element of the vector.
The last element of the sequence (j, j+i, j+2i ...) will be the last element of the vector.
For example: 1 : 4: 13, 1 : 4 : 14, 1 : 4 : 15 and 1 : 4 : 16
where all return the vector [1 5 9 13]
(5) ctranspose (Matrix conjugate transpose):
The given expression ;
y=ctranspose(x)
returns the matrix conjugate transpose, x'.
(6) eq (Equal):
The following expression:
150
z=eq (x, y)
compares x and y, and returns "1" if x ==y, "0" otherwise. If x and y are arrays of the same size,
corresponding elements are compared, and the result is an array of the same size as x and y.
(7) ge (Greater than or equal):
The return of the following expression:
z=(ge(x, y)
is 1 if x> = y and 0 otherwise
(8) gt (Greater than):
This operator compares for "greater than" only.
z=gt(x, y)
and returns 1 if x>y and 0 otherwise.
(9) Individe (Inverse divisions):
This operator returns the result of the element-by-element division of y by x, x. \y.
z=Idivide (x, y)
(10) le (Less than or equal):
This operator compares the two expression x & y for "lesser than or equal to" checking:
z=le(x,y)
(11) lt (Less than):
This operator compares x & y only for "lesser than""
z=lt (x, y)
and returns 1 if x<y and 0 otherwise.
(12) mand (Logical AND):
The "Logical and" operator is named in C++ and Visual Basic programs.
151
(13) minus (Subtraction):
The "minus" operator returns the result of subtracting y from x, x-y.
x-y, where x and y are arrays with the same dimensions, subtracts each element of y from the
corresponding element of x. if y is a scalar, then x-y subtracts y from each element of x.
z=minus(x, y)
(14) mldivide (Matrix inverse division):
This operator returns the result of matrix division of y by x, x\y.
z=mldivide(x, y)
The following expression ;
z=x\y
products the solution z to the matrix equation xz = y. x must have the same number of rows; z will
have the same number of rows as x has columns, and the same number of columns as y.
(15) mnot (Logical NOT):
The "Logical not" is named "mnot" in some programming language like, C++ and Visual Basic.
(16) mor (Logical OR):
The "Logical or" is named "mor" in C++ and Visual Basic programming language.
(17) mpower (Matrix Power):
The following expression using the "mpower()" function returns different results as follows:
z=mpower(x, y)
If x is a square matrix and y is a scalar, than z is x raised to the yth power, xy.
If x is a scalar and y is a matrix, is something else entirely. If both x and y are square matrices, is an
error.
7. Some MATLAB Functions
(1) Indexing (Access submatrices):
152
Consider the following expression ;
y=z(v)
Where this operator returns the elements of x specified by v :
The expression
x(v)=y
sets the elements of x specified by v to be y. If y is an empty matrix, the indexed elements are
deleted from the matrix x. y must either be a scalar or an array of the same size as the submatrix
x(v).
Indexing can be in more than one dimension. For example: x (v, w). In this case, v specifies the rows
and w specifies the columns of the submatrix. Indices may be of three types:
(i) Regular index contains numbers, the indicate into the indexed matrix.
(ii) Logical matrices are arrays of 1's and 0's, resulting from functions that give true false
results, such as <, >, ==, all, any. A logical index acts as a mask on the indexed matrix.
(iii) Indexing with: (colon) is same as selecting the whole dimension.
The end keyword in an indexing expression means the last index in that dimension.
For example:
For A = "1, 2, 3
2 3 4
3 4 5 #,
Then, y=A(:, 3)
returns
y= ( 3, 4, 5 ),
(2) abs (Absolute value):
abs(x) is the function computing absolute value of x, [x].
If x is complex, the return value is computing according to the following expression:
153
abs(x)=qreal(x)2 + imag(x)2.
(3) all (All non zero elements):
This function returns logical 1 if all x element along a dimension are non-zero, and logical 0
otherwise.
y=all(x)
4. Check your progress:
8. What is PLP?
9. Which is the latest versions of the softwares in MATLAB?
……………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………
……………………………………………………………………
4.7 FoxPro
FoxPro is the most extensively used data base management package, i.e. DBMS. Before
understanding DBMS and its functioning, we have to understand some related terms as data,
information, database, etc. The database is organized collection of records. The database can be
referred to as the table of records sometimes. The record is the collection of many fields to
represent the meaningful information. The data are the raw fact used to create the meaningful and
readable information. We can say that the discrete facts are called data, such as, name, address,
city, number etc. When the data are collected to make it meaningful, it is called information. The
term database has been defined by different persons in different ways. A generalized simple
definition of the database can be given as follows:
"The database is an organized collection of related information together to arrange them in
tabular manner".
The database is useful because of following purposes:
(i) It can manage the records in desired manner.
(ii) The desired information can be retrieved at any time.
(iii) It is helpful for taking meaningful decisions during data process.
(iv) The information stored can be recognized according to the requirement.
(v) The data stored is processed in an efficient manner.
154
FoxPro on starting displays the FoxPro window.
The FoxPro window consists of three parts-the highlighted menu bar, the output display screen and
the command window. At the start time, FoxPro displays a FoxPro sign-on Message" on the display
screen. This massage disappears from the screen when user starts further working. The highlighted
bar on the top of FoxPro screen is called as the menu bar containing various words on itself. Every
word on the menu bar is called as menu pad. Each menu pad on activation displays a droop down
menu list, which contains various menu options for different working of the database processing
such as, Save, open.... etc. There is present a small window in the lower right corner of FoxPro
screen, called command window. This window is used for entering the FoxPro commands required
during various database operations.
The menu pads can be activated by mouse or by using the following key combination.
<ALT> Key + Highlighted Character
Every menu pad has a single highlighted character which is helpful to open the dropdown menu list
for that menu pad. The selection of menu pad is deactivated by using <Esc> key (Escape Key). As we
have already read, the dropdown menu list contains menu options for various database operations.
Creating a database file involves designing and defining structure in memory to store the specified
records.
CREATE <databasefilename>
FoxPro supports following data (field type) to store various kinds of data in the database:
(i) Character Data Type
The Character data type is used to store the alphanumeric character as data values in the database
fields. This data type validate a field to store alphabets, numeric digits, symbols, etc. as the field
value. This type provides on width for one character
(ii) Numeric Data Type
The numeric data type is used to store the numeric digits only. Its data value is usable by
mathematical calculations. The numeric data values can be stored with or without decimal values.
Thus, we can say that numeric data type is useful to store both integer data values as well as real
data values.
. (iii) Date date type
This data type is used to store the date value for a field. Its default size '8' bytes and can not be
changed by user. It allows the storage of date in the default manner as 'mm/dd/yy'. This manner can
be changed by the user as per requirements by the date format commands supported by FoxPro.
155
(iv) Logical Data Type
Logical data type is used to store logical data values in field i.e. True/False. It allows 1 byte size for its
value which can not be changed. It allows to store .T. for true value and .F. for false value.
(v) Memo Data Type
Memo data type is used to define a field which can store long textual information. It provides the
facility to store the text larger than that of character data type, i.e. more than 254 characters. The
memo data type occupies only 10 bytes to store any amount of data and this width can not be
changed by the user.
(vi) General Data Type
This data type is used only with 'FoxPro for Windows". It allows to store graphical objects with in the
database file, such as picture, sound file movie file etc.
After defining the structure of data base file, FoxPro asks the user regarding the input of records in
the database. The dialog box with following message is displayed.
This dialog box has two button to choose as "Yes" and "No". We can select any one of these buttons
by using "<tab>" key and then pressing "<Enter>" key. If we select "No" button, the cursor moves to
the command windows and waits for next command to instruct by the user. If we select "Yes"
button, FoxPro displays the Blank Record Entry from for entering the record values.
FoxPro displays the name of each field in the separate row on the record entry form. Each field
name is displayed on the left side of Record Entry form by the blank space box entering the data.
The blank box has different widths for different fields depending on the field with specified during
the database structure definition. We can enter the data value for various fields in the blank boxes
provided for them appropriately. At the first time, the Record Entry form displays only one blank
record. When the user starts filling up the first record, FoxPro displays blank record the first record
separated by a separator line.
When user enter data cursor moves to the field box automatically or use <tab> key or <Enter> key.
The movement is signed by beep sound. <Esc> key (Escape> key is used to close the record entry
form without saving. If we want to save the records, then key combination of "<Ctrl>+W" is used to
"Save and Exit". We can enter as may as records in can add more records in the database. Then the
record entry form is closed by the user. Furthermore, in future we can add more records in the
database using "Append" command.
The database files after working should be closed. It is needed for the safety of database records.
After completion of work with the database files, the database needs to be closed. Although the new
file when opened will automatically replace the previously opened file, but, in this case all the
opened database files remain in memory in deactivate form and occupy the space in main memory.
156
This will decrease the system performance. So all these files are to be closed using following
command in the command window.
CLOSE DATABASE
By using this command, all the opened database are closed from the memory. Then we can open the
required one and do the database operations with increased performance.
A database file is allowed to work when it is created and not closed. But the database file are closed
and may be needed for use at any time in future. So, the file needs to be opened when required.
FoxPro provides "USE" command to open/activate a database file. Opening a file means, loading it in
main memory from the secondary storage media. Activating a file means, enabling a previously file
to work (which is deactivated/closed till now).The following is the syntax of "USE" command :
USE<filename>
This command requires that the given file name must be of an existing database file, otherwise an
error message is encountered. This command does not require the file name with extension. The
filename may or may not be given with extension name (.dbf) because it is the default extension
name for FoxPro database files. We can open many files in FoxPro and reuse them as per
requirements. The file remains is the memory until it is closed by using "CLOSE DATABASE"
command and so it can be reused again and again.
4.8 MS-Word
The word Processing means typing, editing and formatting the document such as letters, faxes,
memorandum, balance sheets, etc. In general, word processing refers to the processing of words,
i.e., the simple text. These textual data can be used to generate bills, print letters, booklets, books
advertisements, reports etc. A word processing is such a software package that allows the user to
create and edit the documents. Creating the document involves typing text in the internal memory
of the computer and saving it on to the disk. Editing a document involves correction of spelling
mistakes and deleting or removing words, sentences or paragraphs, i.e., arranging text at
appropriate place in the document. Some examples of Word processor are word perfect, Word star,
MS-Word, etc.
A word processor allows us to perform following tasks :
(1) Type a document through the keyboard and save it on disk.
(2) Correct, delete and insert characters, words, lines anywhere in the document.
(3) Retrieve documents from the disk as and when required.
(4) Move or copy paragraph, etc, from one place to another place in the same document or any
other document.
157
(5) Decrease or increase the left, right, top or bottom margins of document according to the
requirement.
(6) Change the text font and style or can say display appearance.
(7) Search for a particular word or phrase in the document.
(8) Search for errors (Spellings and grammar) in document and make corrections to them.
(9) Print a document in required formats on paper.
(10) Print the document using mail merge, a special feature of word processing package which
allows to do a large work in less time.
STARTING MS-WORD
Microsoft office MS-Word is present under the group Microsoft Office of Windows. To invoke MS-
Word in Windows 98, select "Start" option from Task bar and open "Program" Menu, then click on
Microsoft office option. The word Document window has the following basic components :
(1) Title Bar : I displays the name of the program, name of the currently active word document,
control, the minimize button and also close button. The maximize button in maximized
window turns to Restore button. It converts window size to actual size again and turns to the
maximize button.
(2) Menu Bar : It is Placed below the title bar. It contains different option like file, edit view, etc.
known as menu bar Item to perform different works. Each of these Menu bar Item has a
Drop Down Menu.
A Drop Down Menu comprises of a list of various menu options which drops down when you
click on any Menu bar item. Every Menu option has an associated task, such as file open,
save, etc.
(3) Tool Bar : It helps the user to perform tasks faster and easier. Two of the most tool bar
provides the short cut for menu commands while the Formatting Tool Bar contains the tool
related to formatting of the text in the document. When the user several other toolbars are
displayed just below the Menu bar. There are several other toolbars available within MS-
Word and we can open them as required. Some of them are the Drawing Tool Bar, Table
Tool Bar, etc.
(4) Ruler Bar : It allows the user to set the vertical alignment of the text and also the setting of
page margins. There are two Ruler bars founds as Horizontal and Vertical Ruler Bar.
(5) Status Bar: It displays information about the active task on which user is currently working.
This includes page numbers, line number etc on which the cursor is currently placed. The
158
status bar is placed at the bottom of document window. In brief, it displays the status of the
current document.
(6) Scroll Bars : It helps the user to scroll the contents of a document. Word document window
consists of two scroll bars. They are Vertical Scroll Bar and Horizontal Scroll Bar. The
Horizontal scroll bar is used to move the document horizontally, left and right. The Vertical
Scroll Bar is used to move a document vertically and it has four buttons. The single arrow
buttons allow the user to scroll up or down in the document on line at a time. The double
arrow buttons allow the user to scroll by one page at a time.
EDITING TEXT
Editing the text involves rearrangement of text in the document by cut, copy, move or overwriting
the text. Various menu options, toolbar options, shortcut menu options and shortcut keys are used
for these works. The shortcut menu appears on the Word-window by right click of mouse.
Cut :
Delete key
edit → Cut
Standard tool bar → Cut
Short Cut Menu → Cut
Ctrl + X (Shortcut Key)
Paste
Edit → Past
Standard tool bar → Paste
Short Cut menu → Paste
Ctrl + V (Shortcut key)
Copy :
Edit → Copy
Standard tool Bar → Copy
Sort Cut Menu → Copy
Ctrl + C (Shortcut key)
Inserting text : New text can be inserted any where in document. Overwriting of text is possible by
pressing insert key.
MOVING THROUGH THE TEXT
Ctrl + → = Move cursor to next word.
159
Ctrl + ← = Move cursor to previous word.
Ctrl + Home = Move cursor to start of document
Ctrl + End = Move cursor to end of the document
Home key = Move cursor to beginning of the line
End key = Move cursor to the end of the line.
CONVERTING CASE OF TEXT
Steps to convert the case of the selected text are :
Select change case option from format menu.
The change case dialog box is displayed
Select the desired option from the dialog box.
Click on OK button.
The options in the dialog box are as follows.
Option Function
Sentence case Capitalizes only the first letter of each sentence.
Lower case Converts all selected text to lower case
Upper case Converts all selected text to upper case.
Title case Capitalize the first letter of each word
Toggle case Converts upper case to lower case and lower to upper case.
FORMATTING TEXT
Formatting a document includes assigning fonts and font size, aligning text, adjusting the line
spacing, paragraph spacing and setting up the page margins as top margin, bottom margin, left
margin and right margin.
CHANGING FONT
Font refers to the manner or style in which the text is displayed on screen in the document. Different
fonts contain different collection of Characters and symbols. The steps to change the font style are:
Select the text whose fonts has to be changed.
Click on Format option in Menu Bar.
Select Font.... option from drop down Menu.
The Font dialog box is displayed. Select desired font by clicking from the font manes listed in
font Box.
160
Select required font size from the font size box.
Several effects can be applied to the text such as Bold, Italics, Underline, etc. and click or OK
to apply the format.
Alternatively, you can do these works form the formatting Tool Bar by using Font Name Box,
Font Size Box, and Font style buttons.
ALIGNING THE TEXT
Alignment is the placing of the text on paper with reference to left and right margin of the paper.
Four types of alignments can be applied to the text.
Left alignment : Text is aligned with reference to the left margin in the document.
Right alignment : Text is placed towards the right margin of page.
Centre alignment : The text is aligned to an imaginary central line on the document.
Justified alignment : The text is aligned along the right and left both margins.
FORMATTING PARAGRAPH
To format a paragraph, first of all you need to select the paragraph or text required. Select
Paragraph...option from Format Menu. The Paragraph dialog box provides you the independent
control over spacing, indents, etc. Indents and spacing options control the indentation form left and
right margins, line spacing and indent level of first line of the paragraph. Spacing before and after
paragraph can be specified using the appropriate option. The alignment setting can also be done by
using Alignment list box.
USING HEADING STYLES
Word provides a number of built in styles that can be applied to document text or headings. Styles
can be accessed from the style box present at the left edge of formatting Tool Bar. Mostly large
document require many different types of headings. The Heading styles provided by MS-Word of
different types and specific for various levels used to subordinate the different text of document.
These levels are typically used in large documents where different heading levels are used to
subordinate the information. Under different headings and subheadings. MS-Word accommodates
this need by providing the heading styles as Heading1, Heading2, etc.
CREATING BULLETS AND NUMBERED LIST
You can use bullets and numbers to make the list attractive and easy to read in your document. The
steps used to apply the Bullets and Numbering to a list are:
Select the list in the document.
Select Bullets and Numbering .... option from format Menu.
Bullets and Numbering dialog box is displayed.
Select required tag-Bullet, Numbered, outline numbered.
161
Each tag has some associated styles.
Select a bullet or numbers style of your choice, and click on OK.
If you want to modify the bullet or number style, click on the Customize button.
The Customize bulleted list dialog box is displayed. Change the font style, position of bullet,
etc.
SETTING TAB STOPS
Tabs are used to move the cursor at pre-specified gaps. Working with Tabs is a two part process-the
first step involves setting of tab stops at different distances in the document, and the second step is
to use these tabs when the document is typed. MS-Word offers five types of tab stops-left, right,
centre, decimal and bar. Tab key is used to move the cursor to the next Tab stop. The default tab
stop position is 0.5 inch. The steps to set the tab stops are :
Select the Tabs ... option from format menu.
The tab dialog box is displayed.
The following are the tab alignments provided:
Left
Right
Centre ⊥
Decimal ⊥.
Selected tab Alignment you want. The default alignment is left.
Types the required distance in inch in the Tab stop position text box (as2.5")
Select the tab leader style you want, 1 for no leader, 2 for dotted leader (........), 3 for a
dashed leader (-------), 4 for an underlined (___________) from the leader group. A tap
leader is a row of dots or dashes that is inserted between the two text alignment of the two
tab stops.
Click on set button to set the Tab stop.
We can set as many as many as tab stops.
Then click OK.
To clear the tab setting, select that tab stop from the list and then click on clear button.
HEADERS AND FOOTERS
Headers and footers are some special text that needs to be displayed on each page of a document,
such as page Number, chapter name, etc. Headers get displayed at the top while footers at the
bottom of a document. You can have either identical or different Headers and footers. The steps to
enter a Header/Footer are :
162
Select the Header and Footer option from view Menu.
The Header and footer toolbar is displayed.
Type, or edit the text in Header Text Box displayed at the top of the document.
If you want only header text on the document, click on close button.
If you want the footer text also, click on the "Switch between Header and footer" button of
this tool bar and click on the close button after typing the footer text.
Header and footer toolbar also provides buttons for inserting page no. date and time, etc. in
the document.
Header and footer can only be seen in the page layout view of the document.
These Header and footers are displayed as dim in the document as compared to other text of the
document, but on printing, it will look same as that of entire document. The Header and footer can
be edited only by Header or footer Text Area.
FOOTNOTES
Footnotes and Endnotes are the special notes providing the information of any word or sentence,
etc. used in the document. These notes are helpful to understand the document, such as project
report, journals, scientific research papers, thesis, etc. The steps to insert a footnote in a document
are:
Select Footnote ......option from Insert Menu of Menu bar.
The Footnote and Endnote dialog box will be displayed.
Select Footnote or Endnote option as required.
Footnote : Displayed at the bottom of the page.
Endnote : Displayed at the end of the document.
Select Auto numbering for numbering the words or select custom mark to assign a special
mark for the word.
TYPING IN COLUMNS
In the document like magazines, newspaper articles you have been the text typed in the columns.
These columns are made by breading the page into vertical section breaks called Columns. To type
the document in columns, the columns are created by using the following steps. :
Select format option from menu bar.
Select Column... option from the drop down menu.
Select any column design from the presets of columns dialog box.
The Number of columns can be changed.
The width and spacing between columns is also allowed to change.
163
We can put vertical line between two columns by clicking the checkbox for option "Line
between."
Click on OK button.
To move the cursor from one column to the other column, the steps are:
Select Insert option from menu bar.
Select Break ... option from drop down menu.
The Break dialog box will be displayed.
Select column break from the dialog box.
Click on OK button.
To Create two or three or more column style on a page, the steps are:
Select Insert option from menu bar.
Select Break .. option from drop down.
The, select page break option from the break dialog box.
Select continuous from the section break.
Click on OK button.
This method will break a page into two or more sections and each section is independent like pages.
Then we can apply different column setups to different sections of the same page.
INSERTING SECTION BREAKS
Section breaks divide a document into sections, i.e., part of the same page but behaves differently.
The break appear as double dotted lines containing the word "end of section" in normal view. The
steps to insert a section break in the document are:
Position the cursor at the location where you want to insert a break.
Select the break option from the Insert Menu. The Break dialog box is displayed.
Select one of the following options from the section break area. :
Next page Radio Button to insert a section break and begin the new section at the top of
the next page.
Continuous radio button to inset a section break and begin the new section from next
line on the same page.
Even Page Radio Button to insert a section break and being a new section on an even
numbered page present next to current page.
Odd page Radio button in inset a section break and begin the new section on next odd
numbered page.
Click on OK button to close Break dialog Box.
To delete a section break, selection the section break and press del Key.
164
BOOK MARKS
Bookmarks are used to identify the beginning of a chapter or tables or paragraph or the place in the
document where you left off.
(i) The steps to inset a bookmark are as follows:
Position the cursor at the location where you want to create a bookmark.
Section the Bookmark.... option from the edit menu.
Type a name for the bookmark in the text box. [Bookmarks names can contain upto 40
characters]
Then click on add button. We can insert as many as bookmarks in a document.
Click on close button.
(ii) The steps to search for a predefined bookmark are :
Select the Go To... option from edit menu. The find and replace dialog box is displayed.
Select the bookmark option from the "Go to what" scroll list.
Select the name of the bookmark from the 'Bookmark name" drop down list.
Click on go to button. The cursor moves to the place where specified bookmark has been
placed.
Then click on close button.
Spelling mistakes can be corrected by Spell Check Utility. To check the spellings in a document, the
steps are:
Select Tools option from Menu bar.
Select Spelling and Grammar.... option from drop down Menu. Alternatively, we can press
F7 key to start spell check utility.
MS-Word provides facility to make tables in the document. Click on Table option from menu bar.
Click on Insert Table ..... option from droop down Menu.
The Insert table dialog box is displayed.
Specify the number of rows and columns required to be inserted.
5. Check your progress:
10. What is database?
11. What is the default tab stop position in inches?
165
12. What are the examples of word processor?
……………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………
4.9 LETS SUM UP
The computer is becoming an integral part of the chemical industry with reference to the software
as well as hardware. There are actually two ways to integrate function, one is by processing the
function as a string and obtaining the anti-derivative and solving the problem using the second
fundamental theorem of calculus.
The process of evaluating the derivatives of a function f(x) with the help of the given set of value of
that function is knows as numerical differentiation. This may be done by first approximating the
function by a suitable approximating formula and then differentiation it as many times as desired.
Molecular simulations are a recent addition to molecular modeling systems and are still in active
stages of development. They are also more complex conceptually than molecular mechanics. There
are essentially two approaches to performing molecular simulations: the stochastic and the
deterministic. The stochastic approach, called Monte Carlo, is based on exploring the energy surface
by randomly probing the geometry of the molecular system
FoxPro is the most extensively used data base management package, i.e. DBMS. Before
understanding DBMS and its functioning, it is necessary to understand some related terms as data,
information, database, etc. The database is organized collection of records. The database can be
referred to as the table of records sometimes. The record is the collection of many fields to
represent the meaningful information. The data are the raw fact used to create the meaningful and
readable information.
MATLAB family of products, the language of technical computing. It helps us to write the useful
programs of technical work as, Physical Chemistry, Physics, Mathematics etc. You need to install the
MATLAB software versions of the software are MATLAB-5 & MATLAB-6. The latest versions of the
software is MATLAB-6. In this section we will deal with the MATLAB-6 version.
166
The word Processing MS.-Word means typing, editing and formatting the document such as letters,
faxes, memorandum, balance sheets, etc. In general, word processing refers to the processing of
words, i.e., the simple text.
4.10 Check your progress: The key
1. The control panel can affect the quality of your screen and the size of text.
2. Charting tool.
3. One function is the function that had to be integrate then use:-
The other is a function to integrate.
4. The trapezoidal rule is used to improve the accuracy in numerical integration.
5. The stochastic approach is having a reaction zone which is then subdivided into a reaction
region and a buffer region.
6. The stochastic approach is called Monte Carlo.
7. There are essentially two approaches to perform molecular simulations: the stochastic and the
deterministic approach.
8. PLP is "Personal License Password". The PLP indentifies the products licensing to install. A PLP is
a series of five-digit numbers, prefixed with a two-digit release code
9. The latest versions of the MATLAB softwares is MATLAB-6.
10. The database is an organized collection of related information together to arrange them in
tabular manner.
11. The default tab stop position is 0.5 inch
12. Examples of word processor are word perfect, word star, MS-Word.
167