Computer Basics

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 403

C.O.P.A. Trade of I.T.

I RD S

COMPUTER BASICS

 Introduction :-

Computers are now affecting every sphere of human activity and being about many
changes in Industry, Government, Education, Medicine, Law, and Social Science even in arts
like music and painting.

It has many application:-

1) Design buildings, bridges and machine.

2) Control space vehicles.

3) Aid in preparing country perspective plan.

4) Play games like chess and video game.

In fact any task can be done by using computer so it is essential to know about computer.

What is Computer?

Computer is an electronic device, which takes input in


required form. Where Input is unprocessed facts. Process
is command given to computer, Output is result given by
computer.

INPUT PROCESS OUTPUT

“Computer is a term which is derived from word


compute. To compute means to count or to calculate. Computer is a device which is used for
complex calculation and now days it can be a multipurpose device. "

Characteristic of Computer :-

1) Accuracy :-

Fundamentals of Computer Operating and Programming 1


C.O.P.A. Trade of I.T.I RD S

Computer work with very high accuracy. It gives very accurate results
provided that information given to computer should be very correct. This principle of
working of compute is called as GIGO (Garbage in Garbage Out.).

2) Speed :-
Computer works with very high speed. Speed of computer depends on speeds
on speed of microprocessor fixed in CPU (Central –Processing Unit.). The basic unit
used to measure speed of computer is Hz (Hertz).

3) Versatility :-
Computer is a versatile device. It can be adopted or used in any field like
education , banking , railway reservation , entertainment. Its principle of working is
same in any field.i.e.

a) It takes input from user.

b) Process on given data.

c) Gives output in required form.

4) Deligency:-

Computer is a tired less device which works without any problem 24 hrs.in a
day.

5) Automation:-

Computer works automatically without any supervision.

6) Storage:-

Computer can store large amount of data in its memory.

 History and Generation of Computer :-


First computer developed for calculation purpose in Abacus then in 17th century by
Napier Bone are used.

General purpose electronic computers using valves were developed in 1940. In 1823
Charles Babbage an English mathematician designed for automatic computing machine for
automatic computing of mathematical tables. That machine is called as Differential Engine.
First Computer developed is known as ENIAC ( Electronic Numeric Integrator and
Calculator).

Fundamentals of Computer Operating and Programming 2


C.O.P.A. Trade of I.T.I RD S

 Generation of Computer :-
The rapid growth and availability of improved electronic component have resulted in
making computer smaller and enhanced their reliability and reduced their cost . High speed,
large memory are special features in evolution of computer.

1) 1st Generation :-
The 1st electronic computer was completed in 1946 by a team lead by Prof.Eckert
and Prof.Mauchly at university of Pennsylvania in U.S.A. This computer is called as
ENIC ( Electronic Numeric Integrator and Calculator.) It uses high speed vacuum tubes.
It has small memory. It took about 200 microsecond to add two digits and 2800
microsecond to multiply. A idea to store machine instruction in memory of computer
along with data was introduced by John Von Neumann in 1946.

The first computer using this principle was introduced a Cambridge


university called as EDSAC ( Electronic Delay Storage Automatic Calculator.). In 1951
UNIVAC I built by Univac Division of Remington Rand and delivered in 1951. It also
uses vacuum tubes . They has limited life.

During 1st generation computer programming was mainly done in machine language.

2) 2nd Generation :- ( 1955-1965)


A big revolution in electronic took place with invention of transistor
in 1946. Transistors are made up of germanium semiconductor material were highly
reliable compared to tube. They occupy less space so size of computer become less and
speed of computer gets increased. In this generation magnetic cores are invented for
storage. Memory capacity in second generation is about 100 KB. Magnetic disk are also
invented. The highly reliability of computer led to development of high level language .
Fortran, Cobol, Algol, SNOBOL were developed during this generation. New profession
in computing such as System Analysis and Programmers emerged during second
generation.

2) 3rd Generation :- (1965-1975)


It began in 1965 with germanium transistors being replaced silicon transistor i.e. IC
( Integrated Circuits) consisting of transistors and capacitors growing on single chip of
silicon eliminating wired interconnection. From small scale integrated circuits technology
developed to medium scale integrated circuit. This increases speed of CPU which carry
out 1 million instruction per second. The size of main memory reached to 4 MB. Magnetic
disk technology improved rapidly and storage capacity become feasible. Many important
online system storage capacity become feasible. Many important online system become
feasible. High level languages become improved e.g. Fortran IV, COBOL 68, PL/1.

Fundamentals of Computer Operating and Programming 3


C.O.P.A. Trade of I.T.I RD S

th
3) 4 Generation :-
Medium scale integration circuits developed to large scale integration and
very large scale integration. Magnetic core memories are replaced by semiconductor
memories. Floppy disk provide a low cost, high capacity backup. Network of computer
and distributed computer system have been developed. A significant development in
software is development of concurrent programming language. There is development of
time shared interactive system. The effective cost of computing has become down. e.g.
Intel 8080, Intel 8088, Intel 80286, Pentium I, II, III.

th
4) 5 Generation :-
It is estimated from 1990. It is now possible to go specialized VLSI chips at
low cost. Thus an architecture in technology and allows an easier and more natural
algorithm. Functional languages are developed . In this generation there is development of
artificial intelligence. Cost of computer become very less . Speed , Storage , Capacity
become very high.

 Types of Computer :-
Computer are classified on the base of CPU speed work length directly
addressable memory capacity. Computer are classified in following four types.

1) Micro Computer :-
Consist of microprocessor chip as CPU. It uses RAM, ROM for storing
program, data, floppy disk, and hard disk for permanent storage. Early microprocessor has
word length of 8 bit . But now it is 16,32,64 bits. Only one person can use it. It has limited
capacity of input and output. They have wide range of application. They are used as parts
of instrument, controller of plant and robots and as general purpose computer. They are
used as personal computer and as home computer e.g. Desktop, Notebook, Personal
Digital Assistant.

2) Mini Computers :-
Minicomputers are faster than microcomputer. The speed of CPU is more than
1 million instruction per second. They are emerged in 1960. They are also called as
midrange computer. e.g. IBM system / 36 IBM system / 38 IBM AS400. They are
generally used at medium scale industries.

Fundamentals of Computer Operating and Programming 4


C.O.P.A. Trade of I.T.I RD S

3) Mainframe Computers :-
They are also called as Host Computers. They have more processing
speed than micro and mini computers. They are also called as Midi computers. They are
also called as Midi computers. The minimum processing speed is 10 million instruction
per second. They support large compilation intensive scientific and engineering problem
and large scale commercial problem. They are capable of greed data storage. They are
used in company like LIC, Banks etc. e.g. IBM 4300, IBM 4340, NEC ACOS mainframe.
It is designed to support hundred and thousand of user. They have wide range of software
and peripherals.

4) Super Computers :-
It is most powerful type of computer. They are used by very large scale
industries such as NASA.e.g. It performs numeric calculator for weather prediction,
compiled molecular structural calculation. They need additional mainframe computer to
prepare jobs and present them in right order. The above are types of computer according
to processing speed and capacity of computer .

According to purpose of computer they are of three types.

1) Analog Computer :-
These computers are used for measuring purpose. e.g. Voltmeter used to
measure voltage. Thermometer used to measure temperature. They do not perform any
calculation but gives number result.

2) Digital Computer :-
Theses are used for counting or accounting purpose. It always convey all input
in machine language or i.e. in 0 and 1. There fore these computers are called as Digital
Computer.e.g. Microcomputers, Personal Computers etc.

3) Hybrid Computer :-
Hybrid computer are the computer which perform bot task i.e. measuring and
counting or computing. They are mixture of analog and digital computers.

FUNCTIONAL PARTS OF COMPUTER

Fundamentals of Computer Operating and Programming 5


C.O.P.A. Trade of I.T.I RD S

 Organization of Computer :-
Typical computer is basically made up of four main units

1) Input Unit

2) Output Unit.

3) Process Unit.

4) Storage.

MEMORY

CONTROL
UNIT
INPUT OUTPUT
ALU

1) Input Unit :-
To accept information /data from user Input unit . The device used to accept
data from used are called as input device. The main function of input device is to represent
user understandable data in machine understandable format. e.g. Keyboard, mouse,
scanner.

2) Output Unit : -
This unit is used to produce information or result. The main function of output device is to
represent result in machine understandable form into user understandable form. e.g.
Monitor

.3) CPU :-

Fundamentals of Computer Operating and Programming 6


C.O.P.A. Trade of I.T.I RD S

CPU stands for Central Processing Unit. It is heart of Computer. Each and Every
process is performed in CPU.

a) It performs Arithmetic Operation i.e. Addition ,Subtraction, Multiply and Divide.


b) It also performs Logical Operation i.e. Comparison where result is either true false.
c) It controls Input output operation.
d) It controls internal data movements.
e) Data manipulation.

There are three main parts of CPU

Fundamentals of Computer Operating and Programming 7


C.O.P.A. Trade of I.T.I RD S

I. Arithmetic and Logic Unit :-


This unit performs actual arithmetic and logical operation. It perform all
addition, subtraction , multiplication, division and comparison operation like
<,>,=,<=>,=,<> etc.

II. Control Unit :-


It coordinates operation of hardware. It also coordinate the flow and execution of data
and instruction that are fed into memory. It fetches reads instruction and data from memory
unit decode them and sent them to ALU. The output from ALU is fetched by control unit
and send to various output devices and memory.

III. Memory Unit :-


Memory unit store data, instruction and result. Data and instruction are passed
to ALU. The Control Unit and internal storage are linked together by a set of parallel
electrical conduction lines a called as Buses. They carries data and address. The frequency
with which the pro9cessor execute instruction is called as clock speed. The frequency or
speed of computer is measured in Hz. or megahertz i.e.(MHz).

 Application of Computer :-
1) To store large data.
2) For entertainment purpose.
3) For communication purpose.
4) To generate graphics and images e.g. cartoons.
5) In any field like Banking , LIC, Railway reservation or in any business.

 Limitation of Computer :-
1) Can not think their own.
2) Do not learn from experience.
3) It has not ability to understand.
4) It can not handle combinatorial explosion.

Anatomy of Computer System :-


A computer system is made up of three major components.

1) Computer Hardware :-
It includes all physical parts of computer which can be seen or touch. e.g. Keyboard,
Mouse, CPU.

Fundamentals of Computer Operating and Programming 8


C.O.P.A. Trade of I.T.I RD S

2) Computer Software :-
Computer programs that instruct computer how to process data and generate
required information is called as computer software.

3) Computer Personnel :-
They are also called as user . They are the people who prepare data for computerized
input and write computer programs or handles computer programs.

COMPUTER PERIPHERALS
Computer peripheral means input output devices that form essential link
between user and computer system.

 Input Devices :-
Input devices are used to get raw data into the computer.

1) Keyboard :-

This input resembles typewriters. It is used to enter text data into the
computer. There are three type of keys on general keyboard.

a) Alphanumeric keys.
b) Special Keys.
c) Functional Keys.

The alphanumeric keys comprises of alpha bates i.e. (A-Z or a-z) and (0-9) and
also contain some special keys i.e. <,>,?,*,#,:,”,| etc.

The special keys perform specific task e.g. Enter Key, Backspace Key, Delete
key, Caps lock etc.

Fundamentals of Computer Operating and Programming 9


C.O.P.A. Trade of I.T.I RD S

The shift key alter the meaning of character key which is depressed at
same time. The Ctrl and Alt key generate some function with some other key. The Esc
key is used to escape the function . The function keys are used to perform a set of
operations by a key stroke .i.e. F1 is used to display window help.

2 Mouse :-
One of the most popular type or specialized input device is mouse. It is used as
pointing device. It enables the user to manipulate a pointer or arrow on a terminal or
microprocessor. It help in pointing icon or tiny picture. It can place cursor or point an
item.

It draw line picture on screen. Since the cursor follows the way the user
hand movers the mouse, the cursor has a sense of pointing something on screen. The mouse
can be of three type.

1) Mechanical Mouse :-
It has rotating ball on the bottom and is attached with a Corel to the system. As
we move the mouse the roller rotates and control the pointer on screen
.
2) Optical Mouse :-

It has no moving parts. It emits and senses light to detect mouse movement. It
can be used on any surface. It does not require periodic cleaning.

3) Cordless or Wire less Mouse :-


It is a battery powered device. It typically uses radio waves or infrared light
waves to communicate with system unit.
Like Mouse Roller Ball, Track Ball and touch surface are the pointing devices like
mouse. Touch Screen is with laptops.

4) Joystick :-
It is a most popular device for computer games. They are designed in shape of
handles.

Fundamentals of Computer Operating and Programming 10


C.O.P.A. Trade of I.T.I RD S

5) Barcode Reader :-
They are generally used in superstore. Data is coded in form of light
and dark bars. With coded spacing and thickness. These are called as barcodes which are
commonly used to identify Items
.

6) Character and mark recognitions devices :-


These are devices which recognizes special character and marks.

a) MICR :-
Magnetic Ink Character Recognition. They read character printed with magnetic ink
i.e. it reads unusual nos. on bottom of the check.

b) OMR :-
Optical Mark Recognition. It detect presence or absence of mark on a paper.
It uses light rays to detect character.

c) OCR :-
Optical Character Recognition. It detect special preprinted character

.
6) Scanning Device :-
It reads data from source like text document , images pictures, graphs. After
image is scanned it comes in memory of the computer then it gets stored permently or
printed on paper. The Scanner can be flatbed or Optical Scanner.
Now a days there are so many input devices are sued like image capturing devices like
camera or web cam. One important input device is microphone which is used to record
sound..

 Output Devices :-
Output devices are the devices which are used to obtain output from computer.
Printer and monitor are two output devices which are used to obtain output from computer
.
1) Monitor :-
It is also called VDU ( Visual Display Unit ) It is a device used for
interactive processing i.e. data i.e. being keyed in is displayed on screed and monitor message
and processed information is also displayed on screen. The combination of keyboard and
VDU which is an input ,output (I/O). Monitor can be of two type.

Fundamentals of Computer Operating and Programming 11


C.O.P.A. Trade of I.T.I RD S

a) CRT Monitor :-
They uses Cathode Ray Tube that looks like a television picture tube.
The advantages of these monitor are low cost and excellent resolution. The
disadvantages are that they are large in size.

b) Flat panel Monitor :-


These are portable monitors. They are also known as LCD i.e. Liquid
Crystal Display Monitors. Their advantages are that they are not bulky. the disadvantages are
that they are expensive and require more power. The monitors clarify is indicated by its
resolution. It is measured in pixel. To indicate monitor resolution capability several standards
have evolved. The four most common are

Standard Pixel

SVGA 800 x 600


XGA 1024 x 768
SXGA 1280 x 1024
UXGA 1600 x 1200

Using monitor we can obtain softcopy of output.

2) Printers :-
Printers are used to produce hard copy of the output. Printers are classified by
how they point.

a) Ink Jet Printers :-


Droplets of Ink are electrically charged after leaving a nozzle. They are
high color quality and expensive.

b) Thermal Printer: -
These printer uses heat element to produce image on heat sensitive paper. They
are used in scientific lab and costly.

b) Laser Printer: -
Laser Printer can print one page at a time . It uses a laser beam for printing.
The printing quality of this printer is very high. They are more expensive than all other
printers. There are so many printers are available in market.

Fundamentals of Computer Operating and Programming 12


C.O.P.A. Trade of I.T.I RD S

c) Dot Matrix Printer: -


It is a versatile and low cost printer. In general they are used where
height quantity of paper printing is required

.d) Chain Printers.:-


They are expensive than DMP. They can be used in networks. Also
There are many types of other output devices like head phone or speaker for audio output,
plotter which is special type of printer. They can produce high quality multicolor printing.

MEMORY

Storage in one of the important characteristics of computer. Computer can


store large amount of data in its memory temporary permanently. There are two types of
memory as shown below.

MEMORY

PRIMARYY
SECONDARY

RAM ROM HARD DISK


FLOPPY DISK
COMPACT DISK (CD)
PROM
EPROM
EEPROM

 Primary Memory:-

It is also called as internal memory. When we always work in primary


memory. There are two types of internal memory.

Fundamentals of Computer Operating and Programming 13


C.O.P.A. Trade of I.T.I RD S

a) RAM:-

RAM stands for Random Access Memory. It is temporary memory. It is also


called as Volatile Memory. When we switch off our PC all information in this memory get
vanished. It is read / writes memory i.e. we can read information RAM and also write data in
RAM. It is fastest memory. Now a days RAM of 128 MB, 256 MB, 512MB, etc are available
in market. There are different types of RAM Cache Memory. Virtual Memory available in
market which are used for different purpose i.e. . to increase the speed of computer.

b) ROM:-
ROM stands for Read only memory. It stores of data instruction permanently in it
which is used Booting Process. If we switch off our computer then data in this memory
remain unchanged. It is developed by manufacturer. We can read data from this memory . We
can not write any data in this memory. We can not delete data from this memory. Following
are type of ROM.

I) PROM (Programmable Read Only Memory) :-


It used programmable memory. That is it is supplied in blank form by the
manufacturers. The user writes the desired program into it once, by a special process and then
the content can not unchanged
.
ii) EPROM (Erasable Programmable Read Only Memory) :-
The PROM has one defect that we can not change the content PROM if there is any
mistake in programming .Then the solution EPROM Where we can erase the content in it. To
erase the content EPROM ultraviolet rays are used.

iii) EEPROM: - (Electronically Erasable Programmable Read


Only Memory)
In this memory we can change the content of memory using electronic field.

Fundamentals of Computer Operating and Programming 14


C.O.P.A. Trade of I.T.I RD S

 Secondary Memory: -
When we want to store data permanently on computers memory then
secondary memory is used . It uses some device or disk to store data. It we switch off our PC
then also content in this memory remain unchanged. Following are the disks which are used
for secondary storage.
a) Floppy Disk :- This is portable disk which is used to store data. It is made up of thin
magnetic material enclosed in protection bracket. It is accessed as drive a or b In market there
are two types of floppy disk available i.e.

a) FLOPPY DISK:-

Size Storage Capacity


3 ½” 1.44MB
5 ¼” 1.2MB

From Read Write Notch we can read content of Floppy. There is Write Protect Notch present
on floppy which protects writing on floppy but we can read data from floppy. Internal
magnetic disk is deiced into logical circles called as track and these tracks are divided into
sectors.

Fundamentals of Computer Operating and Programming 15


C.O.P.A. Trade of I.T.I RD S

b) Hard Disk: -

Hard Disk can store large amount of data compare to floppy. It is fixed in
CPU. It can store 20GB, 40GB, and 80GB etc. data in it.
It is faster than floppy. It is made up of aluminum material. Hard Disk consist of one
or more metallic platters sealed inside a container. It contains motor for rotating disk.
It also contains an access arm and read write heads for writing data to and reading data
from the disks.

c) Compact Disk: -
CD uses laser technology. They can store large amount of data compared to
Hard disk and Floppy disk. They are silver coated so that light gets reflected from the
surface of the disk. In market different CDs with Different storage capacity are available.
There are three types of CD.

Fundamentals of Computer Operating and Programming 16


C.O.P.A. Trade of I.T.I RD S

I) CD-ROM :-

Stands for Compact Disk Read Only Memory. We can read data
from this disk but can not write.

II) CD-R:-

On this CD we can write data only once. But we cannot modify or rewrite another data
on this disk.

III) CD-RW: -
On this CD we can write and read data many times.

Another type of Optical disk available in market is DVD.

Fundamentals of Computer Operating and Programming 17


C.O.P.A. Trade of I.T.I RD S

NUMBER SYSTEM
In daily work we use Decimal No. system. This uses 0,1,2,3,4,5,6,7,8,9. Here
we are using 10 nos. Therefore basic of this system is 10. Computer is an electronic device. It
works on light so knows only two states on/off. So computer can understand only language of
0/1. 0 and 1 are called as binary digits and this number system is called as Binary No. system
which uses only two digit i.e. 0 and 1 . The base of this no. system is 2 (Bi means 2) 0 and 1
are called as binary digits i.e. bits.

 Working with Binary nos :-

1) Converting Decimal No, into Binary:-

To convert a no. from decimal to binary follows steps


a) Divide decimal number by 2.
b) Find out remainder and quotient.
c) Divide this quotient by 2 and again find reminder and quotient.
d) Report step 3 till we get quotient as 0.
e) Write down all remainders in reverse order. We get equivalent binary now.
e.g. (245)10 = (?)2

2 245 1

2 122 0

2 61 1

2 30 0

2 15 1

2 7 1

2 3 1

2 1 1

 Convert Binary No. into Decimal :-


Multiply unit place by 2. Multiply 10th place by 2 and so on increasing power
of 2 on left side of binary no. Then all these trained multiplications as shown below.

e.g. (110110)2 = (?) 10

Fundamentals of Computer Operating and Programming 18


C.O.P.A. Trade of I.T.I RD S

= 0 x 2 + 1x2 +1x2 + 0x2 + 1x2 +1x2


= 0+2+4+0+16+32
=54

 Octal No. System :-


In Octal No. System 8 digits are used 0,1,2,3,4,5,6,7. They are 8. Base
of octal No. system is 8. As in decimal to binary conversion we divide decimal no 2.

a) Decimal to Octal conversion :-


To convert decimal no. into octal no divide decimal no, by 8 and repeat
the same procedure same as given in decimal to binary conversion.

e.g. (108)10= (?)8

8 108 4

8 13 5

8 1 1

(108)10 = (154)8

b) Octal to Decimal Conversions:-


(154)8 = (?)10

=4x8+5x8+1x8
=0+40+64
=108

c) Octal to Binary Conversion:-

Octal Decimal Binary


0 0 000
1 1 001
2 2 010
3 3 011

Fundamentals of Computer Operating and Programming 19


C.O.P.A. Trade of I.T.I RD S

4 4 100
5 5 101
6 6 102
7 7 103

To convert octal no. into Binary above given table and write equivalent binary
no. for each digit.

e.g. (175)8= (?)2

1 7 5
001 111 101
= (1111101)2

d) Binary to Octal Conversion :-

Make group of three digit from unit place.

Add 0 to left side if required to complete group of three digits.

Write equivalent octal no.

e.g. (11100101011001)2= (?)8


011 100 101 011 001

3 4 5 3 1

= (34531)8

 Hexadecimal No. system:-

This number system uses no from 0 to F i.e.


0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.i.e. 10 is by represented by A, 11 by B
etc.

a) Decimal no. to Hexadecimal conversion:-


To convert decimal no. by into Hexadecimal divide decimal 40 by 16 and find
out reminder.

(110)10= (?)16

Fundamentals of Computer Operating and Programming 20


C.O.P.A. Trade of I.T.I RD S

16 110 E (14)

16 6 6

(110)10= (6E) 16

b) Hexadecimal to decimal Conversion:-

e.g. (6E) 16= (?)10


=Ex16+6x16
=14+96
= (110)16

Consider following table.

Decimal Hexadecimal Binary


0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111

c) Conversion of Binary No. into Hexadecimal:-

Fundamentals of Computer Operating and Programming 21


C.O.P.A. Trade of I.T.I RD S

To convert a Binary No. into Hexadecimal no. make group of digits from unit
place of binary no. Add 0 to right side of no, if required. Write down equivalent Hexadecimal
No, as shown below.

(111010101111110001010)2= (?)16

0001 1101 0101 1111 1000 1010

1 D 5 F 8 A

= (1D5F8A) 16

d) Conversion of Hexadecimal no. into Binary:-

To convert a Hexadecimal no. into binary write down equivalent binary no for
each digit in Hexadecimal no.

e.g. (D5F8EC) 16= (?)2

D 5 F 8 E C

1101 1010 1111 1000 1110 1100

= (1100101011111100011101100)2

 BCD numbers:-

BCD stands for Binary Coded Decimal. Here each decimal digit is represented
by equivalent 4 digits binary no.

e.g. (123)10 = (000100100011) BCD

 Addition of two Binary nos:-

To binary numbers can be added by addition of each corresponding


digit from unit place. To do addition refers following table.

Fundamentals of Computer Operating and Programming 22


C.O.P.A. Trade of I.T.I RD S

no1 no2 addition carry


1 1 0 1
1 0 1 -
0 1 1 -
0 0 0 -

e.g. 111101010

+ 100100

111 Carry

1000001110

 Subtraction of two Binary nos. :-

For subtraction of binary now refer following no.

no1 no2 Subtraction Borrow


1 1 0 --
1 0 1 --
0 1 0 1
0 0 0 --

e.g. 1110101001

- 11010001

11 1 Borrow

1000001000

Fundamentals of Computer Operating and Programming 23


C.O.P.A. Trade of I.T.I RD S

HARDWARE AND SOFTWARE

 Hardware :-
All physical parts of computer system which we see and touch are called
as Hardware .e.g. keyboard , mouse , monitor etc.

 Software :-
We know that computer works on instruction given by user . A set of
instruction is called as program is called as Software. There are four
types of software.
1) Operating System..
2) Languages
3) Translators
4) Utilities

1) Operating System :-
An operating System is essential part of any computer. It
is a program which coordinates and controls the operation of computer
hardware and software resources such as processors, memory input
output devices. It works as interface between compute hardware and
user. Operating system can be of following type.

a) Single user Operating System.


b)
e.g. DOS, win98

b) Multi-user Operating System.

UNIX, Windows NT

Single user operating system allows only one user to


work at a time. Multi-user operating system allows more than one
user at a time. It is used in networking. Following are some
important functions of operating system.

I) works as interface between user and computer


II) It keeps coordination between input and output devices.
III) File management.
IV) Memory management.

Fundamentals of Computer Operating and Programming 24


C.O.P.A. Trade of I.T.I RD S

V) I/O Management.
2) Languages :-
Using languages we can give instructions to the
computer. These languages can be of three type.

I) Machine Language :-
This is machine understandable language. Program can be
written in o’s and 1’s. It is machine dependent languages. i.e. Program
written for one machine can not work on other machines.

II) Assembly Language :-


This language uses mnemonics i.e. symbol to represent a
instruction. e.g. ADD instruction is used to add content of memory
or registers. This is also a machine dependent language.
To convert Assembly language into machine language.
Assemblers are used.

III) High level language :-


Programming in Assembly language and Machine
language is very difficult. There fore High level languages are
developed. They are English like languages
e.g.

BASIC – Beginner All purpose Symbolic Instruction code.


FORTRAN – Formula Translation
COBOL – Common Business Oriented Language.
C, Java , Pascal

3) Translators :-
Translators are the programs used for
conversion of High Level Language into machine level
language. Computer can understand only machine language
therefore translators are used. Translators can be of two type.
Interpreter convert program written in High level language into
machine language one line at a time. Complier convert program
written in High level language into machine language whole
programs at a time. Therefore speed to complier is faster than
speed of interpreter.

3) Utilities :-

Fundamentals of Computer Operating and Programming 25


C.O.P.A. Trade of I.T.I RD S

Utilities are the program which increases the


processing speed of computer. They are special programs which makes
computing easier. The most essential utilities are

a) Antivirus Programs :-
These programs are used to take backup of the important data
for security purpose.

b) Backup Programs :-
These programs are used to take backup of the important
data for security purpose.

c) Uninstall Programs :-
These programs are used to uninstall installed software. It
removes all files installed with corresponding software.
]

d) File Compression Programs :-


These programs are used to compress file make more memory
available on disk.

DOS OPERATING SYSTEM

We have seen that Operating System is very important


part of any computer system because it works as interface between
Computer and user. Without any operating system we can not work
on computer or we can not run any application software.

 Booting Process :-

Fundamentals of Computer Operating and Programming 26


C.O.P.A. Trade of I.T.I RD S

When we switch on the computer a process starts


till we get desktop screen of operating system is called as
booting process In this booting process operating system gets
loaded into RAM it checks for all system file, memory and input
output devices attached to our computer. Following are three
main system files which gets loaded into RAM during booting
process.

a) Command.com

b) MSDOS.SYS

c) IO.SYS

There are two types of booting process.

1) Cold booting

2) Warm booting

When we switch on our computer by switching power button is


called as cold booting Memory is checked in cold booting When
we switch on our computer by pressing restart button or ctrl A+Del then
the booting process as warm booting.

 DOS :-
Dos stands for Disk Operating System , Dos is also called is
command line
Operating system. i.e. it uses command for interfacing . It is a single
user single tasking operating system. i.e. only one user can work on
these operating system at a time and can do only one task at a time .
When we are working is DOS we are diving all commands on C :\>
called as DOS prompt or Command prompt. To work
with DOS we have to use commands. There are two types of DOS
commands

1) Internal DOS commands

2) External DOS commands

There are come basic commands loaded during booting


process which are in command . com file are called as internal
commands. They do not require support of hard disk based file for
execution.

The commands which are not loaded during booting


process and require support of some disk based file for execution are
called as External commands.

Fundamentals of Computer Operating and Programming 27


C.O.P.A. Trade of I.T.I RD S

1) Internal DOS commands

2)External DOS commands

1) Internal DOS commands :-

a) Time :-
This command is used to display and change time of
system. The time is displayed in hh;mm;ss.format

Syntax :- C:\> Time

o/p Current time is 4:21:20.09a

Enter new time:

c) Date:-
This command is used to display and change date of
system. The date is given is (mm-dd-yy.) format.

Syntax :- C:\> Date

O\p Current date is Fri 09-30-2005

Enter new date (mm-dd-yy):

c) Cls :
This command is used to clear the content of screen

Syntax :- C:\> cls

v) Ver :-

Fundamentals of Computer Operating and Programming 28


C.O.P.A. Trade of I.T.I RD S

This command is used to display the version of


operating system loaded on your computer.

Syntax :- C:\>ver Enter

O\p Microsoft Windows Xp ( Version 5.1.2600)

e) Vol :-
This command is used to display volume label your
disk .

Syntax :- C:\>Vol

o\p volume in drive C has no label

volume serial Number is 1618-10D5

f) Dir :-

This command used to see the list of all the contents on the
drive or
any director

Syntax: - C:\>Dir

O\p This command will display list of files and directories in


five
column . i.e. file name file extension , file size, date created
and one
created We can use following switches with Dir command
switch

 Switch Meaning :-

/p :- Displays list of files and directories page wise i.e. take


pause after
page break.
/w :- Displays only name of files and directories in five column
/d : - Displays all files with attribute.
/o : - Displays list in alphabetical order

Fundamentals of Computer Operating and Programming 29


C.O.P.A. Trade of I.T.I RD S

 File handling Internal commands:-

• what is a file?

File is a collection of data stored on disk . Each file on disk


is its unique name. Any file name has two pars a) primary name.

Extension.

e.g. if file name is myself. txt then myself is primary file name and
txt is extension primary name and extension is separated by dots (.)

• Naming rules for file :-


a)
A primary file name have maximum of 8 characters.
b)
In primary name spaces are not allowed.
c)
No special character is allowed in primary name
d)
Fit may be alphanumeric i.e. combination of (a-z)
and (0-9)
e) Extension is of maximum 3 character long.
f) It optional part in file name

• following are some valid file name :-

try 1.txt

hellow.dat

rudrani

hrd . rpt etc

g)Copy con: -

This command is used to create new file

Syntax :- C:\> Copy Con<file name>

Crtl+z or F6 is used to to save file

e.g. type copy con try 1 .txt on dos prompt and press
enter key
types the contents of file where cursor is appeared.
save the file by processing Ctrl+z

Fundamentals of Computer Operating and Programming 30


C.O.P.A. Trade of I.T.I RD S

You find the a file name try1 txt is get created on disk.

h) Type :-
This command is used to display the contents of existing
file

Syntax : C\> type< file name > enter

e.g.:\< Type try 1 txt this will display contents of file

i) Copy:-
This command is used to copy the contents of source
file to
destination file . Syntax : Coy <source file> <destination file> enter

e.g. .copy try1 ctry 1 tct this copies the contents of try 1 txt to
ctry1.txt

j) Rename :-
This command is used to change the name of
existing file

Syntax ;C:\> Rename try 1 txt exp txt this command


change these name of file try 1 txt to exp txt.

k) Delete:-
This command remove the existing given file from disk

Syntax : C:\>Delete <file name>

Delete try 1 txt enter delete the file try 1 txt

Directory handling commands

Directory is collection of files .

1) MD (Make Directory ) :-
This command is used to create directory or sub
directory

Syntax: C:\> MD<Directory Name>

e.g. C:\>MD MBCT

Fundamentals of Computer Operating and Programming 31


C.O.P.A. Trade of I.T.I RD S

2)CD (Change Directory) :-

This command is used to changes from one directory to


another directory.
Syntax:-C:\> CD< Directory name>

e.g. .C:\> CD MBCT

CD ..is used to go to parent directory of current directory.


and CD\ is used to go to root directory

3)RD( Remove Directory):-


This command is used to remove blank directory. if we
want to remove any directory the we must that directory blank by
deleting files and subtracted in it

Syntax :C\>RD<Directory Name>

e.g. C:\>RD MBCT

 Use of wild chard character Dos


command :-

Wild chard character are the character which are used replace on
two multiple character in dos command three to wild chard characters
used in dos . they are ? and *? is used substitute single character and *
used to substitute multiple characters .
e.g.

a) c:\>dir A*.* :-
Will display all files on c; whose name is starting with alphabet

b) C:\>copy*.*d: \mydir :-
This command will copy all files on c:to \ mydir.

Fundamentals of Computer Operating and Programming 32


C.O.P.A. Trade of I.T.I RD S

c)c:\.dir c??.* :-
This command will display list of files whose name is
starting with character c and there are only two character after c and
having any extension.

d) Del*.* :- This command will delete all files in current director

 Word processing in DOS :-


In Dos it is not possible to modify the contents of file after
saving it. To modify the contents of existing file we have to used editor
DOS contents a file Edit. Com. Using this file we can create new text
files and modify existing file in DOS . To open this editor give Edit
command on DOS prompt as given below

In this editor by default file name is untitled 1. There are six


different menus. Each menu name contain a single white color character.
That means we can open that menu we can open that menu by pressing
ALT key with highlighted character in menu name . e.g to open file
menu press Alt+F

1) File menu :-
Creating a new file: -

a)Click on file menu


b)click on option new
c)type the contents of file

2)saving the file :-

a) click on file menu


b) click on option save as to give new name to file to save
modifications click on save
c) A Save as dialog box will appear given file name
d) Click on save button

3)Close the file:-

a) click on file menu


b) click on close option

Fundamentals of Computer Operating and Programming 33


C.O.P.A. Trade of I.T.I RD S

4) close the file


a) click on file menu
b)click on print option

2) Edit menu :-

To cut and paste text


a) select the text which you want to cut
b) click on edit menu
c) click on cut option Place the cursor where you want to
paste
d) click on paste option from edit menu

2. To copy and paste text :-

a) Select the text which you want to copy


b) click on edit menu
c) click on copy option
e) place the cursor where you want to paste
f) click on paste option from edit menu

3) To delete the text :-

a) select the text which you want to delete.


b) click on edit menu
c)Click on delete option

4) Search menu :-

1. To find a particular text


a) click on edit menu
b)click on find option
c) Give the word which we want to find .Match whole word
matches the words and Match case matches for the upper the
small letters
d) click on ok to find the word

To find and replace:


a) click on edit menu
b) click on replace option
c) give the word which we want to find . Also specify the
word with which you want replace the words and
match case matches for the upper and small letters

Fundamentals of Computer Operating and Programming 34


C.O.P.A. Trade of I.T.I RD S

d) click on replace to find and replace one word at time and


click on replace all to find and replace all words
time

4 )View menu :-

1. Split Window :- Spilt the current window into two


windows
2. Size window :- Change the size of window
3. close window : - Closes the current window

5) Tools Menu :-

Setting :- We can make settings for printer ports and tab stop

1. Color : -

We can change the color of active window, text selected


text etc. in editor.

6. Help Menu : -

This menu proved help for edit command and about


editor

 External DOS commands :-

a) More :-
This command is used to display list of files and
directories or contents of files one screen at time . It will display more at
bottom to display next screen of file

Syntax: C:\> command | More

e.g. C:\>dir|

c:\>types<file name>| more

This displays content of file page wise

b) Tree:-

Fundamentals of Computer Operating and Programming 35


C.O.P.A. Trade of I.T.I RD S

This commands-displays directories and subdirectories a


tree structure as shown below
Syntax : c:\> tree

C)Deltree :-

This command is used to delete particular directory and


its subdirectories

Syntax : C:\> Deltree < directory name >

d)Chkdsk :-
This command check for the disk and displays disk
status. It display file system , check for all files and folders free memory
space on disk, storage capacity of disk, if there is problem in any file
then / F option used with chkdsk which fixes the errors on disk. It also
find out memory occupied by hidden files, directories

e) Format :-

This command deletes all files and directories on


disk. It will create new tracks and sectors on disk. Some
sectors are not accessible to user that are reserved for FAT
i.e. File Allocation.

Fundamentals of Computer Operating and Programming 36


C.O.P.A. Trade of I.T.I RD S

WINDOWS(GRAPHICAL USER
INTERFACE)
We have seen DOS operating system which provides command
Line interface. We have to remember all command to do any job in
DOS. Windows provide a very easy interface which shows you all files
and command on screen you have to select one of them . Windows also
support multitasking. That means we can here songs while working on
computer. We can open to or more files at a time. Windows 98,
Windows 2003, Windows NT etc are the operating system developed by
Microsoft and supports GUI.

Terminologies in Windows

1) Desktop :- When we switch on computer, after


completion of booting process first screen appeared is
called as ‘Desktop’. It contains so many things like icons
shortcuts etc.as shown below

2) Icons :-

Fundamentals of Computer Operating and Programming 37


C.O.P.A. Trade of I.T.I RD S

Icon is graphical or pictorial representation of any file.

3) Shortcuts :-

These are icons with small arrows. They are shortcut to


pencils software.

4) Start Menu:-
This menu contains all software available in your
computer. We can start any application from this menu .

5) Task bar :- Shows are opened task or windows.

6) Folder :- Folder is collection of files and subfolders is


same name for directory in DOS.

7) Window :- Window is a very basic feature of any


Graphic Operating System. It works as a container for
different controls. Following are the main part of window.

a) Title bar :-
This shows the name of window or software.

b) Menu bar :-
This shows all menu or commands available in that
software.

c) Minimize Button :-

This button closes the active window.

d) Close Button :-
This button close the active window

.
e) Maximize Button :-

Fundamentals of Computer Operating and Programming 38


C.O.P.A. Trade of I.T.I RD S

This button maximize the active window.

 Start Menu :-
When we click on start menu . It will display all
programs or application in our computer as shown below.

shown below. Stand by means your computer remain in low power


state . Turn off Closes all applications and shut down the computer and
Restart closes all applications and restart computer again.

Fundamentals of Computer Operating and Programming 39


C.O.P.A. Trade of I.T.I RD S

1) Log off Administrator :-


This exists from current login and switch to new
login.

2) Run :-
This allows to run any file or program. e.g. When we run
command. com DOS will get start.

3) Help and Supports :-


This allows to search for particular topic operating
system or displays all topics about which information is available on
computer F1 is shortcut key to help. We can take help in windows using
index key or by searching topic or by selecting topic in display list.

4) Search :-
Search allows searching of particular files or group of
files on different drives on disk.

5) Settings :-
Allows to change system setting for different peripheral
devices like printer, internet, network, fonts etc.

6) Documents :-

Shows list of all recently opened documents.

7) Program :-

This shows list of all application software


available on our PC. We can start any application by click on the name
of that application.

Fundamentals of Computer Operating and Programming 40


C.O.P.A. Trade of I.T.I RD S

 Display Properties of desktop :-

1) Wallpaper :-
It is background pattern given to desk top called as
wallpaper. To change wallpaper.

a) Press right button of mouse on desktop. A shortcut menu will get


appeared.
b) Click on properties option in it.
c) Click on Desktop tab and change the Background setting and
click on apply to make changes permanent.

2) Screensaver :-
A moving pattern appeared on screen when here is no
movement of mouse or keyboard is called as screen

saver. To Change screen saver.

a) Press right button of mouse on desktop. A shortcut menu


with get appeared.
b) Click on properties option in it.

Fundamentals of Computer Operating and Programming 41


C.O.P.A. Trade of I.T.I RD S

c) Click on Screen Saver tab and change the screen saver


setting and click on apply to make changes permanent

 Task Bar Properties :-

To change taskbar properties

1) Place mouse pointer on taskbar

2) Press right button of mouse

3) Click on Properties option.

We can set following properties of task bar


a) Lock the taskbar : -
This will not allow movement of task bar.

b) Auto hide taskbar : -


This will automatically hide the taskbar when it is not in
use

c) Keep the taskbar always on top :-


This keeps task bar on top even if any other application
window is opened.

d) Group similar taskbar button :-

This will group similar taskbar windows in one window.

e) Show quick launch :- This shows Quick Launch toolbar.

Fundamentals of Computer Operating and Programming 42


C.O.P.A. Trade of I.T.I RD S

f) Show the clock :-

Shows clock on right side on the task

g) Hide inactive icons :-


This hides inactive icons on task.

 Explorer :-
To open windows explore Press right button of mouse on
start button. A Shortcut menu will appeared Click on explore option. A
start menu window will get appeared which explores each folder and
subfolder on given path.

a) In this explorer window click on file menu.


b) Click on new option.
c) Click on folder option.
d) This will create new folder. Give new name to folder.

Fundamentals of Computer Operating and Programming 43


C.O.P.A. Trade of I.T.I RD S

If folder is already created then we can change the name of


folder by pressing right button on folder and select option rename and
change the name of folder. To delete folder click on delete option from
same shortcut menu.

To create folder on desktop press right mouse


button. A shortcut menu appeared. Click on new -> folder.

 Creating a shortcut :-
To create short cut Click on file menu in explorer.
Then click on NEW-> Shortcut. " Create Shortcut" Dialog will get
appeared on screen. This will ask ask for the file or program to which
you want to create shortcut. Give that filename with path or select that
file suing . Brows button. Then click on next button and give name to
the shortcut and click on finish button.
To create Shortcut on desktop press right mouse
button. A shortcut menu appeared . Click on New-> Shortcut. "Create
Shortcut" . Dialog will get appeared on screen and then select file or
give path of file and then click on next button give name to shortcut and
click on finish button.

 My Computer :-
The icon shown is always present on desktop. To open
that right click on it and select open option form shortcut menu or
double click on the icon to open my computer. It will displays system
configuration and all drives available out computer

 Recycle Bin :-
When we delete any file in windows operating
system in come in recycle Bin . We can restore all deleted files from
Recycle Bin. To restore files from recycle bin click on file menu and
click on "Restore" option. To delete files permanently from recycle bin
click on file menu and click on "Empty Recycle Bin" Option.

 Calculator :-
To open Calculator Click Start-> Program -> Accessories->
Calculator
Following calculator window will appear.

Fundamentals of Computer Operating and Programming 44


C.O.P.A. Trade of I.T.I RD S

Calculator is used for numeric calculation. Calculator has two


view i.e. Standard and scientific and we can operate in hexadecimal or
octal or binary or decimal no. system .

 Notepad :-

Notepad is a simplest word processing software. Its


window

Fundamentals of Computer Operating and Programming 45


C.O.P.A. Trade of I.T.I RD S

contains. Title bar, Menu bar, Status Bar. By default file name in
notepad is "Untitled . txt" where .txt is extension indicates that it creates
text file. Follow following window.

To open Notepad Click on Start->Program->Accessories-


>Notepad

 File Menu :-
1) Creating a new file:-

a) Click on file menu .


b) Click on option new.
c) Type the contents of file.

2) Saving the file :-


a) Click on file menu.
b) Click on option Save as to vive new name to file and to save
modifications click on save
c) A ' Save as' dialog box will appear, give file name.
d) Click on save button.

Fundamentals of Computer Operating and Programming 46


C.O.P.A. Trade of I.T.I RD S

3) Open existing file :-


a) Click on file menu.
b) Click on open option.
c) Select file name from appropriate path.
d) Click on open button.

4) To Change the page setup :-


a) Click on file menu .
b) Click on page setup .
c) Set paper size, orientation, margins and header footer and click ok
button to apply the settings.

5)Print the file :-


a) Click on file menu .
b) Click on print option .
c) Give the number of copies and select printer and click on print
button .

To exit from notepad click on "Exit" option in File menu.

 Edit menu:-

1) Undo :- This option cancels unsaved action.

2) To cut and paste text :-


a) Select the text which you want to cut .
b) Click on edit menu .
c) Click on cut option .
d) Place the cursor where you want to paste.
e) Place the cursor where you want to paste .
f) Click on paste option from edit menu .

3) To copy and paste text :-


a) Select the text which you want to copy .
b) Click on edit menu .
c) Click on copy again .
d) Place the cursor where you want to paste .
e) Click on paste option form edit menu .

4) To delete the text :-

Fundamentals of Computer Operating and Programming 47


C.O.P.A. Trade of I.T.I RD S

a) Select the text which you want to delete .


b) Click on edit menu .
c) Click on delete option .

5) To find a particular text :-


a) Click on Edit menu .
b) Click on find option

c) Give the word which we want to fine . Match case matches the upper
and small letters.
d) Click on Find next to find the word.

6) To find and replace :-

Fundamentals of Computer Operating and Programming 48


C.O.P.A. Trade of I.T.I RD S

a) Click on Edit menu


b) Click on replace option

c) Give the word which we want to find . Also specify the word with
which you want replace current word. Match whole word matches the
words and match case matches for the upper and small letters.

d) Click on replace to find and replace one word at a time and click on
replace all to find and replace one word at a time and click on replace all
to find and replace all words at a time.

To select whole file Click on select All option or press


"Ctrl+A".
To insert date and time Press F5 or click on "Time/Date".

 Format Menu :-
1) Word wrap :-

This enables to display text in multiple line or cursor


comes automatically to next line end of first line is there. When it is
inactive all text get typed on one line only.

2) Font :-
We can change font , font size , and font style.

Fundamentals of Computer Operating and Programming 49


C.O.P.A. Trade of I.T.I RD S

 Help Menu :-
We can help about note pad from help menu.

Fundamentals of Computer Operating and Programming 50


C.O.P.A. Trade of I.T.I RD S

PAINT BRUSH

Paint brush is a drawing Software used to create simple


drawings. That drawings can be black & white or color & can be saved
as bitmap files (.bmp is extension) Paint Brush is also used to work
with perches such as jpg or.bmp files."Untitled.bmp " is by default
filename in paint brush.

Following task are performed when you are using paint.

1) Draw straight line

2) Fill area with color

3) Work with images from digital camera or scanner.

How to start paint

Fundamentals of Computer Operating and Programming 51


C.O.P.A. Trade of I.T.I RD S

1) Click on 'start button'.

2) Click on 'programs' a menu will appear.

3) Click on 'accessories' menu.

4) Click on 'paint'.

 Following paint screen get appear.:-


There are 16 tools are available on tool box for painting.
Status bar gives status of file.

 Tools in Paint Brush :-

1) Jig Jag cut tool :-


This tools is used to select random area in picture.

2) Selection tool :-
This tools is used to select rectangle area in file.

3) Eraser tool :-

This tools is use to select rectangle area in file.

4) Fill with colour :-


This tool is used to fill color in given object

5) Pick up a colour :-

This tool is use to copy color bitmap File.


6) Zoom Tool :-

To Magnify the Picture this tool is used.

Fundamentals of Computer Operating and Programming 52


C.O.P.A. Trade of I.T.I RD S

7) Rectangle tool :-
This tool is used to draw a rectangle drag & method. To
draw exact square this tool is used with shift key & drag rectangle tool
to get exact square.

8) Rounded Rectangle Tool :-


This tool is use to draw rectangle with rounded corners.
To draw exact square press shift key and then drag and draw rounded
rectangle.

9) Circle / Ellips :-
This tool is used to draw ellips. To draw exact ellips
press shift key and then drag and draw circle. In all rectangle and ellips
tool we can change the format of tools from the format given below tool
box.

10) Straight line :-


This tool is used to draw straight line in any direction. If
this tool is used with Shift key then straight line can drawn only in
perpendicular direction. We can also change the thickness of line from
the thickness give below tool box.

11) Air Brush :-


This tool is used to spray color. We can change the size
of air brush.

12) Brush tool :-


This tool is used to fill color . We can change the shape
of brush.

13) Curve line :-


This tool is used to draw curve line. To draw a curve line
first draw a straight line using this tool and then curve effect on both
side of line.

Fundamentals of Computer Operating and Programming 53


C.O.P.A. Trade of I.T.I RD S

14) Text :-
This tool is used to type text in picture

15) Polygone tool :-


This tool is used to draw polygone.

16) Pencil :-
This tool is used for free hand drawing.

 File Menu :-

 Creating a new file :-


a) Click on file menu.

b) Click on option new.

 Saving the file :-


a) Click on file menu.

b) Click on option Save as to give new name to file and to save


modifications click on save

c) a 'Save as ' dialog box will appear, give file menu


.
d) Click on save button.

 Open existing file :-

a) Click on file menu


b) Click on open option
c) Select file name from appropriate path
d) Click on open button.

 Print Preview :-

Fundamentals of Computer Operating and Programming 54


C.O.P.A. Trade of I.T.I RD S

Print preview means view of picture before printing it.

a) Click on file menu.


b) Click on 'Print Preview' Option following dialog will appear

Where Print is used to print the file 'One page'/ 'Two


Page' are used to display one or two pages at time 'Zoom In' and 'Zoom
Out' is used to view picture in magnified form. 'Next Page' and
'Previous Page' is used to switch between various pages. To close this
view click on close button.

 To change the page setup :-


a) Click on file menu
b) Click on page setup
c) Set paper size, orientation, margins and header footer and click ok
button to apply the settings in Page Setup Dialog Box.

 Print the file :-


a) Click on file menu

Fundamentals of Computer Operating and Programming 55


C.O.P.A. Trade of I.T.I RD S

b) Click on print option


c)Give the number of copies and select printer and click on print button.

To exit from notepad click on "Exit" option in File menu.

Set as Background (Tile/Center) : - This will set the current opened

There is a list of recently opened files in file menu. and


exit is used to exit form paint brushes.

 Edit Menu :-

1) Undo :-

This option cancels recent unsaved action.

2) Repeat :-

This repeat the action which is recently canceled.

 To cut and paste text :-


a) Select the Picture which you want to cut.
b) Click on edit menu
c) Click on cut option
d) Click on paste option form edit menu
e) Cut Past is smae4 as moving a picture.(Ctrl+x is shortcut key for copy
and Ctrl+v is shortcut key for paste)
 To copy and paste text :- (Ctrl+C is shortcut key for
copy)

a) Select the picture or part of picture which you want to copy.


b) Click on edit menu.
c) Click on copy option
d) Click on paste option form edit menu.

 To delete the text (Del) :-


a) Select the picture which you want to delete.
b) Click on edit menu.
c) Click on delete option

 Select All :-

Fundamentals of Computer Operating and Programming 56


C.O.P.A. Trade of I.T.I RD S

Selects Whole Picture Ctrl+A is shortcut key for Select


All.

• Copy to:-
To copy selected drawing or whole drawing to another
new file this option is used.

a) Select a part of drawing


b) Click on Edit-> Copy to
c) Give new file name in copy to dialog box.
d) Click on ok.

 Paste From :-
To bring a drawing from another file to current file this option is
used.

a) Click on Edit-> Paste From.

b) Select existing file name in paste from dialog box

c) Click on open.

 View Menu :-
This menu is related with display of tool box, color box,
status bar, text tool bar on screen. We can active or inactive them from
view menu by clicking on corresponding option.e.g. if color box is
inactive to active it click on View-> Color box. A check mark indicates
that it is active. To inactive it do same View-> color box. Text tool bar
is active if Text tool is selected from tool box. It is used to change font ,
font size text. Ctrl+T is shortcut key to activate tool box and Ctrl+L
active color box.

1) Zoom in : -
This option is used to display picture in magnified form
or large size and normal size.

2) Show grid :-

Fundamentals of Computer Operating and Programming 57


C.O.P.A. Trade of I.T.I RD S

This option shows grid line so we can draw


picture by taking measurement. This option is active only in magnified
form. It is inactive in normal form.

3) Show Thumbnail is also active in magnified form which shows


picture in normal form when we are working in zoom in or magnified
view.

4) View Bitmap Shows picture on full screen. Ctrl+F is shortcut key.

 Image menu :-

 Flip Rotate :-

This option allows to rotate picture by 90,180,270


degrees. Flip Horizontal rotate take horizontal image and Flip vertical.

Fundamentals of Computer Operating and Programming 58


C.O.P.A. Trade of I.T.I RD S

gives Vertical image. Click on ok to apply Ctrl+R is short cut key for
flip and rotate effects.

 Stretch and skew ( Ctrl+W) :-


Select a part of picture. Stretch horizontal changes width
of picture and Stretch vertical changes height

of picture according to given percentage. Skew horizontal


and Skew vertical apply skew effect according to given degrees.

 Invert Color ( Ctrl+A) :-


This invert the existing color. Convet black into whit, red
into green etc.

 Attributes :-

Fundamentals of Computer Operating and Programming 59


C.O.P.A. Trade of I.T.I RD S

This changes the picture size Give width and height


select unit for measurement i.e. inches or cm or pixels. Black and white
shows black and white picture.

Clear Image clear the whole image (Ctrl+Shift+N) is shortcut


key for clear image.

 Draw opaque: -
When this is active or having check mark picture
is selected with White paper background and when it is inactive
background is transparent.

 Color Menu :-
We can edit different colors in color box used Color->
Edit colors option .

Help menu provides help about paint brush.

Fundamentals of Computer Operating and Programming 60


C.O.P.A. Trade of I.T.I RD S

WORD PAD
Word Pad is advance software than Notepad. To open word pad
click on Start -> Program -> Accessories -> Word pad. A WordPad
window appears on screen as shown below.

Word Pad contains tool bars and Menu bar and ruler and status
bar as shown above. In word pad by default file name is documet.doc.
We can also create rich text document and Unicode documents in
WordPad.

 File menu :-

 To create New file (Ctrl+N) :-


1) Click File-> New
2) New Dialog will appear
3) Select Text Document and click on ok

Fundamentals of Computer Operating and Programming 61


C.O.P.A. Trade of I.T.I RD S

 To Save New file (Ctrl+S) :-


1) Click file -> Save as to give new name to file.
2) In save as dialog box give file name and click on save button.
3) Select Text Document and click on ok.

 To open existing file (Ctrl+O) :-


a) Click on file->Open
b) Selected file name from appropriate path and Click on open
button. To save modification in already saved file use save option in
file menu.

 Print Preview :-
Print preview means view of document before printing it.

a) Click on file menu


b) Click on 'Print Preview' option following dialog will appear

Where Print is used to print the file 'One Page'/'Two


Page' are used to display one or two pages at a time 'Zoom In' and
'Zoom Out' is used to view picture in magnified form. 'Next Page' and
'Previous Page' is used to switch between various pages. To close this
view click on close button.

 To change the page setup :-


a) Click on file->page setup
b) Set paper size , orientation, margins and header footer and click ok
button to apply the settings in Page Setup Dialog Box.

 Print the file :-


a) Click on file-> print option
b) Give the number of copies and select printer and click on print button.

To exit form WordPad click "Exit" option in File menu. File


menu in word pad also contains list of four recently opened files.

 Edit Menu :-

1) Undo :-

Fundamentals of Computer Operating and Programming 62


C.O.P.A. Trade of I.T.I RD S

The option cancels recent unsaved action.

2) Repeat :-
This repeat the action which is recently canceled.

 To cut and paste text :- (Ctrl+X, Crtl+V)


a) Select the text which you want to cut
b) Click on Edit->Cut option and place the where you want to paste the
text
c) Click on paste option from edit menu.

 To copy and paste text :- ( Ctrl+c is shortcut


key for copy)
a) Select the text
b) Click on Edit-> Copy and place the cursor where you want to paste
the text
c) Click on paste option form edit menu.

 Paste Special :-
This option is used to paste cut or copied text in special
format.i.e. in unformatted text or in picture format.

 To delete the text (Del) :-


a) Select the text which you want to delete.
b) Click on Edit-> Clear option.

 Select All :-
Selects Whole text. Ctrl+A is shortcut key for
Select All.

 To find particular text (Ctrl+F) :-

Fundamentals of Computer Operating and Programming 63


C.O.P.A. Trade of I.T.I RD S

a) Click on Edit-> find option Find dialog box same as in Note pad will
get appear.
b) Give the word which we want to find. Match case matches for the
upper and small letters.
c) Click on Find next to find the word . F3 is shortcut key for find next.

 To find and replace (Ctrl+H) :-


a) Click on Edit-> Replace option. Replace dialog same as in notepad
will appear.
b) Give the word which we want to find. Also specify the word with
which word you want replace current word. Match whole word matches
matches the words and match case matches for the upper and small
letters.
c) Click on replace to find and replace one word at a time and click on
replace all to find and replace all words at a time.

 View Menu:-
This menu is related with display of Tool bar, Format
bar, Status bar and Ruler. We can active or inactive them form view
menu by clicking on corresponding option. e.g. if Tool bar is inactive
then to active it click on View
-> Tool bar. A check mark indicates that it is active. To inactive it do
same view-> Tool bar.

 Tool Bar :-
This bar also contains shortcut tools to create new file,
open existing file, save existing file, Print file to display previews also
for cut, copy, paste, undo and date/time tools .

 Formatting bar :-
Using this bar we can one age formatting of text using
font, font size, bold, italic etc tools.

Status bar gives of Num lock, Caps lock etc and status of file.

Ruler is used to change indents of paragraph.


 Options :-
This is also used to activate or inactivate format bar,
toolbar, status bar and ruler.
also we make wrap setting and set measurement unit
form options tab. Wrap to window means new line stat at end of window
.

Fundamentals of Computer Operating and Programming 64


C.O.P.A. Trade of I.T.I RD S

and wrap to ruler means new line start at end of ruler i.e. right
indent of paragraph.

 Insert Menu :-

1) Date and time :-


using this option we can insert date and time in required
format where the cursor is placed.

2) Object :-
Using this option we can insert new object file from
different software like Corel draw or paint brush etc.
a) Click Insert -> Object
b) Select software from which you want to insert object and click on ok
button.

 Format Menu :-

Fundamentals of Computer Operating and Programming 65


C.O.P.A. Trade of I.T.I RD S

 Font :-
To change font, font style , font size and color of selected
text font is used.

a) Click Format ->Font

b) Set font font , font style , font size and color in font dialog box.

 Bullet Style :-
This will apply bullets to each paragraph in
selected text.

 Paragraph :-
This is used to left , right , first line margin and
alignment of selected paragraph.

Fundamentals of Computer Operating and Programming 66


C.O.P.A. Trade of I.T.I RD S

a) Click Format -> Paragraph following dialog appear

b) set left , right line margin and set alignment and click on ok apply
settings.

Fundamentals of Computer Operating and Programming 67


C.O.P.A. Trade of I.T.I RD S

a) Click Format -> Tab following Tab dialog will appear.

b) Give tab stop position 1 and click on set.

c) To apply tab settings click on ok button and to cancel tab settings


click on Clear all.

In following dialog if you set tab and 1 position then if cursor


will move to 1 tab position when tab key pressed on new line

Help in Word pad is used to display help about WordPad.

Fundamentals of Computer Operating and Programming 68


C.O.P.A. Trade of I.T.I RD S

INTRODUCTION TO WORD

 INTRODUCTION :-

We have seen Notepad and Word pad in windows. We


know that they are word processor software. But there are some
limitations. We can not create table, we can not create different
windows. We can not insert page breaks very easily or user friendly. MS
Word is a software developed by Microsoft. It is a part of MS-Office. It
is specially designed for word processing purpose. MS word is a word
processing software which is used to create documents or process on the
text by applying different effects available in it. It is part of on the text
by applying different effects available in it. It is part of MS-Office
which is more advanced than Notepad and WordPad. There are different
versions of MS-Office i.e. Office 2000 or office 2003 etc. There is a
slight difference between them. Here we are referring Office 2000.

 Starting MS-Word :-

To start MS-Word click on Start->Programs-


>MS-Word. The following window will appear.

This window contains Title Bar, Menu Bar , Standard Toolbar.


Formatting Toolbar, Drawing Toolbar and Status Bar. By default file
name in MS-Word is ' Document1.doc' where doc is extension specifies
that this is document file.

Fundamentals of Computer Operating and Programming 69


C.O.P.A. Trade of I.T.I RD S

• Title Bar :-

This bar contains title of document , Minimize ,


Maximize and close button.

• Menu Bar :-

There are 9 different menus on menu bar contains


submenus and options to complete the job. We will see application of
different menus later in this book .

• Standard Toolbar :-

Standard tool bar contains tools for creation,


opening, printing and editing text documents as shown below .

Fundamentals of Computer Operating and Programming 70


C.O.P.A. Trade of I.T.I RD S

1) New :- Opens new file.

2) Open :- Open existing file.

3) Save :- Save file.

4) Print :- Print current file.

5) Print Preview :- To Display preview of current document.

6) Spelling and Grammar :- Used to check spelling and


grammatical.

7) Cut :- To cut selected text

8) Copy :- To copy selected text.

9) Paste :- To paste cut or copied text.

10) Format Painter :- This tool copies formatting of selected


text and apply it to another text selection.

11) Undo :- This cancels recent action.

12) Redo :- This repeat recent cancelled action.

13) Insert table :- Insert table with specifies no columns and


rows.

14) Inset Excel Sheet :- Insert Part of excel worksheet.

15) Zoom :- Displays text in specified zoom percentage.

16) Help :- Used to display windows help.

• Formatting Tool Bar :-

Formatting tool bar contains different tool for


formatting text like font, font size, font style, alignment, bulleting,
numbering, color etc. These tools are as shown below.

1) Style :-

Fundamentals of Computer Operating and Programming 71


C.O.P.A. Trade of I.T.I RD S

We can apply predefined styles to selected text.e..g .


Heading1 , Heading2 , Normal etc.

2) Font :-

We can apply different fonts to selected text.

3) Font size :-

We can apply different font size.

4) Bold , Italics , Underline :-

Applies Bold , Italics and Underline effect to selected


text.

5) Alignments :-
We can align text in paragraph to left, right, center or
justify.

6) Indents :-
We can increase or decrease indent of selected paragraph.

7) Border :-
We can apply borders to table.

8) Highlight :-
Select color to highlight the text.

9) Font color :-
Apply selected color to selected text.

Drawing Tool Bar :-

Drawing tool bar contains different tools for drawing


purpose like Auto shapes, line , arrow , rectangle , ellipse, textbox , and
word art, clipart etc. We will see this tool bar later in this book.

 Status Bar :-

Fundamentals of Computer Operating and Programming 72


C.O.P.A. Trade of I.T.I RD S

This bar displays status of the document. Where is cursor


is placed i.e. line no. section no. total no. of pages, current page no.

 WORKING WITH FILE MENU :-

1) Creating New Document :-

a) Click on File->New or press Ctrl+N keys from keyboard.

Following New dialog will get displayed.

b) We can create different new files in word like template, letter or web
file. In all these option click on 'New Blank Document' in General tab
and click on OK button.

This will create new file in MS-Word.

2) Saving New File :-

Fundamentals of Computer Operating and Programming 73


C.O.P.A. Trade of I.T.I RD S

a) Click on File->Save As or press Ctrl+S keys from keyboard.


Following 'Save as' dialog will get displayed.

b) Select the path where you want to store the document and then give
file name and click on button 'Save'. The name given by you will appear
on Title bar.

If we to save modifications in file then click on Save option from


File menu. To save document as web page then click on 'Save as Web
Page' from File Menu.

3) Version :-
We can save different versions of document using
Versions option if File Menu.

4) Open Existing Document :-


a) Click on File->Open or Ctrl+O keys from keyboard.

Following dialog will get displayed.

Fundamentals of Computer Operating and Programming 74


C.O.P.A. Trade of I.T.I RD S

b) Select file name which you want to open from appropriate path and
click on Open.

5) Page Setup :-
To change page setup click on 'File->Page Setup'

There are four tabs in Page setup Margins, Paper Size , Paper
Source and Layout.

In Margin Tab we can set Top, Bottom, Left, Right and


Gutter(Margin for binding purpose) margins of paper. We can also set
Header and Footer margin and mirror margin.

Fundamentals of Computer Operating and Programming 75


C.O.P.A. Trade of I.T.I RD S

In Paper size tab we can set paper size, we can also set paper size
according to our requirement. Orientation may be portrait or landscape .
In Layout tab we can set header footer and we can set border and line
numbers.

6) Print Preview :-
This is used to display view of page before printing it. By
viewing the preview of document we can change the page setup
according to our requirement. Web page preview will display the
document that how it will get displayed on web page.

7) Send To :-
Using send to we can send the document to destination
using fax, using mail etc.

8) Properties :-
This option displays general properties of file and we can
set properties like read only, archive, hidden or system file.

Fundamentals of Computer Operating and Programming 76


C.O.P.A. Trade of I.T.I RD S

General properties displays where it is stored. When it is created,


when it is modified and when it is accessed. It also displays how many
paragraphs are there, how many words are there and how many lines are
there etc. in current file.

File menu also display recently opened file also display recently
opened files and also Exit is used to close MS-Word.

 WORING WITH EDIT MENU :-

As we have studied earlier Edit menu is related


with modifications and editing in document. Following are the
submenus in edit menu.

1) Undo (Ctrl+Z) :-
This is used to cancel recently done action in current
document.

2) Redo (Ctrl+Y) :-

Fundamentals of Computer Operating and Programming 77


C.O.P.A. Trade of I.T.I RD S

This is used to repeat the actions those are cancelled. If


we have not cancel or undo any action then Redo is inactive.

3) Moving text :-
To move text form one place to another use CUT
(Cut+X) and Paste (Ctrl+V ) in edit menu.

a) Select the text which you want to move.


b) Click on Edit->Cut.
c) Place the cursor where you want to paste it.
d) Click on Edit-> Paste.

You found that the test is moved from source to destination.

4) Copying Text :-
To copy text from one place to another place use Copy
(Ctrl+C) and Paste (Ctrl+V) from Edit menu.

a) Select the text which you want to copy.


b) Click on Edit->Copy.
c) Place the cursor where you want to copy it.
d) Click on Edit->Pate.

You will get two copies of selection. One is at Source and on is at


destination.

5) Paste Special :-

We can paste cut or copied text in some special


format.i.e.rich text, picture, unformatted text, or formatted text using
paste special.

Fundamentals of Computer Operating and Programming 78


C.O.P.A. Trade of I.T.I RD S

6) Clear (Del) :-

This option is used to delete selected text.

7) Select All (Ctrl+A) :-


This option is also used to Select whole document.

Fundamentals of Computer Operating and Programming 79


C.O.P.A. Trade of I.T.I RD S

8) Finding Text :-
We can find a word or text in current document using
Edit->Find.

a) Click Edit->Find Following dialog will appear. If search options are


not visible then click on More button.
b) Type the text which you want to find in 'Find What' text box..

Specify where you want to find i.e. in whole document to up side of


cursor or down to cursor. There are Five options.

1) Match Case :-
This matches small and capital letter.

2) Find Whole Words :-


Matches for whole word not the characters.

Fundamentals of Computer Operating and Programming 80


C.O.P.A. Trade of I.T.I RD S

3) Use Wild Cards :-

This is used to match part of word i.e. done by


using wild card character*and ?

4) Sounds Like :-
This matches pronunciation of word. Know and No are
considered as same match if sounds like is checked.

We can also specify the format of text which we want to


lines then click on 'Find Next' Button. The cursor will get placed at the
place where the match is found.

9) Finding and Replacing the Text :-


If we want to find a particular word and replace it with
another word then.

a) Click Edit-> Replace. The same dialog like fine will appear. All
search options and format are same as they are in find dialog. Only the
difference is that here we can replace the text found, with another word.

b) Type text that you want to find in 'Find What' box and type the word
by which you want to replace in 'Replace with' Text box..

c) To make replacement at a time click on 'Replace' and to make all


replacement at a time click on 'Replace All' Button.

Fundamentals of Computer Operating and Programming 81


C.O.P.A. Trade of I.T.I RD S

10) Go to:-
This option is used to go to particular Page, Book mark, Section,
line Footnote, or Endnote, . Enter the page no.

Fundamentals of Computer Operating and Programming 82


C.O.P.A. Trade of I.T.I RD S

in 'Enter page number' box and click on 'Next' button the cursor will
move to the specified page no. If+5 is given then cursor will move in
forward direction and if sign is given then cursor will move in backward
direction.

Fundamentals of Computer Operating and Programming 83


C.O.P.A. Trade of I.T.I RD S

WORKING WITH VIEW MENU


This menu is related with display of the screen. We can change the
display of screen or document form 'View menu'.

1) Changing View of Document :-

There are four different view available in word.

a) Normal View:-
In this view document gets displayed in normal view. It
will not display margins of page. No separate page gets displayed like in
Print Layout. Background given to document is not visible in Normal
view. A single line gets displayed where page is braked.

Fundamentals of Computer Operating and Programming 84


C.O.P.A. Trade of I.T.I RD S

b) Web Layout :-
This view displays the document, How it will appear
when it gets published on Web. Background is visible in this view. It is
also called as "On line View".

c) Print Layout :-
This view displays document with margins, indents of paragraph.
Vertical Ruler is visible in this view. Background is not visible in this
view. This view is help full in changing document setup or page setup.
This view gives idea about how .It will appear on page after printing.
Generally we always work in Print Layout.

d) Outline View:-
This view is used to display outline of document. When
we click on View->Outline, 'Outline' toolbar gets activated.

If there are different style are applied to different


heading in document then to display heading with particular style
outline view is used.

2) Tool Bars :-
To activate or deactivate various tool bars this option is
use. There are different tool bars available in MS-Word as listed below.

1) Standard
2) Formatting
3) Auto text
4) Control tool box
5) Data base
6) Drawing
7) Forms
8) Outline
9) Picture
10) Reviewing
11) Table and Borders
12) Visual Basic
13) Web
14) Word Art
15) Custom & Customize etc.

Fundamentals of Computer Operating and Programming 85


C.O.P.A. Trade of I.T.I RD S

A check mark will appear in front of name of tool bar which are active.
In MS - Word by default Standard, Formatting and Drawing toolbars are
active.

3) Ruler :-
This option is used to activate or deactivate vertical and
Horizontal Ruler in MS-Word.

4) Document Map :-
The Document Map is a separate pane or area that
displays a list of headings in the document. Document Map is used to
navigate thought the document . When we click on a heading in the
Document Map, Word jumps to the corresponding heading in the
document, displays it at the top of the window, and highlights the
heading in the Document Map.

5) Header and Footer :-


Header is the common part that appear above the top
margin on every page in document. Footer is common part that appear
below the bottom margin on every page of document. In Header and
footer we can give page now, file name, Author name etc. To activate
Header area.

a) Click on View-> Header and Footer.

A Header area gets activated and Header and Footer


toolbar gets activated as shown below. There are different tools
available on this toolbar. We can insert Page no, change format of page
no Date, Time using these tools as shown above. Also we can type an
other text in header or footer are, which will appear on every pave of
document. There is a switch tool on tool bar use for navigation or
switching between header and footer area.

b) Click on Close tool to deactivate header and footer area.

Fundamentals of Computer Operating and Programming 86


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 87


C.O.P.A. Trade of I.T.I RD S

6) Foot Note and End Note :-


These option are used to display Footnote and Endnote
which are inserted in document.

7) Full Screen :-
This inactivate all too bars and display document on Full
Screen.

8) Zoom :-
This is used to display document in different magnified
form.i.e.200%,300% etc. as shown.

Fundamentals of Computer Operating and Programming 88


C.O.P.A. Trade of I.T.I RD S

WORKING WITH INSERT MENU

This menu is used to insert different Objects. Shapes , Clip arts ,


Word arts, Date and Time and Page Break etc. as shown below.

Fundamentals of Computer Operating and Programming 89


C.O.P.A. Trade of I.T.I RD S

1) Break :-
Break option is used to insert page break, section break etc.

a) Click Insert-> Break. Following window will get appear.

There are three break types.

Page break insert a page break where the cursor is placed.


Column Break, break the column where cursor is placed.

Fundamentals of Computer Operating and Programming 90


C.O.P.A. Trade of I.T.I RD S

Text wrapping break end the current line where the cursor is
placed and move cursor to next line.

Also there are four types of section break Next page, Continuous
, Even page, Odd page.

b) Click on Ok button to apply the settings.

2) Page Numbers :-
This is used to insert page numbers in document with
different format and at different locations.

a) Click Insert-> Page Numbers. Following Window will appear.

We can specify the position of Page Number i.e. in Footer area


or Header Area. Page Numbers can be aligned to Left, Right, Center,
Inside or Outside. Preview shows the exact location of page number on
page.

Fundamentals of Computer Operating and Programming 91


C.O.P.A. Trade of I.T.I RD S

3) Date and Time :-


This is used to insert Date and Time where the cursor is
placed.

a) Click Insert-> Date and Time Following window will appear. We can
select date and time format form window.

b) Click on Ok Button to apply the setting. When Update automatically


is checked then date will get automatically updated when document is
printed or accessed.

4) Symbols :-
This option is used to insert different symbols in
document.

Fundamentals of Computer Operating and Programming 92


C.O.P.A. Trade of I.T.I RD S

a) Click Insert-> Symbols. Following window will appear. Change the


font to change different symbols. Select the symbol which you want to
insert in document.

b) Click on Insert Button.

5) Fields :-
This option is used to insert different fields in document
like date, time or different formulas. There are different categories of
fields like date and time formulas. We can select fields in specific
category and click on Ok button to insert that field. i.e. select category
'Date and Time' and field 'Date' as shown in following window and click
on Ok it will insert current date in document.

Fundamentals of Computer Operating and Programming 93


C.O.P.A. Trade of I.T.I RD S

6) Auto text:-
This option is used to insert Auto text. Auto text is text
which you are using frequently in document. e.g. yours faithfully,
respected sir etc.Auto Text offers a way to store and quickly insert text,
graphics, fields, tables, bookmarks, and other items that you use
frequently.

a) Select table, text or object for which you want to create Auto text.
b) Click Insert->Auto text->New.
c) Give simple name for Auto text.

Fundamentals of Computer Operating and Programming 94


C.O.P.A. Trade of I.T.I RD S

This will create auto text with given name which appears in
Normal auto text. When you want to insert this auto text in document.
Then Click on Insert->Auto text->Normal->Auto text name. Then the
corresponding table or text gets automatically inserted in document.

7) Comment :-
Used to insert comments in your document where the
cursor is placed. the inserted comments gets displayed at bottom of
screen if 'Command' option from view menu is checked or activated. A
comment number with yellow color will appear where the comment is
placed.

8) Footnote :-
This is used to insert foot note or end note in document.
Footnote is the note which is inserted at the end of page in document.
End note is the note which is inserted at end of document.

a) Click Insert->Footnote. Following dialog will appear.


b) Select Endnote to insert endnote and select Footnote to insert
footnote.
c) We can also change format of number given to note using ' Format
Number'.

Fundamentals of Computer Operating and Programming 95


C.O.P.A. Trade of I.T.I RD S

9) Caption :-
This is used to give numbers to diagrams, tables inserted in
document.

a) Click Insert->Caption Following dialog will appear.

Select Label from options. Click on New Label to insert new


Label. To automatically start the numbering for particular object like
bitmap image, clip art Auto Caption is used. We can change format of
number using Numbering button. to apply settings click on Ok Button.

Fundamentals of Computer Operating and Programming 96


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 97


C.O.P.A. Trade of I.T.I RD S

10) Picture:-
There are six sub options in picture from Insert Menu.
We can also Insert Clip Art from Drawing Tool Bar using tool Clip art .

a) Clip Art :-
We can Insert different Clip arts from Microsoft Clip Gallery .

i) Click Insert->Picture->ClipArt. This will display following Clip Art


dialog box. Click on the category of the Clip on the category of the Clip
Art and then insert button to insert Clip Art.

Fundamentals of Computer Operating and Programming 98


C.O.P.A. Trade of I.T.I RD S

b) From File :-
To insert a Picture from another file like paint brush file, Corel
draw file etc.

i) Click Insert->Picture-> From File . Following Dialog will appear.


Then select the file which you want to insert and then click on Insert
Button.

Fundamentals of Computer Operating and Programming 99


C.O.P.A. Trade of I.T.I RD S

c) Auto shapes:-
When we click on Insert->Picture->Auto shape. This will
activate Auto shape toolbar. We can insert different Auto shape from
this toolbar. We can also insert auto shape from Drawing Tool bar.

Fundamentals of Computer Operating and Programming 100


C.O.P.A. Trade of I.T.I RD S

d) Word Art:-
We can insert different word art in document. Word Art
can also inserted form Drawing Tool bar using tool.

a) Click Insert->Picture->Word Art. Following dialog will appear.


Select the word art style and click on Ok Button the types the text in edit
word art text dialog box. Select Font, Size . We can also apply Bole and
Italic effect to text. Click on Ok button to insert word art.

Fundamentals of Computer Operating and Programming 101


C.O.P.A. Trade of I.T.I RD S

11) File :-
We can inset a document in another document.

a) Click Insert-> File.


b) Insert file dialog will appear, select filename which you want to insert
and click on Insert button.

12) Object:-

To insert object like pait object, calendar, clip art.

a) Click Insert->Object. Following dialog will appear. If you want to


creat new object then click on 'Create New ' tab. If you want to insert
existing file click on 'Create from file' tab. Select Object type. If
'Display as Icon' is active then object is inserted as icon.
b) Click on Ok button to insert object.

Fundamentals of Computer Operating and Programming 102


C.O.P.A. Trade of I.T.I RD S

13) Bookmark :-
Bookmark is the mark inserted in document. To insert
bookmark in document.

a) Click insert->Bookmark. Following dialog will appear. Give name to


bookmark.
b) Click on Add button to insert in document.
c) To delete inserted book mark, select the bookmark and click on
Delete button.
d) If you want to go to selected bookmark the click on Go to Button.

You can also go to selected bookmark using Edit->Go to-


>Bookmark.

Fundamentals of Computer Operating and Programming 103


C.O.P.A. Trade of I.T.I RD S

14) Hyperlink :-
Hyperlink is the link between to document. Hypertext is the text
on which link is created. We can link two document in word using
Insert->Hyperlink.

a) Click Insert->Hyperlink. Following dialog will appear.


b) Type web site address or file name with path that you want to link.
c) Click on Ok button. The text in format like Text will appear called as
hypertext. Mouse pointer will appear as when you point to hypertext.

Fundamentals of Computer Operating and Programming 104


C.O.P.A. Trade of I.T.I RD S

15) Text Box:-


When you want to insert text in document which you can move
any where in document that can insert be insert in text box. We can
insert text box from drawing tool bar using text box tool. or

a) Click Insert->Text Box. Type the text in text box.

16) Cross Reference:-


If you want to give some details about the table or diagrams
inserted in your document then cross reference is used.

17) Index and Table:-


This is used to create index in your document.

WORKING WITH FORMAT


MENU

Format menu is related with Formatting of text. We can change


fort, font size, effects, colors, bullet style, number style and paragraph
formatting form format menu. Format contains following options.

1) Font:-
To change font, font size etc of text.

a) Select text and click on Format->Font. Following dialog will appear.


There are three tabs available. Font tab is sued to change font, font style,
font size, font color, underline style, color of underline style and
different effects like superscript, subscript, emboss, shadow etc. We can
also make these changes from format tool bar.

Character spacing tab is used to change spacing between tow


character i.e. expanded or condensed. We can change scale and position
of character on line i.e. raised or lowered.

Fundamentals of Computer Operating and Programming 105


C.O.P.A. Trade of I.T.I RD S

Text effect tab is used to apply different text effect like linking
background, shimmer. We can see preview in preview window.

Fundamentals of Computer Operating and Programming 106


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 107


C.O.P.A. Trade of I.T.I RD S

2) Paragraph:-
To change paragraph formatting

a) Select the paragraph which you want to format.

b) Click Insert->Paragraph. Following dialog will appear. There are two


tables in this dialog. Indents and spacing is used to align paragraph as
left, center, justify. We can set left indent, right indent, first line indent
of paragraph. That can also be set from Horizontal Ruler. Spacing
before and after paragraph can be set. Second tab is 'Line and Page
break' is used to keep paragraph continue on one page. To keep all lines
together in a paragraph.

Fundamentals of Computer Operating and Programming 108


C.O.P.A. Trade of I.T.I RD S

3) Bullets and Numbering :-


This tool is used to give bullet or numbers to selected paragraph
in document. We can also apply Bullets and Numbers from Formatting
tool bar.

a) Click Format-> Bullets and numbering. Following dialog will appear.


We can apply different bullet styles from Bulleted tab. We can also
change bulleted style by customizing bulleted. Number tab is used to
apply number in various formats like 1, 2, 3 or a, b, c, etc.

Fundamentals of Computer Operating and Programming 109


C.O.P.A. Trade of I.T.I RD S

4) Borders and Shading:-


This is used to apply borders to paragraph and page.

a) Click Insert-> Borders and shading. Following dialog will appear.


There are three tabs. Border tab is used to apply border to the selected
paragraph. Set the border type, style of line, width or line, color of line
and then click on OK button to apply the settings. Page border tab is
used to apply border to the page. All settings in page border are same as
border tab. Only one addition type of border we can apply to the page
i.e. art type border. Click on Ok button to apply the settings. Shading tab
is used to apply shading to the paragraph. We can fill different colors or
patterns to background or paragraph.

Fundamentals of Computer Operating and Programming 110


C.O.P.A. Trade of I.T.I RD S

5) Columns:-
This option is used to divide the page in columns like News
paper.

a) Click on Format->Columns .Following dialog will appear. We can


divide page different no. of columns. We can adjust no. of columns and
width of column, the spacing between to column will get set
automatically. Line between option is used to apply line between to
columns. Click on OK to apply the settings.

Fundamentals of Computer Operating and Programming 111


C.O.P.A. Trade of I.T.I RD S

6) Change Case :-
This option is used to change the case or selected paragraph or
text.

a) Click Format->Change case. Following dialog will appear. There are


five cases we can apply to the text.

1) Sentence Case :-
In this case first character of each sentence become capital and
all other in small letters.

2) Lower Case :-
In this case all characters appear in small case.

3) Upper Case :-
In this case all characters appear in capital letters.

4) Title Case:-
In this case first character of each word become Capital.

5) Toggle Case:-
In this case all character in Capital form appears in Small letters
and vise versa.

Fundamentals of Computer Operating and Programming 112


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 113


C.O.P.A. Trade of I.T.I RD S

7) Tabs :-
This option is used to give space using tab key. It help in
creation of structure like table without border.

a) Click Format-> Tab following Tab dialog will appear.


b) Give tab stop position 1 and click on set.
c) To apply tab settings click on ok button and to cancel tab settings
click on Clear all.

In following dialog of you set tab at 1" position then if cursor


will move to 1" tab position when tab key pressed on new line, again tab
key is pressed then cursor will move to next tab position. In Ms-Word
there are five types of tabs. Left tab align left, Tight tab align text to
right, Center tab align text to center, Bar tab align text to bar And
decimal tab align decimal point.

Fundamentals of Computer Operating and Programming 114


C.O.P.A. Trade of I.T.I RD S

8) Drop Cap :-
This option is used to make first character of sentence to big
size.

a) Click Format-> Drop cap. Following dialog will appear. There are
two types of drop cap position i.e. Dropped or In margin. Select on of
them. Then set font, no. of lines to drop and distance from text and click
on Ok button to apply settings.

Fundamentals of Computer Operating and Programming 115


C.O.P.A. Trade of I.T.I RD S

9) Background:-
To apply background to the document .

a) Click on Format->Background. A color box will appear select color


for background. To view more click on more color option in
background.

b) We can also fill more patterns using fill pattern option. From
following dialog box select the pattern and color of pattern you want to
fill. There are four tabs. Pattern tab is used to fill pattern. gradient tab is
used to fill different color with different shading style. Texture tab is
used to fill different available texture to page. Texture are some
predefined patterns that we can apply to background of document.
Picture tab is used to apply picture from different software like paint
brush etc.to background of the page.

Fundamentals of Computer Operating and Programming 116


C.O.P.A. Trade of I.T.I RD S

10) Theme:-

Theme is collection of styles applied to hypertext, bullets,


heading1, heading 2, etc. To apply these theme.

a) Click on Format->Theme . Following dialog will appear.


b) Select the theme from given list. Preview is shown there.
c) Click on Ok button to apply the settings.

Fundamentals of Computer Operating and Programming 117


C.O.P.A. Trade of I.T.I RD S

11) Auto format:-


This is used to Auto format the document.

a) Click on Format->Auto format . Following dialog will appear.


b) Select the format which you want to apply to document and click on
Ok button to apply the settings.

Fundamentals of Computer Operating and Programming 118


C.O.P.A. Trade of I.T.I RD S

12) Style:-
This option is used to apply different styles to the document.
Styles have predefined formatting e.g. font, font size, color, margin ,
styles and tabs etc. To apply these styles.

a) Click Format-> Styles. Following dialog will appear. Select the style
Preview of style is shown in preview window.
b) If you want to create new style click on New button. Again a new
dialog will appear. Give new name to style and to set formatting click on
format button.
c) Click on Ok button to apply the setting You will found that the new
style gets added in list of style.

Fundamentals of Computer Operating and Programming 119


C.O.P.A. Trade of I.T.I RD S

WORKING WITH TOOLS MENU

1) Spelling and Grammar:-


This tool is used to find spelling and grammatical corrections in
document and correct it. Spelling and Grammatical tool is also available
on Standard toolbar. When we click on. This tool following dialog will
appear. It shows spelling mistake in red color and grammatical mistake
in green color. There are suggestions given to correct the mistake. Select
the correct one form suggestions and click on change button to make
changes where the mistake found. Change all makes changes in Whole
document where the mistake found. Click on Add button to add that
word in dictionary e.g. name of person or institution. Ignore button will
ignore the mistake and continue. If check grammar is checked then only
computer will search for grammatical mistake otherwise not . F7 is
shortcut key for spelling and grammar.

Fundamentals of Computer Operating and Programming 120


C.O.P.A. Trade of I.T.I RD S

2) Word Count:-
This displays the total characters with or without spaces, Total
no. of lines in document, Total no. of paragraphs and word in document.
If include Footnote and Endnote check box is checked then it include
text in footnote and endnote in counting.

Fundamentals of Computer Operating and Programming 121


C.O.P.A. Trade of I.T.I RD S

3) Auto Summary:-
This option is used to summaries the document. It automatically
takes the sentences relevant to subject in summary. When we click on
Tool->Autosummary.Following dialog will appear. We can take
summary in font types.

1) Highlight Key point highlight key points in yellow color in the


document itself. We can increase or decrease the percentage of
summary.
2) Executive summary is shown at the top to document.
3) New document can be created which contains summary of original.
4) Hide everything in document except summary.

Fundamentals of Computer Operating and Programming 122


C.O.P.A. Trade of I.T.I RD S

4) Auto Correct:-
Auto correct makes some correction as you type the document as
listed below.

a) Correct two initial capitals corrects if two characters are typed in


capital format.
b) If Capitalize first character of the sentence is checked there. It
capitalizes first character of each new sentence automatically.
c) It also capitalize name of days.
d) If accidentally caps lock get on then it off caps lock automatically.
e) Also corrects mistake in typing automatically e.g. about gets replaced
by about etc.

Fundamentals of Computer Operating and Programming 123


C.O.P.A. Trade of I.T.I RD S

5) Language:-
There are three sub options in language.

1) Language:-
Sets the language which helps in spelling and grammar
checking .

2) Thesaurus:-
We can find synonyms for particular word in document.

3) Hyphenation:-
This option hyphenates the document.

6) Track Changes:-
a) This option is used to track the changes in document. Once
you saved the document. Click on Tools->Track Changes->Highlight
track changes. Activate the option to track the changes while editing.
When you edit the document the changes are highlighted in specific
form or style and comment is shown about the changes.
b) To accept the changes Click on Tools->Track Changes->Accept or
Reject the changes.
c) Compare document compares the original document with edited
document. To compare document.

1) Create document and save it.


2) Make some modifications it it.
3) Highlight track changes from Tools->Track Changes->Highlight
track changes.
4) To compare click Tools->Track Changes->Compare documents and
sleect the original file from list.
5) This automatically highlights the track changes or modification done
in original document after saving it.

Fundamentals of Computer Operating and Programming 124


C.O.P.A. Trade of I.T.I RD S

7) Protect Document:-
This option is used to protect document from making changes.
To protect the document click Tools->Protect document following
dialog will appear. Select the option for which you want to protect the
document .One can protect the document from inserting new text,
deleting existing text and inserting password. Password always appears
in form of *. Click on ok button and retype the password in next
window. Click on Ok button . This makes track changes active. This
highlight all changes made in document. One can not accept or reject
these changes without unprotect the document.

Fundamentals of Computer Operating and Programming 125


C.O.P.A. Trade of I.T.I RD S

8) Unprotect Document:-
To unprotect the document click on tool->Unprotect and give the
same password which is given to protect the document. After unprotect
the document one can accept or reject all track changes.

9) Mail-Merge:-
Some time we want to send same letter to different person.
Suppose we want to sent a letter to parents of students informing about
parents teacher meeting. Instead of creating multiple documents. Type a
common to letter and merge the database containing name and address
of parent in it. This will create a separate for each parent.

a) Type the letter and save it.

b) Click Tools->Mail merge. Following mail merge helper dialog will


appear. There are three steps

c) Click on Create->Form letters button. It will ask for window. Click on


active window button.

d) Click on Get data->Create data source window will appear. Remove


the fields which you don't want from list and add the fields which you
want to add. We can also change the order of field using arrows. Click
on Ok button and give name to data source to save it. Then edit the data
source to insert data into it. Enter records in database.

e) Click on Ok button. Then Mail merge tool bar gets activate.

Fundamentals of Computer Operating and Programming 126


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 127


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 128


C.O.P.A. Trade of I.T.I RD S

Insert Merge field contains all fields in data source. Insert the data
fields at appropriate place. View merged data tool shows current merged
record. We can change record using Next, Previous, First or Last tool. to
merge all records or selected records click on Mail merge helper tool.
This will again display mail merge helper window. Click on Merge
button and give range of records which you want to merge and click on
Merge button. You will found a separate letter corresponding to each
record.

In same way, using Mail merge we can create labels and


envelops using data source.

10) Envelops and Labels:-

Fundamentals of Computer Operating and Programming 129


C.O.P.A. Trade of I.T.I RD S

This is used to create envelops and labels. Click on


Tools->Envelops and Labels. This will display following window. To
create envelop click on Envelop tab. To create Label tab. We can add
delivery address and return address from address book. We can Omit
return address. Using options we can change envelop size and position
of address of on envelop . Click on Print button to print the envelop and
click on 'Add to document' to add envelop in current document.

We can print same label on whole page or we can print a


single label. Using option in Label tab we can change label size,
distance between two labels and no, of labels on a single page.

11) Letter Wizard:-


Wizard is a step by step procedure. Letter wizard helps in
creating a letter.

Fundamentals of Computer Operating and Programming 130


C.O.P.A. Trade of I.T.I RD S

a) Click Tools->Letter wizard. Following letter wizard dialog will


appear. There are four tabs. Letter format sets the design of letter i.e.
whether using letter head for printing or not. Date. Line. Recipient Info
tab sets information of the recipient. I.e. Recipient address, Name and
type of letter that whether the letter is formal, informal or business.

Other element tab sets the attention line mailing instruction,


reference line and subject. Sender tab contains the information about the
sender. I.e. senders information, job title etc.

Click on Ok button to apply the settings. This will create a letter


with specified format. Now only type the matter in the letter.

Fundamentals of Computer Operating and Programming 131


C.O.P.A. Trade of I.T.I RD S

12) Macro:-
Macro is a collection of instruction. To create a new macro click
Tools->macro->Record new macro. Now the recording gets started.
Execute all the instruction which you want to copy in macro. Then stop
the recording of macro and save macro.

With some name. When you want to execute same instruction


the instead of going to all instructions Run only the macro from Tool-
>Macro->Macros. Following dialog will appear. Select the macro name
from list and Run the macro to execute all instruction recorded in macro.

Fundamentals of Computer Operating and Programming 132


C.O.P.A. Trade of I.T.I RD S

WORKING WITH TABLE MENU

1) Draw Table:-
This is used to draw table in document. When we click on Table-
>Draw table. Table and Borders toolbar gets activated. As shown below.

We can select the line style, width, color and draw the table.

2) Insert:-
This is used to insert tables, rows, columns etc. There are five
sub menus.

a) Table: -
This option is used to insert table with required no, of
columns and rows. When we click Table->Insert->Table. Following
dialog will appear. Give No. of columns, no. of rows and behavior of the
table and click on Ok button to insert the table.

Fundamentals of Computer Operating and Programming 133


C.O.P.A. Trade of I.T.I RD S

b) Columns to left insert columns to left side of column where the cursor
is placed.

c) Columns to right insert columns to right side of the columns where


the cursor is placed.

d) Similarly we can insert rows to above and blow of the row where the
cursor is placed.

e) Cells:-
We can insert cells in table. for that we have to insert
whole row or column or we have to shift current cell to below or right of
the current cell. Click Table->Insert->Cells shows following dialog.
Specify where to shift current cell and click on Ok button to insert the
cell.

Fundamentals of Computer Operating and Programming 134


C.O.P.A. Trade of I.T.I RD S

3) Delete:-
This option is used to delete specified no. or selected rows or
columns or cell. We can also delete the whole tables.

When we delete the cell it will ask for where to shift cell either
on up or left as shown below. Specify where to shift cells and click on
Ok button to delete the cell.

4) Select:-
This is used to select table, row, columns or cells.

5) Split Cell:-
To convert single cell into multiple cells split cell is used. Click
Table -> Split cell following dialog will appear. Give no. of columns
and rows to split the cell and click on ok button.

6) Merge Cells:-

Fundamentals of Computer Operating and Programming 135


C.O.P.A. Trade of I.T.I RD S

To convert multiple cells into single cell Merge cells option is


used. To merge cell Select multiple cell and click Table->Merge cell.
All cells get merged and you found only single cell.

7) Spilt Cell:-
To convert single cell into multiple cells spilt cell is used. Click
Table->Spilt cell following dialog will appear. Give no. of columns and
rows to split the cell and click on ok button.

Fundamentals of Computer Operating and Programming 136


C.O.P.A. Trade of I.T.I RD S

8) Auto Format:-
There are some predefined formats which we can apply to the
table using Auto format. To apply formatting to table.

a) Select the table.


b) Click->Table->Auto format
c) Select format. Specify formatting which you want to apply and where
you want to apply.
d) Click on Ok button to apply formatting.

9) Auto fit:-
This option is used to adjust width of column and table.

a) Auto fit to content:-


Adjust width of column according to contents of column.

b) Auto fit to window:-


Adjust width of table according to size of window.

c) Fixed column width:-


Fixes width of column.

d) Distribute rows evenly:-


Make height of each row to same size.

e) Distribute column evenly:-


Makes width of each column to same size.

Fundamentals of Computer Operating and Programming 137


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 138


C.O.P.A. Trade of I.T.I RD S

10) Convert: -
We can convert text to table and table and table to text.

a) To convert table to text Click Table->Convert->Table to text.


Following dialog will appear. Specify the how to separate the text in
each column. Click on Ok button you found that the table gets converted
in text separated by given character or specification.

Fundamentals of Computer Operating and Programming 139


C.O.P.A. Trade of I.T.I RD S

b) To convert text to column click. Table->Convert->Text to table


following dialog will appear. Specify no. of columns and how the text is
separated and how to adjust column width in table. Click on Ok button
to convert text in to table.

Fundamentals of Computer Operating and Programming 140


C.O.P.A. Trade of I.T.I RD S

11) Sort:-
Sorting means arrangement records on a particular order i.e.
ascending or descending order. We can sort table according to order to
primary key or any field in table. To sort the table. Select the table.
Click Table ->Sort. Following dialog will appear. Select the field
according to which you want to sort the table e.g.sr.no.or name and
specify the order.

Give second field for sorting. If some contents are same in sort
by field then it will get sort by then by field specified next. Specify the
order of sorting. This sort the table.

12) Formula:-

Fundamentals of Computer Operating and Programming 141


C.O.P.A. Trade of I.T.I RD S

This is used to insert formula in table. We can perform some


numeric or logical operation on contents of table. We can find sum,
maximum or minimum between cells to left, right, above or down of the
current cell. To insert formula in cell Click Table->Formula following
dialog will appear. Select the function from Paste function. Number
format and specify from which side you want sum or value of formula.
Click on Ok button to insert formula.

13) Hide Gridline:-


We can apply border to the table. When border is not applied to
table then the lines in gray color appear on screen but not appear on
appear while printing are called as gridlines. To display these gridlines
click Table->Show Gridlines. To hide gridlines Click Table->Hide
Gridlines.

14) Table Properties:-

Fundamentals of Computer Operating and Programming 142


C.O.P.A. Trade of I.T.I RD S

To specify position of text in cell, height of row, width of


column we have to set table properties. Click Table->Table properties.
Following dialog will appear. There are four tabs. Table tabs sets
alignment and wrapping effect of table. Row tab sets height of row.
Column tab specify width of column and cell tab specify position of text
in cell.

INTRODUCTION TO MS-EXCEL
Ms-Excel is spread sheet software. This is used to create sheets
where numeric calculations are required e.g. salary sheet, mark sheet
etc. It is a part of MS-Office.

 Starting MS-Excel:-

Fundamentals of Computer Operating and Programming 143


C.O.P.A. Trade of I.T.I RD S

To start excel Click on Start->Programs->Ms-Excel.


Following excel window will appear. This window contains 'Title Bar'
which contains name of file. In excel by default file name is 'Book1.xls'
where book1 is file name and .xls is extension. Menu bar contains
different menus. All menus are almost same as we have seen in MS-
Word. Only some changes are there that we will see. Standard tool bar is
used to work with file like create, open, save undo etc. Formatting tool
bar is related with formatting text i.e. font, font style etc.

One new bar i.e. Formula bar is displayed on this screen as


shown above. This contains address of cell and displays contains of cell.

Fundamentals of Computer Operating and Programming 144


C.O.P.A. Trade of I.T.I RD S

1) Sheets:-
There are three sheets in a book. We can insert 256 sheets in a
file. A sheet contains rows and columns. There are 65536 rows and 256
columns on on sheet. A, B, C ... IV are the name given to column. 1, 2,
3, ... 655536 are name given to row Intersection of one row and one
column is called as cell. Each cell has address shown on formula bar. A
cell address is combination of name of row Intersection of one row and
one column is called as cell. Each cell has address shown on formula
bar. A cell address is combination of name of row and column. A1 is
address of first cell. Group of more than one cell is called as range.
Address of range is given by address of first cell and address of last cell.
A1: C5 is range include cell from A1 to A5, B1 to B5 and C1 to C5. A
cell may contain numeric or string value of formula.

2) Auto Complete:-

Fundamentals of Computer Operating and Programming 145


C.O.P.A. Trade of I.T.I RD S

Suppose a list is present in column. If you want to fill same value


as a next item in list then type the initial value in cell it show and
complete the same data present in list automatically as shown.

3) Auto Fill:-
In excel type Sunday or any day name in a cell. Place mouse
pointer on fill handle and drag it. It will automatically fill name of days
in sequence as shown below. In same way we can also fill series of Jan ,
Feb , Mar etc.

4) Giving Values in a Cell:-


A cell may contain numeric, alphabetic value or formula.
Numeric value is always right aligned and Alphabetic value is always
left aligned. A formula can be given in cell. This formula always start
with = sign.+ is used for addition , * is used for multiplication , - is used
for subtraction and / is used for division. We can also copy the formula
from above cell to below cell by dragging fill handle as shown above.
When we put mouse point on this fill handle it appear as +.

Working With File Menu:-


As we know file menu always related with opening,
closing ,saving file etc.

• Creating New File:-


To create new book in excel click File->New . Select workbook
and click on 'Ok'button to open new workbook. Each file in excel is
called as workbook. Ctrl+N is shortcut key to create new workbook.

1) Saving New Workbook:-


We know that to save work book with new name click on
File->Save as. To save modifications in work book click File->Save.
Ctrl+S is shortcut key to save work book. We can save workbook. We
can save workbook from save tool on standard toolbar. To save the
workbook as webpage click File->Save as webpage.

2) Open Existing Workbook:-


To open existing work book click File->Open. Select the
name of workbook from appropriate path and click on 'Open' button to
open it. Ctrl+O is shortcut key to open Workbook.

Fundamentals of Computer Operating and Programming 146


C.O.P.A. Trade of I.T.I RD S

3) Close:-
Click File->Close to close workbook.

4) Save as Workspace:-
Some times we want to open number of workspaces at a
time. Then we save that workbooks as workspace.

a) Open multiple workbooks.

b) Click File->Save as workspace and give name to workspace.

When you open this work space from File->open all the
workbooks in the workspace get open.

5) Setting Page:-
To set paper size, margin header and footer click File->Page
setup. Following dialog will appear. There are font tabs. Page tab is used
to set orientation of page, paper size, zooming percentage and printing
quality. Margin tab is used to set Top, Left, and Right, Bottom and
Header and Footer margin of the page. Header and Footer tab is used to
set header and footer or the page. We will see this in next chapter.

Sheet tab is used to set print area page order and printing
options.

Fundamentals of Computer Operating and Programming 147


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 148


C.O.P.A. Trade of I.T.I RD S

6) Setting Print Area:-


To print a particular range of cells or area on sheet set it as print
area . Select multiple cell or range click File->Print area. To clear print
area. Click
File -> Clear print area.

7) Print Preview:-
We can see the page before printing called as print preview.

8) Printing Sheet:-
To print the pages or sheet click File->Print. Ctrl+P is shortcut
key for print. Following dialog will appear. Set the printer, ranges and
specify what you want to print i.e. selection, sheet or entire workbook.
Specify no, of copies to print and click on 'Pint ' button to print the page.

Fundamentals of Computer Operating and Programming 149


C.O.P.A. Trade of I.T.I RD S

WORKING WITH EDIT AND VIEW


MENU IN EXCEL

 Edit Menu:-

As we have seen in word edit menu is related with


editing modifying workbook, undo, cut, copy, paste are same as we have
seen in word.

1) Undo (Ctrl+Z):-
This is used to cancel the action.

2) Redo (Ctrl+Y):-
This is used to repeat the action.

Fundamentals of Computer Operating and Programming 150


C.O.P.A. Trade of I.T.I RD S

3) Cut (Ctrl+X) Paste (Ctrl+V):-


When we want to move cells select the cells. Click Edit-
>Cut and place the cursor where you want to move the text. Click File-
>Paste.

4) Copy Cells:-
When we want to copy cells the select the cells click edit-
>Copy and select the cell where you want to paste. Click Edit->Paste.

If the cell contains formula then formula get copied.

5) Filling Contents:-
We can fill the contents of cell in row or column. To fill
the contents to down side then select the cell containing the value and
select the column in down or up direction and click Edit->Fill->Down or
UP. To fill the contents to left or right side then select the cell
containing the value and select the row toward left or right side and
click Edit->Fill->Left or Right.

Fundamentals of Computer Operating and Programming 151


C.O.P.A. Trade of I.T.I RD S

6) Filling Series:-
To fill series select the cell containing starting value and
then click Edit->Fill->Series. Following dialog will appear.

Select rows or column where you want to fill the series. There
are four types of series.

Fundamentals of Computer Operating and Programming 152


C.O.P.A. Trade of I.T.I RD S

a) Linear Series:-
In this series step value gets added in starting value or previous
values. e.g. if starting values is 2, setup value is 2 and stop value is 14
then series gets filled is 2,4,6,8,10,12,14.

b) Growth Series:-
In this series starting or previous value gets multiplied by step
values. e.g. if starting values is 3, step value is 2 and stop value is 14
then series gets filled is 3,6,12.

c) Date Series:-
In date series step value gets added in day , year or month of date
as per your selection . e.g. if starting date is 2/2/04, step value is 2 date
unit is month then series gets filled is 2/2/04,4/2/04,6/2/04,.... etc. Stop
value specifies the ending value. Click on Ok button fill the series.

7) Clear:-
There are four options.

a) All:-
This clears all i.e.formating, contents and comments.

b) Formats:-
This clears formatting of cell but content and comments remains
as it is.

c) Contents:-
This clears content of cell but formatting and comments
remains remains it is.

d) Comments:-
This clears comments but content and formatting remain as it is.

8) Delete:-
To delete cell or range of cell click Edit->Delete. Following
dialog will appear. Shift cells left means shift the contents from right
side cells to left. Shift cells to up means shift the contents of cells to Up

Fundamentals of Computer Operating and Programming 153


C.O.P.A. Trade of I.T.I RD S

means shift the contents of cells from down to up. Delete entire row or
column. Select one of the option and click on Ok button to apply.

9) Delete Sheet:-
To delete current sheet Click Edit->Delete sheet.

Fundamentals of Computer Operating and Programming 154


C.O.P.A. Trade of I.T.I RD S

10) Move or Copy Sheet:-


To move or copy current sheet Click Edit->Move or Copy sheet.
Following dialog will appear. Specify the location i.e. file, and before
sheet where you want to move the current sheet. Click on Create a copy
to create copy of current sheet. And Click on Ok button to apply the
settings.

Fundamentals of Computer Operating and Programming 155


C.O.P.A. Trade of I.T.I RD S

11) Finding and Replacing Text:-


To find particular text click Edit->Find and specify the word
which you want to find as we have seen in MS-Word. To replace the
text with another Click Edit->Replace and specify old and new word
and Click 'Replace' button to replace old text with new.

12) Go to:-
To locate the particular cell Click Edit->Goto.Following
dialog will appear. Specify the reference or cell address that you want to
locate and click on 'Ok' button.

Fundamentals of Computer Operating and Programming 156


C.O.P.A. Trade of I.T.I RD S

 View Menu :-

This menu is related with view or display of screen. Let


us see options in View menu.

1) Views in Excel:-
There are two different views available in excel. In
Normal view no different pages are shown on sheet. In Page break
preview different pages are shown on sheet.

2) Tool bar, Formula bar, Status bar:-


To show or hide toolbars use View->Toolbar. To show or
hide Formula bar Click View->Formula bar. To show or hide status bar
Click View->Status bar.

3) Header and Footer:-


To set header and footer Click View->Header and Footer.
Following page setup dialog will appear. In that Click Header and footer
tab. To customize header Click on 'Customize header' button again
following dialog will appear. Make the settings for header in left right
and center section. Insert text, total no. of pages, page no. , Date and
time, sheet name and book name. Click on 'Ok' button to apply the
settings. Do same for customize Footer of page.

4) Comments:-
To display comments on screen Click View->Comments.

5) Full screen:-
To display book on full screen Click View->Full screen.

Fundamentals of Computer Operating and Programming 157


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 158


C.O.P.A. Trade of I.T.I RD S

6) Custom views:-
To create different views in excel Click View->Custom views.
Following dialog will appear. Click on 'Add' button to create new view.
Give name to view. Click on 'Show' button to display book in
customized view.

Fundamentals of Computer Operating and Programming 159


C.O.P.A. Trade of I.T.I RD S

WORKING WITH INSERT MENU


Insert menu is related with inserting cells, columns, rows, charts
and functions in book.

1) Inserting Cells:-
Click Insert->Cells to insert new cell where the cursor is
placed. Specify whether to insert new row or column or to shift current
cell to right or down side. Click on Ok button this will insert new blank
cell instead of current cell.

Fundamentals of Computer Operating and Programming 160


C.O.P.A. Trade of I.T.I RD S

2) Inserting Rows:-
To insert multiple rows or single row, Select multiple or single
row and Click Insert->row.

3) Inserting Columns:-
To insert multiple columns or single column select
multiple or single column and click Insert->Column.

4) Inserting Sheet:-
To insert sheet in book Click Insert->Worksheet. You found that
the new sheet get inserted into book before the current sheet.

5) Inserting Chart:-
We can insert chart or represent table in graphical format. To
insert chart follow give steps.

a) Create following table in excel.

Sr.No. Name Sub1 Sub2 Total


1 Pradhyana 78 77 155
2 Vasanti 56 55 111
3 Madhuri 34 44 78
4 Rasika 25 35 60
5 Gavari 65 65 130

Fundamentals of Computer Operating and Programming 161


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 162


C.O.P.A. Trade of I.T.I RD S

b) Click Next button. Following window will appear. give data range i.e.
select table or specific column. Select name column and press Ctrl
button and select Total Column Click on Next button. Following
window will appear. Give Title to chart, information about axe, Position
of legend, table and label. Click on Finish button to

Fundamentals of Computer Operating and Programming 163


C.O.P.A. Trade of I.T.I RD S

Complete and finish the chart. Following chart will get inserted in table.

Fundamentals of Computer Operating and Programming 164


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 165


C.O.P.A. Trade of I.T.I RD S

6) Inserting Fountain in Cell:-

Using Insert->Function we can insert different functions in


formula in a cell. We can directly type the function in a cell. Following
are some common functions used.

Each function must start with = sign

a) Sum ( ):-
This function is used to add contents of given cell address
of given values.

e.g. = sum (A1:E5) : Adds contents of cells from A1 to E5

= sum (45, 45, 10) gives result 100

b) Average ( ):-
This function is used find out average of given values or
cell contents.

=Average (90,10) gives 50

c) Max ( ):-

This function returns maximum value in give range or values .

= Max (A1:A5)

d) Min ( ):-
This function returns minimum value in given range or values.

= Min (78, 34, 23) returns 23

e) Count ( ):-
This function returns no. of cells containing number values in
given range.

f)Counta ( ):-

Fundamentals of Computer Operating and Programming 166


C.O.P.A. Trade of I.T.I RD S

This function return no, of cells containing any values except


blank cells in given range.

g) Char ( ):-
This function returns character represented by given number.

= Char (36) returns $

h) Len ( ):-

This function returns length of given string.

= Len ("Rudrani") returns 7

i) Upper ( ):-
This function returns length of given string.

e.g. = Upper ( "Pallavi") will return "PALLAVI"

j) Lower ( ):-
This functions returns given string in lower letters.

e.g. = Lower ("Pallavi") will return "pallavi".

k) If (Condition, True, False):-

This function is used to check given condition and display result


according to value of condition. This condition should be logical
condition returns True or False.

e.g. = If (E5>35,"Pass","Fail") Here if contents of E5 is greater than 35


then Pass will appear else Fail will appear. we can also using nested if as
given below.

=If (E5<35,"Fail", If (E5<50,"C",If

E5<65,"B".If (E5<75,"A","Dist")))) If within another if is called a


nested if. Above given function satisfies all following conditions.

Fundamentals of Computer Operating and Programming 167


C.O.P.A. Trade of I.T.I RD S

If Per<35 then Grade is Fail

If Per>=35 and Per<50 then Grade is C

If Per>=50 and Per<65 then Grade is B

If Per>=65 and Per<75 then Grade is A

If Per>=75 Grade is Dist

 Logical conditions:-

We want to check multiple conditions at a time then this logical


function are used.

1) And ( ):-
This function returns value "True' When all given conditions are
true. All conditions are separated by Comma (,).

=And (A1<35, B1<35, C1<35)

2) Or ( ):-
This function returns value "False' When all given conditions
are false.

=Or (A1>35, B1>35, C1>35)

3) Not ( ):-
This function returns value 'True" if given condition is false and
vice versa.

=Not (A1=35)

Condition 1 Condition 2 And


Or

T T T
T

Fundamentals of Computer Operating and Programming 168


C.O.P.A. Trade of I.T.I RD S

T F F
T

F T F
T

F F F

7) Working with Names:-


We can give name to specific range or spefic
formula.

Name a cell or range. Select the cell where the formula is given
Click Insert->Name and give name to formula. To paste the formula in
another cell give = sing and name given to formula.

Name given to range always appear at name box when same


range get selected. We can use cell name in formula instead of cell
address.

Fundamentals of Computer Operating and Programming 169


C.O.P.A. Trade of I.T.I RD S

WORKING WITH FORMAT MENU


Format menu is related with formatting of cells, column,
rows, sheets etc.

1) Formatting Cell:-
To format cell or cells select range or cell. Click Format-
>Cells. Following dialog will appear. There are total six tabs. Number
tab specifies alignment of text in a cell. Font tab is used to specify font,
font size, font style color of text. Border tab is used to set border of cell
or selected range. Pattern tab is used to fill different patterns in cells.

Fundamentals of Computer Operating and Programming 170


C.O.P.A. Trade of I.T.I RD S

2) Formatting Rows:-
We can change height of row using Format->Row-
>Height. We can hide or unhide rows.

3) Formatting Columns:-
We can change width of column using Format->Column-
>Width. We can hide or unhide columns.

4) Formatting Sheet:-
We can change name of sheet using Format->Sheet-
>Rename. We can hide or unhide sheet in a book. We can apply
background to sheet using Format->sheet->Background.

5) Auto Format:-
Select table. We can apply different predefined formats
to table using Format->Auto format. Following window will be appear.
Select any format according to your choice and click on Ok button and
apply it to selected table.

Fundamentals of Computer Operating and Programming 171


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 172


C.O.P.A. Trade of I.T.I RD S

6) Conditional Formatting:-
We can change formatting of cell or contents in cell according to
condition. To do this click Format->Conditional formatting. Following
dialog will appear. Give the condition that what should be the value of
cell. or what should be the formula in cell. Click on Format button and
Set the formatting to apply when condition gets satisfied and click on
Ok button to apply conditional formatting. To add another condition
click on Add button and to delete the condition click on Delete button.

7) Applying Styles to Cell:-


To apply new styles to cell select cell or range of cell.
Click Format->Style. Following dialog will appear. To apply existing
style select style name from given list and click on Ok button. To create
new style give new style name and click on Add button and click on
Modify button to make changes in new style.

Fundamentals of Computer Operating and Programming 173


C.O.P.A. Trade of I.T.I RD S

WORKING WITH TOOLS AND DATA


MENU

 Tools Menu:-

1) Protecting Workbook and Sheet:-

To protect sheet click Tools->Protect->Sheet. Following


dialog will appear. Specify protect worksheet for contents objects and
scenarios. Give password. Click on Ok button. Retype password and
click on Ok button to protect the worksheet.

Fundamentals of Computer Operating and Programming 174


C.O.P.A. Trade of I.T.I RD S

To protect workbook click Tools->Protect->Protect Workbook.


Following dialog will appear. Specify protect workbook for structure
and window. Give password. Click on Ok button and retype the
password and click on Ok button to protect the workbook.. To unprotect
the workbook and sheet again click Tools->Protect->Unprotect sheet
and workbook and type the correct password previously given.

Fundamentals of Computer Operating and Programming 175


C.O.P.A. Trade of I.T.I RD S

2) Goal Seek:-
This option is used to set value of cell to particular value by
changing the value of another cell whose reference is given in formula.
Select the cell containing formula. Click Tools->Goal seek. Following
dialog will appear. give the reference of cell containing formula in Set
Cell. Give the value in To value box (i.e. Target value) Give reference
of cell that contains the value that you want to adjust. Click on Ok
button.

Fundamentals of Computer Operating and Programming 176


C.O.P.A. Trade of I.T.I RD S

3) Creating Scenarios:-
Click Tools->Scenario. Following dialog will appear. Click on
Add button. Again Edit Scenario dialog will appear Give name to
scenario and reference of cell that you want to change. Click on Ok
button. Enter values for changing cell. Click on Ok button. Click on
show button in Scenario Manager Dialog to show the scenario.

Fundamentals of Computer Operating and Programming 177


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 178


C.O.P.A. Trade of I.T.I RD S

4) Auditing in Excel:-
Auditing means locating cells that proved values to formula.

Fundamentals of Computer Operating and Programming 179


C.O.P.A. Trade of I.T.I RD S

1) Select the cell containing formula. Click Tools->Auditing->Trace


precedents. It will shows the cells on which current cell is depend.

2) Select the cell click Tools->Auditing->Trace Dependents. It will


shows the cells that depends on current cell.

3) Select the cell containing error value. Click Tools->Auditing->Error.


It will shows possible cells responsible for error.

4) Click Tool->Auditing->Show Auditing Toolbar. Following toolbar


will appear.

5) Remove all arrows hides all auditing arrows.

6) Circle invalid data:-


This option is used to circle invalid data in given range.

Fundamentals of Computer Operating and Programming 180


C.O.P.A. Trade of I.T.I RD S

 Data Menu:-

Fundamentals of Computer Operating and Programming 181


C.O.P.A. Trade of I.T.I RD S

1) Sort:-
This option is used to sort table in ascending or descending
order. Click Data->Sort. Following dialog will appear. Click on Header
row to display heading of row in sort by. Specify the column name and
order. This will arrange contents of column or table according to
specified column in ascending or descending order. A-Z is ascending
and Z-A is descending. To sort table according to two columns specify
second column name in .Then by box and order and click on Ok button.

Fundamentals of Computer Operating and Programming 182


C.O.P.A. Trade of I.T.I RD S

2) Filter:-
Filter means way to find data quickly and easily. Filtered
list contains the data that matches given criteria. Select the list. Click
Data->Filter->Auto filter. A filter gets attached to each column in
table.i.e. Click on this down arrow or filter and specify the criteria. List
data satisfying criteria gets displayed.

Fundamentals of Computer Operating and Programming 183


C.O.P.A. Trade of I.T.I RD S

3) Form:-
Select the table click Data->Form. A form containing all fields in
table gets displayed as shown below. We can add, deleted, find records
using this form in table.

Fundamentals of Computer Operating and Programming 184


C.O.P.A. Trade of I.T.I RD S

4) Subtotal:-
Subtotal is used to find sum according to another value.i.e.in
following example we want to find total sale of each COM. separately.
Then sort the table according to comp name then Click Data->Subtotal.
Following dialog will appear. Specify column name to find subtotal.
Select the field that you want to sum and click on Ok button to find
subtotal. You will get total of sale according to company name.

Name to find subtotal. Select the field that you want to sum and
click on Ok button to find subtotal. You will get total of sale according
to company name.

Fundamentals of Computer Operating and Programming 185


C.O.P.A. Trade of I.T.I RD S

5) Validation:-
This is used to apply some condition to check entered data is
valid or invalid. Select the range where you want to

Apply validation criteria. Click Data->Validation. Following


dialog will appear. There are three tabs. In setting. Give the condition
that you want to check while validating criteria. In Input Message give
input massage and Give error message in Error Alert box. Click on Ok
button to apply. Input message get always appeared on cell where
validation is applied. If invalid data is entered then error message get
displayed.

Fundamentals of Computer Operating and Programming 186


C.O.P.A. Trade of I.T.I RD S

6) Text to Column:-
Suppose Field name are given in cell and you want to make it
separate as shown below. Click Data->Text to column. Following dialog
will appear. Click on

Fundamentals of Computer Operating and Programming 187


C.O.P.A. Trade of I.T.I RD S

Delimited and click on Next button. Again next screen appear.


Specify delimiter click on next button and then on Finish button you
find the text get separated in different column.

Fundamentals of Computer Operating and Programming 188


C.O.P.A. Trade of I.T.I RD S

7) Consolidate:-
Consolidate is used to add values in corresponding cell from
different references on different sheet. Click Data->Consolidate.
Following dialog will appear. Select range of cell as

First reference and add it. Then select second reference and add
it and click on ok button to find sum of corresponding cell values in
references at destination.

Fundamentals of Computer Operating and Programming 189


C.O.P.A. Trade of I.T.I RD S

8) Pivot table:-
Pivot table is gives all summary reports or reports according to
our choice. Consider following table.

Sr.No. Name of Company District Location Sale


1 Bajaj Pune Chakan 2000
2 Bajaj Pune Chakan 3000
3 Dial A'bad Waluj 4000
4 Dial Pune Kothrud 1000
5 Bajaj A'bad Waluj 2000
6 Rucha A'bad Cthana 4500
7 Rucha Pune Chakan 6500
8 Dial A'bad Waluj 3400
9 Bajaj A'bad Waluj 2900
10 Bajaj A'bad Waluj 3000

Fundamentals of Computer Operating and Programming 190


C.O.P.A. Trade of I.T.I RD S

Click Data->Pivot table Click Microsoft Excel list and Pivot


table. Click on next button. Again step 2 dialogs will appear. Select Data
range and click on Next button. Step 3 dialog will appear. Click on
Layout button and set layout of table as shown below Drag and drop;
Name of comp button at page. Location at Row, District at column and
sum of sale at data and click on Ok Button. You found a pivot table as
shown below on sheet. We can see reports according to company name
area, location and sale and total sale.

Fundamentals of Computer Operating and Programming 191


C.O.P.A. Trade of I.T.I RD S

 Freeze Pane:-
Freeze Pane freeze left and up area of selected cell.

Help menu is excel provides help about excel.

Fundamentals of Computer Operating and Programming 192


C.O.P.A. Trade of I.T.I RD S

INTRODUCTION TO MS-POWERPOINT

Ms-PowerPoint is presentation software. It is very important


software in Ms-Office. We can create presentation for seminars,
meetings etc in Ms-PowerPoint. There are so many facilities give which
are used to make your presentation very powerful and attractive.

 How to Start Power Point:-


To start PowerPoint click Start->Ms-PowerPoint.
Following window will appear. There are three options give to create
presentation.

Fundamentals of Computer Operating and Programming 193


C.O.P.A. Trade of I.T.I RD S

1) Auto Content Wizard:-


When we select Auto Content Wizard to; create presentation.
Following window will appear. There are five steps in auto content
wizard. Click on Next button and select the presentation type that you
want to create. Again click on Next button and select how you want
output. Again click on next button. and give presentation title and footer
of style. Again click on next button and the to create presentation click
on Finish button. The wizard can

Also be activated by click File->New->Auto content wizard. When we


create presentation using auto content wizard a presentation gets created.
This presentation give s clue points which we can add in presentation.
Or explain the points which are given on slide.

Fundamentals of Computer Operating and Programming 194


C.O.P.A. Trade of I.T.I RD S

2) Design Template:-
If we want to apply a template to blank presentation the select
design Template option from above window or click on File->New-
>Select Design template tab from new window.

3) Open Existing Presentation:-


This option is used to open existing or already created
presentation. Select the path of file which you want to open and then
click on open button to open existing presentation.

This can be also done from File->Open and select the


presentation that you want to open.

4) Blank Presentation:-
This option is used to create presentation according to your own.
A Following dialog will appear which ask for slide layout. Select the
slide layout. There are 24 layouts available. Click on Ok button to insert
the slide and presentation. A presentation is collection of no. of slides.

Fundamentals of Computer Operating and Programming 195


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 196


C.O.P.A. Trade of I.T.I RD S

 Saving Presentation:-

a) Save as:-
As we have seen in Ms-Word to save a new presentation with
new name Click on File->Save As. Give name to presentation. By
default in PowerPoint presentation name is 'Presentation1.ppt' where
.ppt is extension.

b) Save:-
To save modification in PowerPoint Click File->Save.

c) Save as Web Page:-


To save the presentation as web page Click File->Save as web
page.

 Setting and Printing presentation:-


a) To see the preview of presentation Click on File->Webpage preview.
This will show preview of slide in Internet Explore.

b) To set width and orientation of slide click on File->Page Setup.


Following dialog will appear. Set the slide size, orientation and
orientation in Notes and hand out.

Fundamentals of Computer Operating and Programming 197


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 198


C.O.P.A. Trade of I.T.I RD S

c) To print the presentation Click File->Print. Following dialog will


appear.

Select the printer, Print range, No. of copies, What you want to print i.e.
handouts or notes pages, No. of slide on one handout, Gray scale, Pure
black and white etc. and click on Ok to print.

PowerPoint window also contains Standard toolbars, formatting


toolbar drawing toolbar same as we have seen in Ms-Word.

Fundamentals of Computer Operating and Programming 199


C.O.P.A. Trade of I.T.I RD S

EDITING AND VIEWING


PRESENTATION

 Editing Presentation:-
To edit or modify Edit Menu is used. There are some option like
undo, redo some as in Ms Word.

1) Cancel and Repeat the Action:-

a) To cancel the current action in presentation Click Edit->Undo or use


shortcut key Ctrl+Z

b) To repeat the canceled action in presentation Click Edit->Redo or use


shortcut key Ctrl+Y

2) Move or Copy Object or Slide:-

a) To Move this slide or object on slide select the object or slide, Click
Edit->Cut and place the cursor where you want to paste or move the
slide or object and click Edit->Paste.

b) To copy the object or slide select the object or slide Click Edit->Copy
and place the cursor where you want to paste or copy the slide or object
and click Edit->Paste.

3) Deleting and Selecting Slide:-


To select all slides click on Edit->Select all.

To delete the slide select the slide and then click Edit->Delete or press
Del key from keyboard.

4) Duplicate Slide:-
To make duplicate slide of current slide Click Edit->Duplicate.

Fundamentals of Computer Operating and Programming 200


C.O.P.A. Trade of I.T.I RD S

5) Find and Replace:-


To find particular word Click Edit->Find. Following dialog will
appear. Give the word which you want to find in 'Find What' and click
on 'Find Next' button. If you want to replace that word with another then
type that word in 'Replace with' and click on 'Replace' button. 'Match
case ' matches lower and upper case.' Find whole words only' Check for
whole word.

Fundamentals of Computer Operating and Programming 201


C.O.P.A. Trade of I.T.I RD S

 Viewing Presentation:-
View menu contains all the options which allows to display
presentation in different formats.

1) Views in PowerPoint:-
There are font views available in PowerPoint

a) Normal:-
In Normal View three areas gets appeared on screen. They are
called as pane i.e. Outline pane, Slide pane and Notes pane. Outline
pane shows outline view of slides or all text on slide. Slide pane shows
how the contents of slide appear in slide show and Notes pane contains
the notes of r speaker. By default any view Click View->Normal or
press Normal view tool given at down left corner of screen .

b) Slide Sorter View:-


In this view all slides in presentation gets appeared at a time on
screen as shown below. So that you can change the order so Slide in
presentation. We can see transition effects on screen. Click View->Slide
Sorter View to display presentation in slide sorter view.

c) Notes Page View:-


In this view slide gets appear on screen with notes page. We can
add notes for speaker on this notes page. Click on View->Notes page
to ,display presentation in Notes page view.

d) Slide Show:-
This is used to show slides on full screen.

Fundamentals of Computer Operating and Programming 202


C.O.P.A. Trade of I.T.I RD S

 Setting Master Slides:-


If we want to apply some effects to all slides then set that effect
to master slides. The settings of Master slides get automatically applied
to all slides in presentation.

a) Slide Master:-
Click View->Master->Slide Master. Following master slide
appear on the screen. Here we can set Date, Footer and Slide Number on
slide. Also we can set format of title on style and objects on slide. the
object or background given to slide master will get automatically
applied to all slides in presentation.

b) Handout Master :-
To set settings for handout (no. of slides on one page) Click
View->Master->Handout. Following Master handout will appear on
screen. Also Handout Master toolbar will on screen. Set header area,
date Area, Footer area and Numbers area. Also set numbers of slides on
handout from handout master tool bar.

c) Notes Page Master :-


To set setting on master notes page click view->Master->Note
page. Following Master notes page gets appear on screen. Set Header
area, Date Area Footer and Number area. All settings will applied to all
notes pages in presentation.

Fundamentals of Computer Operating and Programming 203


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 204


C.O.P.A. Trade of I.T.I RD S

 Other Options in View Menu:-

1) Black and White:-

To display presentation in black and white format Click


View->Black and White.

2) Slide Miniature:-
This displays slide miniature window as shown below on screen.
Click->View ->Slide Miniature. This option is active only in Notes page
view.]

3) Toolbars, Guides, and Rulers:-


To activate and deactivate different toolbars click View-
>Toolbars. To display guidelines on screen click View->Guides. To
display horizontal and vertical ruler click View->Ruler.

4) Header and Footer:-


To set header and footer to slide. Notes page an Hand out Click
View->Header and Footer. Date and time include date and time footer
area. Update automatically means update date according to current date.
Slide number include slide in footer area. First tab 'Slide' is used to set
header and footer to slide and second tab 'Notes and Handout's used to
set header and footer to notes page and handout.

Fundamentals of Computer Operating and Programming 205


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 206


C.O.P.A. Trade of I.T.I RD S

5) Comment:-
This is used to show comments on screen.

6) Zoom:-
This is used to show presentation in maximize or minimize view.

Fundamentals of Computer Operating and Programming 207


C.O.P.A. Trade of I.T.I RD S

INSERT AND FORMAT IN POWERPOINT

 Insert Menu:-

Insert menu is related with insertion of different objects


in PowerPoint. Many options in this menu are same as we have seen in
Ms-Word i.e. inserting cliparts, word art, auto shape, comments,
symbols, text box, object etc.

1) Inserting New Slide:-


To insert new slide in presentation.
a) Click Insert-> New slide.
b) A dialog asking for slide layout gets appeared. Select slide layout and
click on Ok button to insert slide.

2) Insert Duplicate Slide:-


Select the slide whose duplicate you want, click Insert-
>Duplicate slide.

3) Comment:-
To insert comment on slide click Insert->Comment.

4) Slide from Files:-


We can insert slide form other presentation in current
presentation. click Insert->Slide from files. Following 'Slide Finder'
dialog will appear on screen. Click on 'Browse' button to select the file
from which you want to insert slides. Slides from that file will get
appeared. Select the slide and click on 'Insert' button. To insert all slides
click on 'Insert All' button.

5) Inserting Organization Chart:-


Organization chart shows structure of organization. To insert this
chart click Insert->Picture->Organization chart. Following window will
appear. Another way to insert organization chart on slide in insert slide
having layout 'Organization chart' from Insert->New slide and double
click on organization chart to insert organization chart.

6) Insert Table:-

Fundamentals of Computer Operating and Programming 208


C.O.P.A. Trade of I.T.I RD S

To insert table on slide click Insert->Table. Following dialog


will appear. Give no. of columns and rows and click on 'Ok' button to
insert table. Another method to insert table in Insert->New slide and
select slide layout 'Table'. Double click on table to insert table on slide.

Fundamentals of Computer Operating and Programming 209


C.O.P.A. Trade of I.T.I RD S

 Formatting objects and slide:-

1) Font:-
As we have seen in Ms-Word we can change font, font style of
text on slide. We can apply effect like shadow, underline, superscript,
emboss, subscript and color.

a) Select the text; click Format->Font Font dialog will appear. Make the
settings and click on Ok to apply the settings.

2) Bullets and Numbering:-

Fundamentals of Computer Operating and Programming 210


C.O.P.A. Trade of I.T.I RD S

To apply bullets or number to paragraph on slide click Format-


>Bullets and number following dialog will appear. Select 'Bulleted' tab
to apply bullets or 'Numbered' to apply numbers.

3) Alignment:-
We can align the text to center, left, right using Format->align.

Fundamentals of Computer Operating and Programming 211


C.O.P.A. Trade of I.T.I RD S

4) Line Spacing:-
To change spacing between two lines of paragraph, spacing
before paragraph and after paragraph Click Format->Line Spacing
Following dialog will appear. 'Click on Ok' button to apply the settings.

Fundamentals of Computer Operating and Programming 212


C.O.P.A. Trade of I.T.I RD S

5) Change Case:-
We can convert selected text in Title, Sentence, and Upper,
Lower or Toggal case using Format -> Change.

6) Replace Font:-
This is used to replace selected font with another font. Click
Format->Replace Font. Following dialog will appear. Select with which
font you want to replace existing font. Click 'Replace' button to apply
changes.

Fundamentals of Computer Operating and Programming 213


C.O.P.A. Trade of I.T.I RD S

7) Slide Layout:-
To change layout of exiting slide select the slide Click Format-
>Slide Layout. Following dialog will appear. Select layout and click
'Reply' button to apply new slide layout.

Fundamentals of Computer Operating and Programming 214


C.O.P.A. Trade of I.T.I RD S

8) Slide Color Scheme:-


There are some predefined color schemes. To apply these color
scheme click Format->Slide color scheme. Following dialog will appear.
Select the color scheme. To change color click on custom and make
changes to predefined color for background, bullets etc. click on 'Apply'
to apply settings to current slide and 'Apply All' to apply settings to all
slides.

9) Background:-
To change background of slide click Format->Background.
Following dialog will appear. To change color of back ground click on
combo box and select color from 'More color' and to fill different pattern
Click 'Fill pattern' Following dialog will appear. There are four tabs.
'Gradient' tab is used to apply shading of two or more colors. 'Texture'
tab is used to apply different textures. 'Pattern' tab is used to apply
different pattern and 'Picture' tab is used to apply picture to background
of slide. Click on 'Ok' button to apply the settings.

Fundamentals of Computer Operating and Programming 215


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 216


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 217


C.O.P.A. Trade of I.T.I RD S

10) Design Template:-


To apply different design template to slide click Format->Design
Template. Following dialog will appear.

Select the template from design available and click on 'Apply' button to
apply the settings.

Fundamentals of Computer Operating and Programming 218


C.O.P.A. Trade of I.T.I RD S

11) Colors and Lines:-


To format clip art or word art or any object inserted in power
point Format->Colors and Lines is used. When we select clip art the
dialog with name 'Format Object' will appear. If word art is selected the
dialog with 'Format Word art ' dialog will appear on screen as shown
below. 'Colors and Lines' tab is used to fill different colors in object. To
change format of line and arrows e.g. line style, color etc. 'Size' tab is
used to change width, height and rotation of object. 'Position' tab is used
to change horizontal and vertical position of object.

Fundamentals of Computer Operating and Programming 219


C.O.P.A. Trade of I.T.I RD S

12) Picture Tool Bar:-


To activate this tool bar click View->Toolbar->Picture.
This tool bar is used to format picture. This tool bar is also available in
Ms-Word. Insert picture is used to insert picture on slide. Using image
control we can display picture in gray scale, Black and white and water
mark.. We can increase or decrease contrast and brightness. To cut part
of object crop is used. Line style can be apply. We can change the color
and format object using this toolbar.

WORKING WITH SLIDE SHOW


MENU
PowerPoint is presentation software. To make our presentation
attractive and more effective we can apply animation effects in power
point. That effect can be given using 'Slide Show' menu.

 Giving Animation Effect to Objects:-


Any moving effects are called as animation effects. To apply
these animation effects select the object on slide and click Slide Show-
>Custom animation. Following dialog will appear Select the object.
Form 'Effect' tab select animation effect i.e. fly from left etc and apply
sound effect. Specify how to introduce text. From order and timing
specify time settings for object and order of object.

These animation effects can also be given using 'Slide Show'-


>Preset animation.

To display the preview animation click 'Slide Show'->Animation


Preview. Following window gets appear on screen. Click on this
window to display preview of animation.

Fundamentals of Computer Operating and Programming 220


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 221


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 222


C.O.P.A. Trade of I.T.I RD S

 Giving Slide Transition Effect:-


Moving effects given to slide are called as transition effect. To
apply these effect click Slide Show->slide transition. Following dialog
will appear.

Select effect and speed of animation. Set timings for occurrence of


each slide and click on 'Apply' button to apply changes to current slide
'Apply to All' to apply changes to all slides.

Fundamentals of Computer Operating and Programming 223


C.O.P.A. Trade of I.T.I RD S

 Other Option in Slide Show Menu:-

1) Hide Slide:-
To hide a particular slide in presentation select the slide and
click Slide Show->Hide slide.

2) View Show:-
To display presentation on full screen Click Slide show->View
show. F5 is shortcut key to display presentation on full screen.

3) Rehearsal Timings:-
Click slide show->Rehearsal Timings following tool bar will
appear while presentation. It shows time required by current slide in
presentation and total time required by presentation.

4) Set up Shows:-

Fundamentals of Computer Operating and Programming 224


C.O.P.A. Trade of I.T.I RD S

Click Slide Show->Setup show. Following dialog will appear on


screen. We can change show type pen color and range of slide to show
in presentation.

Fundamentals of Computer Operating and Programming 225


C.O.P.A. Trade of I.T.I RD S

5) Custom Shows:-
We can select slides from presentation can create different shows
in power point Click Slide show->Custom shows. Following dialog will
appear. Click on 'New' button to create new show.

Fundamentals of Computer Operating and Programming 226


C.O.P.A. Trade of I.T.I RD S

Following dialog will appear. Give to show and add the slide from
original presentation that you want in show. Click 'Ok' button to apply
the settings.

Click on Show button to display presentation according customize


show.

Fundamentals of Computer Operating and Programming 227


C.O.P.A. Trade of I.T.I RD S

7) Action Button:-
To navigate through the presentation action buttons are used.
There are nine actions button given to go to next slide back slide, first
slide, and last slide. We can introduce new presentation in existing
presentation using this action button. Click Slide Show->Action buttons.
Drag and drop action button on slide as shown below.

Following action settings dialog will appear. Select the hyper link
to which slide and click on Ok button to apply the settings. Click on this
button to go to last slide slide during presentation show.

 Window and Help Menu:-


Window menu is related with creation of new windows and
arrange it. Help menu provide assistant and help about selected topic as
we have seen in Ms-Word.

Fundamentals of Computer Operating and Programming 228


C.O.P.A. Trade of I.T.I RD S

INTRODUCTION

 Language:-
The language is the way of communication between two persons.

• C-Language:-
It gives the bas for communication between user and computer
or the user and programmer.

There are three types of Languages of follows.

1) High Level Language:-


It is the language which gives better programming
efficiency i.e. faster program development. The code is written in
English, Hernce it will convert the code from English to binary language
and then it will process the code. Hence the output will be in Binary
form, and then this output will be again converted into English. In this
way it has to covert the code from English to Binary and again from
Binary to English.

• Advantage: - It is very easy to learn and easy to implement.

• Disadvantage: - The execution speed of High level


Language is slow due to the conversion factor from English to
Binary and again Binary to English.
e.g.:- BASIC, COBOL, PASCLE, FORTRAN etc.

2) Low Level Language:-


It is the language which gives better machine efficiency i.e.
faster program execution. The code is written in Binary i.e. in the form
of 0 and 1. Hence it is directly understood by computer. Therefore the
execution speed is very fast in low level language.

• Advantage: - The execution speed is fast.

• Disadvantage: - It is very difficult to learn and to implement.

Fundamentals of Computer Operating and Programming 229


C.O.P.A. Trade of I.T.I RD S

e.g.:- 1) Machine language 2) Assembly language.

3) Middle Level Language:-


It is the language which gives better programming efficiency i.e.
faster program development and also it gives better machine efficiency
i.e. faster program execution. In this way it shows the qualities of High
Level and Low Level and hence it is known as Middle Level Language.

• Advantage:-

1) It is very easy to learn and easy to implement.

2) The execution speed is fast.

e.g.:- C Language.

Fundamentals of Computer Operating and Programming 230


C.O.P.A. Trade of I.T.I RD S

 History of 'C':-
By 1960 a crowd of computer has come into existence, almost
each for a specific purpose e.g. COBOL has being used for commercial
application, FORTAN for engineering application. At this stage, people
started thinking the instead of suing different language which can
program all possible application. Therefore an international committee
was set to develop such a language Table. Shorts the various stages in
evolution of language.

Year Language Developed by Remarks


1960 ALGOL International Too general and
committee abstract
1963 CPL Cambridge Hard to learn
University and implement
1967 BCPL M.Richards For specific
problem only
1970 B Ken Thompson For specific
problem only
1972 C Dennis Ritchie Lost generality of BCPL
and B, restored.

 Introduction to 'C':-
C is programming language developed at AT & T's Bell
Laboratories of USA in 1972. It was designed and written by Dennis
Ritchie. C is often called a middle level language.

 Importance of C:-
The increasing popularity of C is probable due to its many
desirable qualities. It is a robust language whose rich set of built in
functions & operations can be used to write any complex program. The
C compiler combines the capabilities of an assembly language with the
features of a high level language & therefore it is well suited for writing
both system software & business package and so it is called as a middle
level language. Programs written in C are efficient & fast . C is highly
portable. Another important feature of C is its ability to extend itself. A
C program is basically collection of functions that are supported by the
C library. We can continuously add out functions to C.

Fundamentals of Computer Operating and Programming 231


C.O.P.A. Trade of I.T.I RD S

 Features of 'C' language:-


• It is highly portable. This means that C programs written
for one computer can be run on another with little or no
modification.
• 'C' is a well suited for structured programming.
• 'C' program is basically a collection of function supported
by the 'C' library.
• Variety of data types and powerful operators.
• There are 32 keywords and its strength lies in its built in
function.
• C is well suited for structured programming. This
modular structure makes program testing & debugging
very easy.

 Constants, Variable and


Keywords:-
The alphabets, numbers and special when properly combined
from constants, variables and keywords.

• A constant is a quantity that does not change. This quantity can


be considered, stored at locations in the memory of the
computer.
• A variable can be considered as a name given to the location in
memory where this constant is stored.
• A keyword is a special word, which has some meaning in C.

 Types of Constants:-
C Constants can be divided into two major categories.
1) Primary Constants.
2) Secondary Constants.

Fundamentals of Computer Operating and Programming 232


C.O.P.A. Trade of I.T.I RD S

Constants

Primary Constant
Secondary Constant

Array, Pointer

Structure, Uninon,
Integer Real Character enum, etc.
Constant constant constant

 Rules for constructing Integer constants:-


1) An integer constant must have at least one digit.
2) It must not have a decimal point.
3) It could either positive or negative.
4) It no sign precedes an integer constant 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 + 032767.

 Rules for constructing Real constants or Floating Point


constants:-

Real constants are often called Floating point constants. The real
constants could be written in two forms. Fractional form and
Exponential form.

1) A real constant 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 constant.

Fundamentals of Computer Operating and Programming 233


C.O.P.A. Trade of I.T.I RD S

 Rules for constructing Character constants:-

1) A character constant is a single alphabet, a single digit or a single


special symbol enclosed within single inverted commas.
2) Maximize length of a character constant is 1 character.

• Define Symbolic Constants (Macro):-


We often use certain unique constants in program. These
constants may appear repeatedly in a number of places in a program .Ex.
PI (3.14) . For that we define this constant. A constant is defined as
follows
# defines symbolic name value of constant / expression.

Example: - # define PI 3.14


# define MARKS 50

They are also called as macro. Here PI and MARKS are macros.

 Types of C variables:-

In 'C' a quantity which may vary during program execution is


called a variable. Variables are names given to the location in the
memory of computer where different constants are stored. The location
can contain Integer, real or character constants.

 Rules for constructing variable Names:-


1) A variable name should be a combination of alphabets, digit or
underscores. Some compilers allow variable names whose length could
be up to 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.
3) No commas or blanks are allowed within a variable name.
4) No special symbol other than underscore (as in gross _Sal) can be
used in a variable name.
Example: - Si_int
M_hra
Por_e_sg.
5) Variables defined in upper and lower case are considered as different.
6) C Keywords can not be used as a variable name.

Fundamentals of Computer Operating and Programming 234


C.O.P.A. Trade of I.T.I RD S

Following are the examples of variable declaration statements.


Int si, m_hra;
Float b, c;
Char code; where Int, float and char are the data types.

 C Keywords:-

Keywords are the words whose coning has already beer


explained to the C complier (or in a broad sense to the computer). The
keyword 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 as "Reserved Words". There are 32
keywords available in 'C'.

auto double if static


break else int struct
case enum long switch
char extern near typedef
const float register union
continue far return unsigned
default for short void
do go to signed while

 C Instructions:-
There are basically four types of Instructions in 'C'.

1) Type Declarations Instructions.


2) Input / Output Instructions.
3) Arithmetic Instructions.
4) Control instructions.

 Type Declaration Instructions:-


To declare the type of variable used in a 'C' program.

Fundamentals of Computer Operating and Programming 235


C.O.P.A. Trade of I.T.I RD S

 Input / Output Instructions:-


To perform the function of supplying data to a program and
obtaining the result from it.

 Arithmetic Instructions:-
To perform arithmetic operations between constants and
variables.

• Control Instructions:-

To control the sequence of execution of various statements in a


'C' program.

 Structure of 'C' programming:-


A 'C' program should be written in a specific sequence which
includes following steps.

• Linking.
• Constant declaration.
• Global variable declaration.
• Main ( ) function.
• Local variable declaration.
• Input statement.
• Calculation or processing.
• Output statement.
• User defined functions.

 Linking:-
C uses various built in functions to perform the operations. They
are also known as standard library function which are defined in
different header files. To use a particular function, the respective header
file should be included in the program. When the program is executed,
the file gets linked to the program.

 Header files: - [Extension. H]

1) Stdio.h:-

Fundamentals of Computer Operating and Programming 236


C.O.P.A. Trade of I.T.I RD S

In stdio.h header file, all the standard input/output functions are


defined Example: - printf ( ), scanf ( )

2) Conio .h:-

Consol input output Functions. Example: - clrscr ( ), getch ( )

3) Math.h:-
Mathematical functions. Example: - sqrt ( ), abs ( )

4) String.h:-
String functions. Example: - strcpy ( ), strlen ( )

To include the header file in the program # include statement is used as:-

Syntax: - # include <header filename>

Example: - # include <stdio.h>


# include <math.h>

 Constant Declaration:-
If require constant can be declared in the program above the
main ( ) function. It is defined using # define statement. E.g. PI (3.14)
can be declared as a constant to calculate the area of circle as its value
does not change. They are also called as preprocessor directives.

 Global Variable Declaration:-


Sometimes it is required to use some variables anywhere in the
program i.e. by any function in the program. For this the variable must
be made accessible to all the functions by declaring it as global i.e.
outside all the functions. Global variables are declared same as the local
variables. their scope is global.

 Main ( ) function:-
After linking and declaration statements you can start your
program with main ( ) function.

Fundamentals of Computer Operating and Programming 237


C.O.P.A. Trade of I.T.I RD S

 Local Variable Declaration:-


Local variables are the one that are declared inside a function.
They are accessible to the function in which they are defined.

 Input Statement:-
After local variable declaration, input statement can be given to
input or accept the data from user, for this C provides standard input
function: scanf ( ).

 Calculation / Processing Statements:-

It includes the general data processing statements like


mathematical calculations or string manipulation statements, data
conversion statements etc.

 Output Statements:-
Finally result will be displayed on screen using the output
statement (function): printf ( ).

 User Defined Functions:-


Unlike the built functions, we can define our own functions in
the program whenever required. They are called as user defined
functions. They must be defined outside any function and can be called
anywhere in the program.
All the above steps are not compulsory in every program. They
can be included as per the program requirement.
Every program must contain a main ( ) function.

 Data types:-
While declaring the variable we must have to specify the data
type of the variable. The data type determines the type of value the
variable is going to hold like numeric, character etc. One of the features
of C is that C has variety of data types. There are two types of data
types:

a) Built in data types.

Fundamentals of Computer Operating and Programming 238


C.O.P.A. Trade of I.T.I RD S

c) User defines data types / Derived data types.

The standard built in data types User Defined Data types


* Integer/Int (Numeric) * Arrays
* Float(Real) *Structures
* Char (Character) *Unions

Built in data types are given divided into following subtypes;

Integer Character Float


Integer Single Character Float
Short integer String (Sequence of Char.) Double
Long integer -- --

These data types varies according to their storage size and the range of
value
they can hold . The range and bit size of each data types is given below;

Data types bit size Rang for Signed Unsigned


Character 8bit -128 to +127 0 to 255
Short-int 8bit -128 to +127 0 to 255
Int 16bit -32768 to +32767 0to 65535
Long Int 32bit -214748367to+214748367 0to429496729
Float 32bit -38 to 34+E38 ---
Double 64bit 1.7 +E 308 ---

PROGRAMMING IN C

Instruction In a Program is written as a separate statement


Therefore a complete C program will emprise of a series of statements ,
These statements must appear in the same order in which we wish them
be executed
However big programs, following rules are applicable to all statements;
1. Blank spaces may be inserted between two words to improve the
readability of the statements. However, no blank spaces are allowed
within a variable, constant or keyword
2. Usually all statements are entered in small case letters.

Fundamentals of Computer Operating and Programming 239


C.O.P.A. Trade of I.T.I RD S

3. Chas no specific rules for position at which statements are to be


written. That is why it is often called a free-form language.
4. Every individual statement is program always ends with a semicolon
('; ')
Any program has three parts:
1. Algorithm
2. Flowchart
3. Program

 Algorithm:-
Thinking in our own language and writing it in simple English
language is called as algorithm. There are no special symbols and
commands used in it.

 Flowchart: - The graphical representation of the program


is known as flowchart. It can be represented using various
flowchart symbol

Oval:-To Start or End the program.

Rectangle: - For Variable Declaration and


Processing
Statement

Parallelogram: - For Input and Output


operations

Diamond:-To give decision making (conditional)


Statements.

Flow Lines:-To specify the flow of the program.

Connector:-To continue the flowchart on next page.

Using these symbols we can draw a flowchart for the program.


Algorithm and Flowchart simplifies the program logic. First write the
algorithm and flowchart and from it write a program.

 The first 'C' program:-

Fundamentals of Computer Operating and Programming 240


C.O.P.A. Trade of I.T.I RD S

Example: - Addition of two numbers.

• Algorithm:-
1) Include the required header files in the program.
2) Declare the variables to store two numbers and the addition of the
numbers.
3) Accept two numbers.
4) Perform the addition.
5) Display the result.

• Flowchart:- Start

int a, b,c

Accept two numbers a & b

c = a+b

Display the addition

End

Fundamentals of Computer Operating and Programming 241


C.O.P.A. Trade of I.T.I RD S

• Program:-
/* Addition of two numbers */

# include<stdio.h>
main ( )
{
int a,b,c;
clrscr ( ); /* To clear the
screen */
printf ("Enter two numbers");
Scanf ("%d%d", & a , & b ); /* accept 2
numbers */
c = a+b; /* performs addition of
a and b */
printf ("\n Addition = %d", c); /* Displays
the result */
}

Comment about the program should be enclosed within /* */ . Any C


program is nothing but a combination of functions. Main ( ) is one such
function. Empty parentheses after main is necessary. The set of
statements belonging to a function are enclosed with in a pair of braces
i.e.
main ( )
{ Statement 1;
Statement 2;
}

The above program performs the addition of any provided two


numbers. The first step of the program is linking i.e. including the
header file. The program does not require any constant declaration or
any global variable declaration so these steps are skipped. The program
starts with main ( ) function followed by a '{'. The main requirement in
above program is providing two numbers for addition. To store these
numbers a variable is required int a,b,c statement declares three integer
variables. a, b and c. a,b will hold the two numbers and will hold their
addition. Any variable used in the program must be declared before
using.

Next step is accepting two numbers: - printf ( )


function will print the message as "enter two numbers:" and scanf ( )
function will accept the data from user into a and b . '%d' is a conversion
operator used for integer data type. In scanf ( )function '&' operator is
used to get the address ( location number ) of the variable. The numbers
will be stored into the memory at a and b locations.

Fundamentals of Computer Operating and Programming 242


C.O.P.A. Trade of I.T.I RD S

Next step is the calculation:- addition will be


performed and it will be stored into third variable c. Finally it will print
the result on screen using
printf ( ) function.

Clrscr ( ) function is used to clear the screen before executing the


program. The program is ending with '}'. Save this program with valid
filename and extension as c by pressing F2 key or select File - Save
option.
To run a c program following key combination is used :

• Compile :- Alt+F9
• Execute :- Ctrl+F9
• Output :- Alt+F5

Every time to display output we have to press Alt+F5 key. To avoid this
getch () function can be included at the end of the program.

With every c program i.e. c file two more files gets created:

1) .obj file gets created at the time of compilation.


2) .exe file gets created at execution time. The program can be executed
from DOS prompt.

 Predefined Functions (Stdio.h):-

• Main ( ):-
This function is used as a starting point of the program. It tells
the compiler that the programs is started from the point or statement. It
is void function i.e. it does not have any parameter and it does not
return any value. All the executable statements must be given in the
main ( ) function because execution starts with main ( ).

• Printf ( ) :-
Printf ( ) is one of the most versatile function in C. In fact it is
a standard library function used to display the output on the screen.
We can format the output using various formatting options like
'\n','\t', %3d etc.
Syntax:-
Printf (" Format string ", list of variable);

Example: - To display any message on screen:

Fundamentals of Computer Operating and Programming 243


C.O.P.A. Trade of I.T.I RD S

printf ("Welcome to MCED") ;

OR

To print the value of a variable ;


int a=10 ;
printf ("\n%d",a);
"%d" is a format specifies used to print the value of the variable on
screen .For each data type a format specifies is provided

%f : For printing real (float) values.


%d : For printing integer values.
%c : For printing single character
%Id : For Long integer.
%u : For unsigned integer.
%If : For Double values

Examples:-

Printf (" % 2f", si);


Printf (" % 3d % 3d ", p, n);
Printf ("Simple interest = %f", sp);
Printf (" Principle amount = %d \n Rate = %f ", p, r);

"\n":- It is called new line and it takes the cursor to the next line

• Scanf ( ) :-
Scanf ( ) is used to accept data through keyboard (from user)

Syntax: -
Scan (" format specifier ", & variable name);
Operator'&' is used before the variable to get the address of the
variable. It takes the location number where variable is defined '&'
is not required when we are using '%s' operator for string values.

Example:-
Scan ( "%d %d", &p,&n, name ): We can accept multiple values
with a single scanf ( ) statement.

Examples 1:- Calculation of simple interest


# include < stdio.h >
Main ( )

Fundamentals of Computer Operating and Programming 244


C.O.P.A. Trade of I.T.I RD S

{
Int p, n;
Float r. si:
Printf (" Enter value of p, p, r ");
Scant (" %d%d%f', &p, &n. &r);
Si= p*n* r/100;
Printf (" simple interest is = %. 2f", si);
}

Example 2:- Program to accept student's information and


display student
Mark list.

# include<stdio.h>
main ( )
{
int rno, sub1, sub2 , total;
float per;
printf ("\n Enter rollno:");
scanf("%d",& rno);
total = sub1+ sub2
per = total / 2;
printf ( "\n\t\t STUDENTS MARKLIST");
printf ( "\n\t\t -------------------------------");
printf ( "\n\n\n\t Roll No. = %d", rno);
printf ("\n\t -----------------------------");
printf ( "n\t\t English \t\t Math");
printf ("\n\t\t %d \t\t %d", sub1 , sub2);
printf ("\n\t -----------------------------------");
printf ("\n\t Total = %d", total);
printf ("\n\t Percentage = %2f", per);
getch ( );
}

Fundamentals of Computer Operating and Programming 245


C.O.P.A. Trade of I.T.I RD S

Output is :-
STUDENTS MARKLIST

Roll No. = 1

English Math
70 70

Total = 140
Percentage = 70.00

The program contains formatting character like '\n' , '\t' etc. they are
known as escape sequences. Escape sequences always begins with '\'
followed by a character. Following are the escape sequences :

Escape Sequence Character Format


'\n' New Line character.
'\t' Horizontal Tab.
'\b' Back Space.
'\' Quotation mark.
'\\' Backslash character.
'\O' Null Character.

Fundamentals of Computer Operating and Programming 246


C.O.P.A. Trade of I.T.I RD S

DECISION MAKING

 The Decision Control Structure :-


Sometimes it is required that some statements in the program
should be executed depending on some condition. This is known as
conditional programming. The decision control structure allows us to do
this. It can be used to provide the condition in the program. The
condition can be given using operators.

 Operator in C :-
Operators are use to perform various operations like addition,
comparison etc. C supports following operators.

• Mathematical Operators :-
'+','-','*','\','%' ( modulus operator) etc.

• Relational Operator :-

>,< , >=, <=, = = , = , != etc.

The expression is true if


x==y x is equal to y
x!=y x is not equal to y
x<y x is less than y
x>y x is greater than y
x <= y x is less than or equal to y
x >= y x is greater than or equal to y

• Note :-
• = is used for assignment operator.
• = = is used for comparison of two quantities.

• Logical Operators :-
&& (and) , | | (or) , ! (not)

Fundamentals of Computer Operating and Programming 247


C.O.P.A. Trade of I.T.I RD S

 Hierarchy of Operators :-
The operators are evaluated in order of their priority. The hierarchy
(priority) of commonly used operators is shown in fig

Highest ( ), | | , ->
!, ~, ++, --, -, *, &
*, / , 5
< , <=, >, >=
==,!=
&&,||
?:
Lowest = , + = , -= , *= , /=

 Chas two major decision making structures :-

• If statement.
• Switch statement.

 The If statement :-

C uses keyword 'if' to implement the decision control instruction.


The general form of 'if' statement likes :

Syntax :-

If (condition)
{
execute statements;
}

Example :- demonstration of if statement


# include <stdio.h>
main ( )
{
int num;
printf ( "\n Enter a number less than 10");
scanf ( "%d", & num );
if (num <= 10)
printf ( "\n What an obedient servant you are:");
}

Fundamentals of Computer Operating and Programming 248


C.O.P.A. Trade of I.T.I RD S

On execution of this program. If you type a number less than or


equal to 10, you get a message on the screen through print ( ) as "What
an obedient servant you are :". If you type some other number no output
will printed. Here the if statement will not have a ';' as the scope of the
statement continues further.

The if statement has three forms :

• Simple If
• Multiple If
• Nested If

• The Simple if (If - else statement ) :-


Simple if statement can be used when there is only one condition.

Syntax :-
If (condition)
{
group of statement 1;
}
else
{
group of statement 2;
}

If the condition given with if statement is true then statement 1


will be executed otherwise else part will executed. Else part is optional.
If there are multiple statements given in if block then if block then
enclose it in { }.

Example :- In a company an employee is paid as under :


If his basic salary is less than Rs.1500/- then HRA-10% of basic salary
and DA =90% of basic salary. If his salary is either equal to or above
Rs.1500/- then HRA = 500 and DA=98% .
write a program to calculate HRA , DA and Gross Salary.

Fundamentals of Computer Operating and Programming 249


C.O.P.A. Trade of I.T.I RD S

# include <stdio.h>
main ( )
{
int basic;
float gross, hra, da;
printf ("Enter the basic salary");
scanf ("%d", & basic);
if (basic <1500)
{
hra = (float) basic*10/100; // Typecasting basic to float
da = (folat) basic*90/100;
}
else
{
hra = 500
da = basic*98/100;
}
gross = basic + hra + da ;
printf ('\n HRA = %2f\t\t DA = %2f ", hra,da);
printf ("\n\n\t Gross Salary = %2f ", gross );
}

Example :- Program to find greater number between


two
numbers entered.

# include <stdio.h>
main ( )
{
int a,b;
clrscr ( );
printf ("\n Enter two numbers :");
scanf ("%d %d ", & a , & b);
if (a>b)
printf ("\n A is greater ");
else
printf ("\n B is greater ");
getch ( );
}

Fundamentals of Computer Operating and Programming 250


C.O.P.A. Trade of I.T.I RD S

 Nested If :-
Nested if is perfectly all right if we write an entire 'if-else' construct
within another if block or else block. This is called Nesting' of ifs.

if (condition 1) /* Outer if */
{
Group of statements 1;
if (condition 2) /* Inner If */
Group of statements 2 ;
else
{
Group of statements 3;
}
}
else
{
Group of statement 4;
}
In this case the second if statement is known as inner if and main if
statement is known as outer if. The if condition will be checked only
when the outer if condition is satisfying.
Example :- To find greater number between three numbers
entered.
# include <stdio.h>
main ( )
{
int a, b,c;
printf ("Enter three numbers");
scanf ("%d %d %d", & a , & b , & c );
if (a>b)
if (a>c)
printf ("\n A is greater ");
else
printf ("\n C is greater ");
else
if (b>c)
printf ("\n B is greater ");
else
printf ("\n C is greater ");
getch ( );
}

 Multiple if (if - else if) :-


Multiple if statement can be sued when we want to perform multiple
operation depending on different conditional .

Fundamentals of Computer Operating and Programming 251


C.O.P.A. Trade of I.T.I RD S

Syntax :-

if (condition)
statement 1;
else if (condition 2)
statement 2;
else if (condition 3)
statement 3;
:
:
else if (condition N)
statement N;
else
statement X;

Like this we can give N number of conditions and we can execute


different statements. Conditions will be checked one by one. If
conditional 1 is satisfying statement 1 will be executed and control
will be transferred to the end of if statement., if it is false then only
condition 2 will be checked. Among all the given condition any one
will be satisfied at a time. If all of the given conditions are false then
final else bock will be executed.

Example :- Program to display the grade of the student based on


following
Criteria:

Per Grade
Between 50-59 'C'
Between 60-75 'B'
Above 75 'A'
Below 50 ' Fail'

Fundamentals of Computer Operating and Programming 252


C.O.P.A. Trade of I.T.I RD S

# include <stdio.h>
main ( )
{
int rno;
float per;
printf ("Enter rno and percentage for a student");
scanf ("%d %f ", &rno, &per);
if (per>=50 && per<60)
printf ("\n Grade = C");
else if (per>= 60 && per<75)
printf ("\n Grade = B");
else if ( per>=75)
printf ("\n Grade = A");
else
printf ("\n student is Fail");
getch ( );
}

In above example it will accept the percentage and grade will be


displayed by checking the condition.
e.g. per =65 then grade = 'B', if per = 45 then 'student is Fail' message
will be displayed.

 Conditional operator :-

Another conditional construct used as an alternative for simple if


statement is conditional operator. The conditional operator ? and : are
sometimes called ternary operators since it takes three arguments.

Syntax :-
expression 1 ? expression 2 : expression 3
if expression 1 is true, then the value returned will be expression 2
otherwise the value returned will be expression.

Example :-
# include <stdio.h>
main ( )
{
int x, y ;

Fundamentals of Computer Operating and Programming 253


C.O.P.A. Trade of I.T.I RD S

printf ("\n Enter number:");


scanf ("%d", &x);
y = (x > 5 ? 3:4);
printf ("%d", y );
}

This statement will store 3 in y if x is greater than 5 otherwise it will


store 4 in y.

Example :-
# include <stdio.h>
main ( )
{
char a;
int y ;
printf ("\n Enter any character:");
scanf ("%c", &a);
y = (a>=65 && a<=90 ? 1:0);
printf ("%d",y);
}

Here if character a is between 65 to 90 i.e. A-Z then if will return 1


otherwise it will return 0.

Fundamentals of Computer Operating and Programming 254


C.O.P.A. Trade of I.T.I RD S

ITERATION CONSTRUCT

 The loop control structure :-


The computer's ability is 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 respective operation is done using loop control structure.
There are three methods by way of which we can repeat a part of a
program.
They are :

• using While loop


• using For loop
• using Do-While loop

 The While loop :-


The operation of While loop is given below

START

initialise

Test
condition
True STOP

Body of loop

Increment

While Loop

Fundamentals of Computer Operating and Programming 255


C.O.P.A. Trade of I.T.I RD S

Syntax :-

Initialize loop counter


while (condition)
{
group of statements;
Increment loop counter;
}

Note the following points about while.

• The statement within the while loops would keen on getting


executed till the condition being remains true. We the condition
become false, the control passes to the first statement follows the
body of the while loop.
• The condition being tested may use relational or logical
operators.
• The statements within the loop may be a single line or a block of
statements. Statements should enclose within pair of braces
( { } ).

• Operators :-

i = i+1
i++ : It is a increment operation which increments the value of i by one.
i + = 1 : is a compound assignment operator. It is increment the value by
1.

The above three statements are same, they will give the same result i.e. i
will be incremented by 1 use any of them.

Example :- Program to display first 10 numbers (1 to 10) in


ascending order.

# include <stdio.h>
main ( )
{
int i=1; / / initialization.
while (i<=10) / / condition
{
printf ( "\n %d ", i);
i++; / /
increment.
}
getch ( );
}

Fundamentals of Computer Operating and Programming 256


C.O.P.A. Trade of I.T.I RD S

The above program will print. 1 to 10 numbers. Variable i is initialized


to 1.,condition will be checked , true and value of i will be printed as 1. I
will be incremented by 1 and again control will be transfer condition.
Same procedure will be performed till the condition is satisfying. Once
condition is false loop be terminated.

• The For loop :-


The operation of For loop is given in Fig.1. The For Loop allows
us to specify three things in a single line . Initializing a loop counter.
Testing the loop counter to determine whether its value has reached the
number of repetition desired. Increasing the value of loop counter each
time the program segment within the loop has been executed.

Syntax :-
for (initialization :condition: increment/decrement)
{
Group of statements;
}

Initialization part will be executed only once i.e. at the starting of loop.
Then condition will check. If it is true then statements will be executed
and then increment/decrement part will be executed. Again condition
will be checked and same procedure will performed. All the three parts
must be separated by a ';'.For loop can be used when there is fixed
number of iterations.

Fundamentals of Computer Operating and Programming 257


C.O.P.A. Trade of I.T.I RD S

START

initialise

False
Test
condition
True STOP

Body of loop

Increment

For Loop

 The Do.... While loop :-


Do..... while loop is same as while loop.

Syntax :-
do
{
group of statements;
loop counter variable;
} while (condition)

Fundamentals of Computer Operating and Programming 258


C.O.P.A. Trade of I.T.I RD S

The difference is that in while loop condition will be checked first and
then statements will be executed. But in do...while loop statements will
be executed first and condition will be checked at the end of loop as it is
condition is false. Here while statement should end with a ';'.

START

Initialise

Body of Loop

Increment

True
Test
Condition

False

STOP
Do.... While loop

Fundamentals of Computer Operating and Programming 259


C.O.P.A. Trade of I.T.I RD S

Example1 :- Program to display 1 to 10 numbers in ascending order


using
do...while loop.

# include <stdio.h>
main ( )
{
int n=1; / / initialization.
do
{
printf ("\n %d", n);
n++; / /
increment.
} while (n<=10); / / condition
getch ( );
}

Example 2:- To display 1 to 10 numbers in ascending order.


# include <stdio.h>
main ( )
{
int i;
for ( i=1 ; i<=10 ; i++)
{
printf ("\n %d", i);
}
getch ( );
}

In for loop we can initialize more than one variable also.

Fundamentals of Computer Operating and Programming 260


C.O.P.A. Trade of I.T.I RD S

Example 3 :- Program that demonstrates for loop with multiple


variable
initialization.

# include <stdio.h>
main ( )
{
int b,c;
for ( i = 1 , j =10 ; i <= j ; i++, j--)
{
printf ("\n %d", i );
}
getch ( );
}

The above program will print 1 to 5 numbers only . Both i & j is


initialized. I will be incremented and j will be decremented.

Example 4 :- Calculation of simple interest for 3 set of p,n and r


using For
loop.

# include <stdio.h>
main ( )
{
int p , n , count;
float r , si;
for (count = 1; count <=3; count =
count+1)
{
printf ("\n Enter values of p, n &
r");
scanf ("%d %d %f ", & p , & n , &
r);
si = p*n*r/100;
printf ("\n Simple interest = Rs.
%2f", si);
}
getch ( );
}

Fundamentals of Computer Operating and Programming 261


C.O.P.A. Trade of I.T.I RD S

 The infinite Loop :-

The loop that we have used so far executed the statement within them
a finite number of times. However in real life programming one may
come across a situation that it is not known beforehand how many times
the statement in the loop are to be executed. In such case we can use
infinite loop.

Example1 :- Program to display square of given number.

# include <stdio.h>
main ( )
{
char another = 'y'
int num;
while ( another = = 'y' or another = = 'Y')
{
printf ("\n Enter a number");
scanf ("%d", & num);
printf ( "square of %d is %d", num ,
num*num ); printf ("Another number
(y/n) ? ");
flush (stdin);
scanf ("%c", & another );
}

In this program the while loop would keep getting executed till the user
continues to answer Y. The moment he answers n , the loop terminates,
since the condition (another = = 'y') fails. flush (stdin) is used to remove
any data remained in the buffer. The argument stdin means buffer
related with standard input device.

Fundamentals of Computer Operating and Programming 262


C.O.P.A. Trade of I.T.I RD S

 The Infinite for loop :-


Infinite for loop can be used to perform certain operation infinitely like
displaying a time , changing color or rectangle etc. The loop should be
given without any condition.

Example1 :- Program that demonstrates infinite for loop.

# include <stdio.h>
# include <dos.h>
# include <process.h>
main ( )
{
int i = 1;
for ( ; -;)
{
printf ("\n %d", i);
delay (1000);
if (kbhit ( ))
{ exit (0); }
i++;
}
}

The above program will be executed until user hits a key. Number will
be printed one by one with some time duration delay ( ), kbhit ( ), exit
(0) are the built in functions.

• delay (int milliseconds) :-


Delay ( ) function is used to set time limit to
perform the operation. It takes the argument (time) in milliseconds.
Defined in dos.h.

• Kbhit ( ):-
kbhit ( ) function checks whether a key is hit or
not. It returns true if any key is hit from keyboard otherwise returns
false. Defined in conio.h.

Fundamentals of Computer Operating and Programming 263


C.O.P.A. Trade of I.T.I RD S

• Exit (int) :-
It is used to terminate the program execution. It takes integer
argument as 0 or 1.

 Nested loop :-
A loop within a loop is known as Nested loop.

Example :- To print a character in following format.


*
**
***
****
*****

# include <stdio.h.
main ( )
{
int i , j ;
for ( i=1 ; j<=1 ; j++)
{
printf ("*");
}
printf ("\n");
}
getch ( );
}

Here inner loop will be executed for 5 times till outer if condition is
satisfying. First a single '*' will be printed and inner loop will be closed
then cursor will be set to next line using "\n". i will be incremented and
again inner loop will be executed, now it will print two stars. Outer loop
value remains constant for complete inner loop.

Fundamentals of Computer Operating and Programming 264


C.O.P.A. Trade of I.T.I RD S

 The Break Statement :-


We often come across situation where we want to jump out of a loop
instantly without waiting to get back to the conditional test. The
keyword 'break' allow us to do this. When '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' statement . If it is used in
a nested loop, break will terminate only that loop in which it is given.

Example :- Write a program to determine whether a number is


prime or not.

# include <stdio.h>
main ( )
{
int num , i , prime =1;
printf ("\n Enter a number");
scanf ("%d", & num);
i = 2;
while (i < num)
{
if (num %1 = = 0)
{
prime = 0;
break;
}
else
{
prime =1;
}
i++;
}
if ( prime = =1)
printf ("Number is Prime
");
else
printf ("\n Number is not
prime");
getch ( );
}

In above example prime is used as flag variable, if remainder of the


division (num%i) is 0 then prime will set to 0. If condition is false then
prime will set to 1 and loop will be terminated with the break statement
as there is no need to check further. After the loop message will be
printed as per the value of prime.

Fundamentals of Computer Operating and Programming 265


C.O.P.A. Trade of I.T.I RD S

 The Continue Statement :-


In some cases we want to take the control to the beginning of the
loop, by ignoring the statement inside the loop which has not yet been
executed. The 'continue' statement allows us to do this. When continue
is encountered inside any loop, control automatically passes to the
beginning of the loop.

A 'continue' is usually associated with an 'if '. Following program


illustrates the use of continue statement.

Example :- To print the values of i and j.

# include <stdio.h>
main ( )
{
int i , j ;
for (i =1; i<=2; i++)
{ for ( j =1; j<=2; j++)
{ if (i = = j)
continue;
printf ("\n %d %d \n ", i , j);
}
}
}

The output of above program would be


1 2
2 1

Note that when the value of i equals that of j , the continue statement
takes control to the starting of inner for loop by ignoring rest of the
statements pending for execution in the inner for loop.

Fundamentals of Computer Operating and Programming 266


C.O.P.A. Trade of I.T.I RD S

 Decision making using Switch :-


In real life we are often face with situation where we require to make a
choice form a number of alternatives rather than one or two. The control
statement, which allows us to make a decision form 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.

Syntax :-

Switch (integer expression)


{
case constant 1;
group of statement 1;
break;
case constant 2;
group of statement 2;
break;
:
default :
default statement ;
}

• The expression following switch keyword is any 'c' expression that


yields an integer value.
(a) It could be an integer constant like 1,2,3----------------
(b) A variable that evaluates to an integer or char.
• An integer or a character constant follows the keyword case in the
condition.
• Each constant in each case must be different from all the others.
• The group of statements in the above form of switch represents
any valid 'c' statements.
• The integer expression. following the keyword switch is evaluated.
• The value is gives is then checked one by one against the constant
value that follows the case statement.
• When a match is found the program executes the statement
following that case condition.
• The break statement used in a switch takes the control outside the
switch once the condition is satisfied.
• If no match is found with any of the case statements, then only the
default statement will be executed.

• There are multiple statement to be executed in each "case" there is


no need to enclose them within a pair of braces. Unlike if and
else.
• The switch statement is very while menu derive programs.

Fundamentals of Computer Operating and Programming 267


C.O.P.A. Trade of I.T.I RD S

• The operation of switch :-

START

Yes
Case1 Statement 1

No

Yes

Case2 Statement 2
No

Yes

Statement 3
Case3 No

Yes

No
Case4 Statement 4

Switch
STOP

Fundamentals of Computer Operating and Programming 268


C.O.P.A. Trade of I.T.I RD S

Example 1 :- Program to display message using Switch .. Case


structure.

# include <stdio.h>
main ( )
{
int i = 2;
switch (i)
{
case 1 : printf ("\n I am in case 1");
break;
case 2 : printf ("\n I am in case 2");
break;
case 3 : printf ("\n I am in case 3");
break;
default : printf (" I am default ");
}
getch ( );
}

In above program value of i is 2. i is passed to the switch block. Case


conditions will be checked one by one . Case 1 is false so it will check
next case. Case 2 is true and it will print message as : 'I am in case 2'.
the immediate Break statement will terminate the switch block.

Example 2 :- Program to illustrate Switch Structure with character


value.

# include <stdio.h>
main ( )
{ char c = 'x ' ;
switch (c)
{
case ' v ' : printf ("\n I am in case
v");
break;
case ' a ' : printf ("\n I am case a
");
break;
default : printf ("\n I am in case
default");
}
getch ( );
}
The output of this program is : ' I am in case default '.

Fundamentals of Computer Operating and Programming 269


C.O.P.A. Trade of I.T.I RD S

Example 3 :- To display menu as below and perform the operation


as per
given choice using switch structure.

MENU
-----------------------
1. Circle .
2. Square .
3. Exit .
------------------------

# include <stdio.h>
# include <process.h>
# define PI 3.14
main ( )
{
int r , ch ;
float a;
clrscr ( );
printf ("\n\t MENU");
printf ("\n\t ------------------");
printf ( "\n\t 1. Circle.");
printf ("\n\t 2. Square. ");
printf ("\n\t 3. Exit . " );
printf ("\n\t -----------------------")'
printf (\n\t Enter your choice :");
scanf ("%d", & ch);
switch (ch)
{
case 1 : printf ("\n Enter radius :");
scanf ("%d", & r);
a = PI*r*r;
printf ("\n Area or Circle =
%.2f", a);
break;
case 2 : printf ("\n Enter side:");
scanf ("%d", & r);
a = r*r ;
printf ("\n Area or Square =
%.2f", a);
break;
case 3 : exit (0);
default : printf ("\n you have entered
wrong choice!");
}
getch ( );
}

Fundamentals of Computer Operating and Programming 270


C.O.P.A. Trade of I.T.I RD S

ARRAYS

It is the set of homogeneous data items which can be referred by the


common name. Array is a finite ordered set of similar data elements. It
is the list of items which are bound together in common relationship.
Arrays are called as subscripted variable because array uses the
subscript i.e. [ ] and the arrays are called as indexed variable because the
array elements can be accessed by using index number. Arrays are
divided into following types.

There are two types of arrays:

1) One dimensional.
2) Two or multi dimensional.

For one dimensional array we have to specify only one dimension i.e.
number of elements. For two or multi dimensional array we have to
specify more than one dimension. Two dimensional arrays are also
known as matrix.

int a [5];
char str [10];
int num [3] [3];
char name [5] [10];

In above example a and str are one dimensional arrays while num and
name are two dimensional array, a is integer array with five elements,
num is a two dimensional array having 3*3 - 9 elements. It is also
known as a 3 by 3 matrix with 3 rows and 3 columns. Character Array
have some differences, str is one dimensional character array which can
hold 10 characters i.e. one word. While name is a two dimensional
character array in which first dimension is the number c elements and
second dimension is the width of each element i.e. name array can hold
five names each of having 10 characters length. We can not store
multiple strings in a single dimensional array.

When an Array is declared it gets defined in a consecutive memory


locations and each location is considered as an element of the array.

If we have array like


int num [6];
Then the computer reserves five continuous storage location i.e.

Fundamentals of Computer Operating and Programming 271


C.O.P.A. Trade of I.T.I RD S

Memory location
Number

Element number

6002 6004 6006 6008 6010 6012

0 1 2 3 4 5

Num

Array Name

Storage Locations in Array.

Memory location are given as 6002, 6004,...because integer value takes


two bytes.

 Initialization of Array:-
An array can be initialized in different ways. Following are the
different ways for initializing numeric array.

int num [5]; Declaring an array. Array will hold


garbage value.
Or
int num [5];
num [0]= 35; Element can be initialized separately.
num [1]= 40;
Or
int num [5] = {35,40,45,50,55}; Numbers will be stored one by one .
Or
Int num[ ] = {10,20,30,40}; The size or array will be taken as per
numbers
given.
Or
Int num[5]=[10]; All the elements are initialized to zero.
Or
Int num[5]= {1,2,3}; Remaining elements will be initialized to
zero.

Now the array will look like :-

Fundamentals of Computer Operating and Programming 272


C.O.P.A. Trade of I.T.I RD S

35 40 45 50 55
Initialization of Array
0 1 2 3 4

num
The subscript of an array can be integer constants, integer variables like
p , or expression that yield integers, or all characters etc. usually the
array of characters is called a "string", where as a array of integers &
floats is called simply array.

• Note :-
All the elements of any array must be of the same type i.e. we cannot
have an array of 10 numbers of which 5 are integers and 5 are floats.

* Initialization of character array :-


Character array can be initialized in following ways :-

char name[10]; Declares a character array


Or
char name[5]= {'A','R','R','A','Y'}; Initializes the elements with five
character
Or
char name[5]={'A','B','C'}; Stores three character to the array
elements and
remaining elements contains blanks.
Or
Char name[ ] = {'M','C','E','D'}; Takes the size of array according to the
the characters stored.

Example :- char name [8] = {'W','E','L','C','O','M','E'};


Declares name as character array (string) that hold maximum of 7
character string "WELCOME". Each character of the string is treated as
an element of array name and stored in the memory as follows.

W E L C O M E \O

Fundamentals of Computer Operating and Programming 273


Name
C.O.P.A. Trade of I.T.I RD S

Character Array

Each character in the array occupies one byte of memory and the last
character is always '\O' (null character). It tells that where the string
ends. The string without '\O' is not a string but just a collection of
characters. Using this we do not have to rely upon the length of the
string. When the compiler sees a character string it terminates it with an
additional null character. Thus the element name[8] holds the null
character. When declaring character. arrays we must always allow one
extra elements space for the null terminator.

Example :- while (name[i] !='\O')


{
-------------
-------------
}

Following program illustrates how array are declared and manipulated :-

Example 1 :- Write a program to store five numbers in the array and


display it
on screen.

# include <stdio.h>
main ( )
{
int a[5] = {35,40,50,20,60};
int i;
clrscr ( );
for (i = 0 ; i<5; i++)
{
printf("\n %d", a[i]);
}
getch ( );

The program will print five numbers stored in the array. Arrays can be
manipulated using a loop. Elements can be varied using a variable i i.e.
a[i] will refer to each element. To repeat the same procedure a loop is
used. But here every time it will print the same five numbers, to print the
numbers entered through keyboard scan ( ) function should be used.

Fundamentals of Computer Operating and Programming 274


C.O.P.A. Trade of I.T.I RD S

Example 2 :- Program to accept 5 numbers in the array using scan (


) function

# include <stdio.h>
main ( )
{
int a[5];
int i;
clrscr ( );
printf ("\n Enter five numbers:");
for (i = 0; i<5; i++)
{
scanf ("%d", & a [i] );
}
printf ("\n Five numbers entered");
for ( i = 0 ; i<5 ; i++)
{
printf ("\n %d", a[i]);
}
getch ( );
}
Here every time it will accept new numbers and print it. Character
arrays are manipulated in the same way as integer array.

Example 3 :- Program to print 5 characters stored in array.


# include <stdio.h.
main ( )
{
char str[5] = { 'A','R','R','Y'};
int i ;
clrscr ( );
printf ("\n the array is");
for ( i = 0; i<5; i++)
{
printf ("\n %c", a[i]);
}
getch ( );
}

Though str is a character array, its elements are referred by integer value
so i should be of integer type. 'c' operator takes a single character. The
complete string (array) can be printed using '%s' operator. It also be used
with scan ( ) to accept a string. %s considers the whole string at a time
as:

Fundamentals of Computer Operating and Programming 275


C.O.P.A. Trade of I.T.I RD S

Example 4 :- Program to accept a string in array with %s operator


using
scanf ( ) function.

# include <stdio.h>
main ( )
{
char str[25];
clrscr ( );
printf ("\n Enter a string :");
scanf ("%s", str);
printf ("\n the array is : %s", str);
getch ( );
}

Here for loop is not required and we have to specify the array name only
in the printf ( ) and scanf ( ) statement. Another way to access the array
elements is using pointer, which we will see later.

 The gets ( ) and puts ( ) functions :-


In above example scanf ( ) is used to accept a string. If the string is
entered as "Happy Diwali" then only the word "Happy" will gets stored
in the array and it will not terminate the string by \O.i.e. scanf ( ) is not
capable of receiving multi-word strings, sentences or space between
characters. To overcome this limitation gets ( ) function can be used,
gets ( ) function can accept blank spaces and it into the array. To this
function we have to pass the array name. It also automatically stores
'\O' to end the string.

• Syntax : - gets (array name);

• Example :- gets (name); where name is a character


array.

Similarly puts ( ) function works. It prints the whole string at a time


screen.

• Syntax : - puts (array name);

• Example :- puts (name);


Following program illustrates the use of gets ( ) and puts ( ) functions.

Fundamentals of Computer Operating and Programming 276


C.O.P.A. Trade of I.T.I RD S

Example 5 :- Program to accept a string and convert it into upper


case.

# include <stdio.h>
main ( )
{
char str [25];
int i = 0;
printf ( "\n Enter a string:");
gets (str);
while (str[i] != ' \ O' )
{
if (str[i] >=97 && str[i] <123)
{ str[i] = str[i] - 32 ; }
i++;
}
printf ("\n String in upper case :");
puts (str);
getch ( );
}

 Two Dimensional Arrays :-


The arrays can have more than one dimension also. In mathematics,
we represent a particular value in a matrix by using two subscripts such
as Vij. Here V denotes the entire matrix and Vij refers to the value in the
ith row and j th column. C allows us to define such a table of items by
using two dimensional arrays. A two dimensional array requires two
dimensions. It is also called as matrix.

Fundamentals of Computer Operating and Programming 277


C.O.P.A. Trade of I.T.I RD S

• Two dimensional Array Declaration :-


Declaration of two dimensional arrays is same as one dimensional array
only we have to specify two dimensions.

Syntax :-
Data type array name [row size][column size]

Example :-

int V [4][3]; Creates a 4 by 3 matrix.


int n [2][2]; Creates a 2 by 2 matrix.
char name [5][10]; Declares a character array with 5 elements and
10
characters width for each element.

• Character array can be initialized as :-


char name [3][10];
Or
char name [3][10] = {"Parag","Ram","Akshay"};
Or
char name [3][10] = {
"Parag",
"Ram",
"Akshay"
};

Name array can hole 3 names with maximum of 10 characters length.

Fundamentals of Computer Operating and Programming 278


C.O.P.A. Trade of I.T.I RD S

• The array will be stored in memory as :-

n [0][0] n [0][1] n[1][10] n[1][1]

10 20 30 40

Array stored in memory

• The character array will look like :-

name [0] P a r a g \0

name [1] R a m \0

A k s h y \0
name [2]

Character Array

Fundamentals of Computer Operating and Programming 279


C.O.P.A. Trade of I.T.I RD S

Example :- Program to display the number stored in two


dimensional arrays
in a matrix form.

# include <stdio.h>
main ( )
{
int n[3][3];
int i , j;
printf ( "\n Enter the numbers for a 3 by 3
array :");
for (i = O ; i<3; i++)
{
for (j = O ; j<3; j++)
{
scanf ("%d", & n [ i ] [ j ]);
}

}
printf ("\n the numbers are : \n");
for (i = O; i<3 ; j++)
{
for ( j = O ; j<3; j++)
{
printf ("%3d", n [i ] [ j ]);
}
printf ("\n);
}
getch ( );
}
It the numbers entered as 1 2 3 4 5 6 7 8 9 then they are printed in
following format

1 2 3
4 5 6
7 8 9

The program contains a two dimensional array of 3 rows and 3


columns. A nested for loop is used to accept and display numbers in
each element. To vary the elements i and j counter variables are used.
%3d is a formatted operator which will set the width as 3 for each
element. Character '\n' is given outside the inner loop as the line changes
for each row only. Individual element can be referred as n [ i ] [ j ].

Fundamentals of Computer Operating and Programming 280


C.O.P.A. Trade of I.T.I RD S

This mechanism can be used for matrix operations like matrix addition,
matrix, multiplication etc.

Example :- Program to perform matrix multiplication.


# include <stdio.h>
main ( )
{
int m1[2][2], m2[2][2], m3[2][2];
int i , j , k;
printf ("\n Enter matrix 1 :");
for (i = O; i<2; i++)
{ for ( j = O; j<2; j++)
{
scanf ("%d", & m1[ i ]
[ j ] );
}
}
printf ("\n Enter matrix 2 :");
for (i = O; i<2; i++)
{ for ( j = O; j<2; j++)
{
scanf ("%d", & m2 [ i ] [ j ] );
}
}
for (i = O; i<2; i++)
{ for ( j = O; j<2; j++)
{
m3 [ i ] [ j ] = O;
for (k = O; k<2; k++)
{
m3 [ i ] [ j ] + = ( m1 [ i ] [ k ] * m2 [ k ]
[ j ] );
}
printf ("%3d", m3 [ i ] [ j ] );
}
printf ("\n");
}
getch ( );
}
In above example three for loops are used. Third for loop is for k . In
matrix multiplication one row of first matrix is multiplied with each
column value of second matrix and final addition will be stored in the
resultant matrix. To repeat the multiplication and to perform their
addition k loop is used. The current multiplication will be added to the
previous multiplication and it will be stored in the resultant matrix i.e.
m3 [ i ] [ j ].

Fundamentals of Computer Operating and Programming 281


C.O.P.A. Trade of I.T.I RD S

STORAGE CLASSES

Variable declaration is the important step of any program. To store


different values we need a variable. While declaring the variable we
have to specify its 'data type' as well as its 'storage class' i.e. all the
variables always have some default storage class. When a variable is
defined it gets stored at particular location in computer. There are
mainly two types of locations where values can be stored : 1) Memory
2) CPU registers. the storage class determines these locations.

These Storage classes tells us

i) Where the variable would be stored.


ii) What will be the default initial value of the variable if not specified.
iii) Scope of the variable i.e. in which function the variable is available.
iv) Life of a variable.

 There are four storage classes in C :-


a) Automatic Storage Class.
b) Register Storage Class.
c) Static Storage Class.
d) External Storage Class.

• Automatic Storage class :-


It is the default storage class for any variable if not specified.

Its characteristics are :-

Storage :- Memory
Default Initial Value :- A garbage value or unpredictable value.
Scope :- Is accessible to the block only in which it is
defined.
Life :- Remain in existence till the control is within
the block.

The variable should be declared using Auto keyword. It gets stored in


memory.

Fundamentals of Computer Operating and Programming 282


C.O.P.A. Trade of I.T.I RD S

Example: - Program to illustrate Auto storage class.


# include <stdio.h.
main ( )
{
auto int i , j;
printf ("\n %d %d", i , j);
}

The above program will print any two values as


2765 1211

Where 2765, 1211 are the garbage values of i and j. These variables are
not accessible by any other function in the program. Its scope and life is
restricted for the procedure in which it is defined.

• Register Storage Class:-

Register storage class is having following features:-

Storage :- CPU Register.


Default initial value :- Garbage value.
Scope :- Local to the block in which it is defined.
Life :- Till the control remains within the
block.

Values stored in the CPU register can be accessed faster than the values
stored in memory. When any variable is occurring multiple times in the
program, its storage class should be register.e.g. Loop counter variables
can be stored in the register as its values changes many times in the
program. Only the thing to remember is that CPU registers are limited.
.If the variable doesn't get stored into register because of unavailability
of space then the variable will be considered as auto. We can not use
register storage class for all types of variables.

Example: - Program that demonstrates register storage class.


# include <stdio.h>
main ( )
{

Fundamentals of Computer Operating and Programming 283


C.O.P.A. Trade of I.T.I RD S

register int i ;
for (i = 1; i<=20; i++)
{
printf ("\n %d", i);
}
}
Here variable i is stored in register so it gets accessed faster in the loop.

• Static Storage Class :-


Following are features of static storage class :-
Storage :- Memory
Default initial Value :- Zero
Scope :- Local to the block in which it is defined.
Life :- Value of the variable remains static
between
different function calls.

The value of static variable remains alive through the whole program.
That is the variable gets initialized only once.

Example :- Program that illustrates static storage class.


# include <stdio.h>
void increment ( );
main ( )
{
increment ( );
increment ( );
increment ( );
}
void increment ( )
{
static int i = 1;
printf ("\n %d", i);
i=i+1;
}

Here the variable i is defined as static in the function increment ( ) and


the function is called three times in the main ( ) function. The value of i
will be printed as :
1
2
3

Here variable gets initialized only once. For other function calls, the
value remains as it is. So the output is in incremented form. Static
variables are also local to the block in which it is defined. If the variable
is defined auto every time the value of i will be printed as
1

Fundamentals of Computer Operating and Programming 284


C.O.P.A. Trade of I.T.I RD S

1
1

External Storage Class :-

The feature of External storage class is :-

Storage :- Memory
Default initial value :- Zero

Example: - Program for extern storage class.


# include <stdio.h>
void increment ( );
void decrement ( );
extern int i =1;
main ( )
{
printf ("\n %d", i );
increment ( );
decrement ( );
i = i-1;
printf ("\n %d ", i);
}
void increment ( )
{ i = i + 1;
printf ("\n %d", i);
}
void decrement ( )
{ i = i - 1;
printf ("\n %d ", i );
}

The output of the program is

1 / / initial value of i
2 / / changed by increment ( ) function.
1 / / changed by decrement ( ) function.
0 / / again changed in main ( ) function.

This shows that the variable is accessible by all the functions in the
program and its values also remain as it is. Initial value of i is 1 it gets
incremented by the increment ( ) function i.e.2. Then it will be
decremented by decrement ( ) function i.e. again 1 and finally it gets
decremented by the main ( ) function, so the final value of i is 0.

Fundamentals of Computer Operating and Programming 285


C.O.P.A. Trade of I.T.I RD S

Example: - Program to illustration extern storage class.


void show ( );
# include <stdio.h>
int i = 10;
main ( )
{
int i = 20;
clrscr ( );
print ("\n %d", i);
show ( );
}
void show ( )
{ print ("\n %d ", i );

The output is :-
20
10

The i variable is defined two times. The variable defined inside main ( )
is local variable and variable above main ( ) is global which is
accessible by any function in the program. So print ( ) statement in main
( ) will print the value of i as 20 . Then it is calling show ( ) function
which will print the value of i as 10 it access the global i variable . The
states that "in any function the local variable gets preference over the
global variable".

STRUCTURES

In real world application we have to deal with


different type of data like numbers, character or fractional values. e.g. a
system, which maintains employee information, may have the
information like empno, name, salary, join_date, job etc. Where empno
is integer type, name is character type. To handle all these values with
different variable name is difficult task. To avoid this C provides the
new data type 'Structure'.

"A structure contains a number of data types grouped together. These


data types may or may not be of the same types". It can collect different
type of data items that comprise a given entity. e.g. employee
information, student information, book information etc. Structure is also
known as derived data type or user defined data type. All the values of
structure can be handled using a single variable name known as
structure variable.

Fundamentals of Computer Operating and Programming 286


C.O.P.A. Trade of I.T.I RD S

 Declaring a Structure:-
The general form of a structure declaration is:-

Struct <structure name / tag name >


{
structure member 1;
structure member 2;
structure member 3;
..........
..........
..........
};

Example:-
struct book
{
char name [15];
float price;
int pages ;
};

This statement defines a new data types called struct book.


Each variable of this data type will consist of character variable name a
float variable called price and integer variable pages.
Once the new structure data type is defined one or more variables can be
declared to be that type. For example the variables b1, b2, b3; can be
declared to be of type struct book as
struct book
{
char name [15];
float price;
int pages;
} b1,b2 , b3;

OR it can be defined in the main function like:

main ( )
{
struct book
{
char name[15];
float price;
int pages;
};
struct book b1, b2, b3;
}

Fundamentals of Computer Operating and Programming 287


C.O.P.A. Trade of I.T.I RD S

Generally structure should be declared outside any function and still


structure variable can be declared in main ( ) or any other function. Like
primary variables and arrays, structure variables can also be initialized
when they are declared.

Example :-

struct book
{
char name[10];
float price;
int pages ;
};
struct book b1 = {"Basic", 130.00, 500};
struct book b2 = {"Physics", 80, 900};

Note the following points while declaring a structure type :-

i) The structure declaration statement must end with a semicolon ( ';' ).


ii) The structure declaration statement does not tell the compiler to
reserve any space in memory, it just defines a form of a structure.
iii) Usually the structure should be declared above the main ( ) function.
It can also be declared in a separate header file.
iv) To access the structure members a structure variable is required.

 Accessing Structure member :-

In arrays we can access individual elements of an array using a


subscript. Structure uses a different scheme. They use a dot ( '.') operator
with the structure variable. e.g. to refer to individual member of the
structure we have to give b1.pages, b2.price etc.

The general form for this is :-

structure variable . structure member

Note that before the dot there must always be a structure variable and
after the doe there must always be a structure element (member).

Unlike arrays structures are also defined in consecutive memory


locations.

b1.name b1.price b1.pages


Basic 130.00 550
1001 1002 1006
Fundamentals of Computer Operating and Programming 288
C.O.P.A. Trade of I.T.I RD S

Memory Map of Structure

Fundamentals of Computer Operating and Programming 289


C.O.P.A. Trade of I.T.I RD S

Example 1:- To accept student's information like rno, name, marks


of
subjects etc, and store it in the structure defined.

# include <stdio.h>
struct student
{
int rno;
char name [20];
int m1, m2, tot;
float per;
};
main ( )
{
struct student s1 = { 1, "Ram", 70, 70, 140, 70};
clrscr ( );
printf ("\n \t The student information");
printf ("\n \t ------------------------------------------------");
printf ("\n \t Roll No. Name Sub1 Sub 2 Total Percentage");
printf ("\n \t %d %s %d %d %d %d
%.2f", s1.rno,
s1.name , s1.m1, s1.m2, s1.tot, s1.per ");
getch ( );
}

In above example the information is directly given in the program and it


is printed one by one. The members are referred as s1.rno, s1.m1 etc.
Following example illustrates how data can be accepted in multiple
structure variables.

Example 2 :- To store information for three books in the structure.


# include <stdio.h>
main ( )
{
struct book
{ char name [15];
int price, pages;
};
struct book b1, b2, b3;
printf ("\n Enter name, prices & no of pages
for 3 books");
scanf ("%s %d %d ", b1.name, & b1.price, &
b1.pages ");
scanf ("%s %d %d", b2.name, & b2.price, &
b2.pages");
printf ("\n The data you entered is ");

Fundamentals of Computer Operating and Programming 290


C.O.P.A. Trade of I.T.I RD S

printf ("\n %s %d %d ", b1.name, b1.price,


b1.pages);
printf ("\n %s %d %d", b2.name, b2.price,
b2.pages);
printf ("\n %s %d %d", b3name,b3.price,
b3.pages);
}

 Array of structure :-
In above program to store data for 100 books we have to define different
structure variables from b1 to b100, which is not very convenient.
Similarly printf ( ) and scanf ( ) statements are given three times which
increases the length of program. A better approach would be to use an
array of structures. The structure variable can be declared as array to
store data for multiple books. It is manipulated in the same way as the
normal array is.

Example :- Program to store multiple records in the array of


structures.

# include <stdio.h>
main ( )
{
struct book
{ char name[15];
int price;
int pages;
};
struct book b[100];
for (i = O; i < = 99; i++)
{
printf ("\n Enter the name, price & pages ");
scanf ("%s %d %d", b[i].name, & b[i].price, & b[i].pages);
}
for ( i = O; i< = 99; i++)
{
printf ("%s %d %d", b[i].name, b[i].price,
b[i].pages");
}
}

Fundamentals of Computer Operating and Programming 291


C.O.P.A. Trade of I.T.I RD S

 Nested Structure :-
One structure can be defined within another structure. This is known as
nesting of structures. Using this facility complex data types can be
created.

Example :- Program that demonstrates nested structure.


# include<stdio.h>
main ( )
{
struct address
{
char phone [15];
char city [25];
int pin;
};
struct emp
{
char name [20];
struct address a;
};
struct emp e = {"Bharti","358649","A'bad",
431005};
printf ("\n Name = %s \t Phone = %s",
e.name,e.a.phone);
printf ("\n City = %s \t Pin = %d",
e.a.city,e.a.pin);
}

In the same way the whole structure can be declared within another. the
value of a structure variable can be assigned to another structure
variable of the same type using the assignment operator.

Example :- Program that copies one structure variable to another.


# include<stdio.h>
main ( )
{
struct employee

Fundamentals of Computer Operating and Programming 292


C.O.P.A. Trade of I.T.I RD S

{ char name [10];


int age;
float salary: };
struct employee e1 = {"Shrishti", 29,80000};
struct employee e2,e3;
strepy (e2.name,e1.name);
e2.age = e1.age;
e2.salary = e1.salary;

OR

all elements at one go as


e3 = e2;
printf ("\n %s %d %.2f", e1.name, e1.age,
e1.salary");
printf ("\n %s %d %.2f", e2.name, e2.age,
e2.salary");
printf ("\n %s %d %.2f", e3.name, e3.age,
e3.salary");
}

The above program will set and print same data for the entire three
variables.

FUNCTIONS
Sometimes it is required to execute a group of statement in a program
multiple times at different situation.E.g. if we need to perform the
addition of two numbers multiple times in the program, for this we have
to write the same code for numbers of times in the program. This
increases the program length and reduces the program efficiency. To
overcome this function concept is used.

" A function is set of instructions used to do a specific task". Every C


program is a collection of such functions. One feature of c is that "C is a
collection of functions".

C functions can be classified into two categories, namely


• Library Function (Built In functions).
• User Defined Function.

 Library functions:-
Library Functions are the commonly required functions grouped
together and stored in a library. They are predefined functions and can
be called anywhere. E.g. printf ( ), scanf ( ), sqrt ( ), strlen ( ) etc.
Following are some Library Functions given category wise

Fundamentals of Computer Operating and Programming 293


C.O.P.A. Trade of I.T.I RD S

• Mathematical Functions Header File :


math.h

i) int abs (number) :- Returns the Absolute Value of given


number.
ii) int sqrt (number) :- Returns the Square Root of a given number.
iii) int pow (m,n) :- Returns the nth power of number m.
iv) int random (num) :- Generates random number between 1 to
( num - 1),
defined in stdlib.h

Fundamentals of Computer Operating and Programming 294


C.O.P.A. Trade of I.T.I RD S

Example: - Program to implement the above functions.


# include<stdio.h>
# include<math.h>
# include<stdlib.h>
main ( )
{
int n=5, a, m=3, b;
float x;
printf ("\n Enter number for Absolute Value:");
scanf ("%d", &a);
printf("\n Absolute value of %d = %d", a, abs (a));
printf ("\n Enter number for square root :");
scanf ("%f", &x);
printf ("\n Square Root of %.2f = %.2f", x , sqrt (x));
printf ("\n The %dth power of %d = %d", m, n , pow (n,
m));
printf ("\n Random number = %d %d %d ", random
(50),
random 950), random (50);
}

• String Functions :- Header file :


string.h

i) strlen (string exp ) :- Returns the length of the given string.


ii) strcpy (string1, string 2) :- Copies the string 2 into string 1.
iii) stcvmp (string 1, string 2) :- Compares two strings & returns
the integer
difference.
iv) strrev (string1) :- Reverse the given string provided as
argument.
v) strcat (string 1, string 2) :- Concatenate (appends string 2 with
string 1.

Fundamentals of Computer Operating and Programming 295


C.O.P.A. Trade of I.T.I RD S

Example 1 :- Program to implement the above functions.


# include<stdio.h>
# include<string.h>
main ( )
{
char str1[30], str2[25], str[25];
int a, b;
printf ("\n Enter String1:");
gets (str1);
printf ("\n Enter String 2:");
gets (str2);
printf ("\n Length of String1 = %d",
strlen (str1));
strcpy (str3, str2);
printf ("\n String3 -- %s", str3);
strrev (str3);
printf ("\n String3 after reversing = %s",
str3);
strcat (str1, str2);
printf ("\n String1 after concatenation =
%s", str1);
}

Example 2:- Program that demonstrates strcmp ( ) function.


# include<stdio.h>
# include<string.h>
main ( )
{
char str1[25], str2[25];
int a;
printf ("\n Enter String1:");
gets (str1);
printf ("\n Enter String2:");
gets (str2);
a = strcmp (str1, str2);
if ( a>0)
printf ("\n Strings are in reverse
alphabetical order");
else if (a<0)
printf ("\n Strings are in alphabetical
order");
else
printf ("\n Strings are equal");
}

Fundamentals of Computer Operating and Programming 296


C.O.P.A. Trade of I.T.I RD S

• Character functions :- Header file : ctype.h

i) toupper (char exp.) :- Converts a single character into


uppercase.
ii) tolower (char exp.) :- Converts a single character into
lowercase.
iii ) isupper (char exp.) :- Checks whether the given character is in
uppercase
or not.
iv) islower (char exp.) :- Checks whether the given character is in
lowercase or not.

Example 3 :- Program that demonstrates toupper ( ) and tolower ( )


functions.

# include<stdio.h>
# include<ctype.h>
# include<string.h>
main ( )
{
char str[20];
int i;
printf ("\n Enter a string:");
gets (str);
for (i = 0; i<strlen (str); i++)
{
if (str[i] > =97 && str[i] < 123)
printf ("%c", toupper
(str[i]) );
else
printf ("%c", tolower
(str[i]) );
}
}

 User Defined Functions :-


User defined functions are the functions defined by the user to do a
specific task. E.g. addnum ( ), show ( ) print line ( ) etc. The main
difference between these two categories is that library function are not
required to be written by user where as a user defined function has to be
developed by the in the program itself.

Fundamentals of Computer Operating and Programming 297


C.O.P.A. Trade of I.T.I RD S

 Need for user defined function :-


Every program must have a main function to indicate where the program
has to begin its execution. While it is possible to code any program
utilizing only main function, it leads to a number of problems. The
program may become too large and complex and as a result the task of
debugging, testing and maintaining becomes difficult.
If a program is divided into functional parts ( subprograms), then each
part may be independently coded and later combined into a single unit.
These subprograms are called as 'Function' and they are much easier to
understand, debut and test.

• Advantage of User Defined Function :-

• Using functions at appropriate places we can reduce the length of


source program. This factor is particularly critical with
microcomputers where memory space is limited.
• It is east to locate and isolate a faulty function for further
investigations.
• Many other programs may use the same function.
• Using function it becomes easier to write the programs and to keep
the track of what they are doing.

•A Multi - Function Program :-


A function is a self contained block of code that performs a particular
task. Once a function has been designed and packed, it can be treated as
"BLACK BOX" that takes some data from the main program and returns
a value. All that the program knows about a function is : What goes in
and what comes out . Every C program can be designed as collection of
these black boxes.

Example :-
printline ( )
{
int i;
for (i = 1; i< 30; i++)
printf ("-");
}

The above set of statements defines a function called printline ( ) which


could print a line of 30-character length. This function can be used in a
program as follows:-

main ( )

Fundamentals of Computer Operating and Programming 298


C.O.P.A. Trade of I.T.I RD S

{
printline ( );
printf ("\n This program says c function \n");
printline ( );
}
printline ( )
{
int i;
for (i=1; i<40; i++)
{
printf ("-");
}
printf ("\n");

Output: - A line of 30 characters will be printed. This Program says c


function.

The above program contains one user-defined function: printline ( )

As you know, the program execution always begins with the main
function. During execution of the main, the first statement encountered
is printline ( ); which indicates that the function is to be executed. A
function gets called when the function name is followed by a semicolon.
As this point, the program control gets transferred to the function
printline ( ). After executing the function a line of 30 characters length
will gets printed. The control is transferred back to the main, now the
execution continues with the statement next to printline. After executing
the printf ( ) function the control is again transferred to the
printline ( ) and the line gets printed once more. Here printline ( ) is a
called function and main ( ) is a calling function.

* The Form of C Functions:-


All function has the form:

return type function name (argument list)


{
group of statements;
return (expression);
}

All parts are not essential. For example, the argument list and its
associated argument declaration part is optional. The declaration of local
variable is required only when any local variable are used in the

Fundamentals of Computer Operating and Programming 299


C.O.P.A. Trade of I.T.I RD S

function. In the example discussed in the previous section, the main


does not required any local variables, while the printline ( ) function
used one local variables i.e. A function can have any number of
executable statements. A function that does nothing may not include any
executed statement at all. The return statement is the mechanism for
returning a value of the calling function. This is also an optional
statement. It is not given; it indicates tat no value is being returned by
the function.
Writing a function in the program includes three steps.
1) Function Prototype.
2) Function Call.
3) Function Definition.

• Function Prototype:-
It is the declaration statement of the function. It tells the compiler what
type of function it is i.e. return type, parameter type of the function etc.
It should be given above the main ( ) function and it should have a
semicolon. The general form of the prototype statement is :
Return type function name (parameter type):

Example: - void printline ( ) void states that function is


not returning any value.
Or int add (int, int) int states that the function is taking
two int
values and it is returning int value.
Or char find ( ) char states that fine ( ) function is
returning
character value.

* Function call:-
It is a statement using which the function gets executed. When a
function call gets encountered control jumps from main program to the
function definition block. After executing the function statements it
returns to the main program and execute the statement next to the
function call. We can call the function anywhere in any function or
program. A function can also be called into itself; this is known as
'Recursion'.

• Function Definition:-
In the function definition we have to write the code for that function.
The function definition must be outside any function or it can be in the
other program also. We can call the same function for number of times
in the program. We can call or define more than one function in a single
program in a random sequence. The function definition statement should
match with the function prototype statement.

Fundamentals of Computer Operating and Programming 300


C.O.P.A. Trade of I.T.I RD S

• Category of functions:-
A function depending on whether arguments are present or not and
whether a value is returned or not, may belong to one of the following
categories.

1. Function with no argument and no returning values [void


function]
2. Function with argument and no returning values.
3. Function with arguments and with returning values.

• Void function:-
When a function has no arguments and it doesn't return anything then is
called as void function. It does not receive any data from the calling
function. Similarly when it does not return a value, the calling function
does not receive any data from the called function. In fact there is no
data transfer between the calling and the called function. The complete
procedure is performed by the function itself.

Function 1 ( ) No Input Function 2 ( )


{ {
------------- ----------------
Function 2 ( ) ----------------
------------- No Output
----------------
------------- }
}

Void Function

No data communication between functions.

Example 1:-

# include <stdio.h>
void add ( ); > Function
Prototype
main ( )
{
clrscr ( ); > Function Call
add ( );
getch ( );
}

Fundamentals of Computer Operating and Programming 301


C.O.P.A. Trade of I.T.I RD S

Void add ( ) > Function


Definition
{
int a, b, c;
printf ("\n Enter two numbers:");
scanf ("%d %d", & a, & b);
c = a + b;
printf ("\n Addition = %d", c);
}

Here add ( ) is a user defined function that will perform the addition of
two numbers. It is a void function, which does not take or return any
value. Void add ( ): is the prototype statement of the function. It is
called in the main ( ) function and it is defined below the main function
It can be called anywhere in the program.

Example 2:- Program to accept a string and to convert it into


uppercase using upper ( ) UDF.

# include<stdio.h>
void upper ( );
main ( )
{
clrscr ( );
upper ( );
getch ( );
}
void upper ( )
{
char str[50];
int i;
printf ("\n Enter a string :");
gets (str);
for (i=O; i<strlen (str); i++)
{ if (str[i] >=97 && str[i] < 123)
{ str[i] = str[i] - 32; }
}
print ("\n String in upper case : %s", str);
getch ( );
}

Fundamentals of Computer Operating and Programming 302


C.O.P.A. Trade of I.T.I RD S

• Function with Arguments but no return


values:-
We could make the calling function to read data from the user and pass
it on to the called function .This approach seems to be because the
calling functions can check for the validity of data if necessary before it
is handed over to the called function.

Function1 ( ) arguments
Function 2 (b)
{ {
One way data
---------------- ------------------
Function 2 (a) Communication ------------------
----------------- ------------------
} }
Values

Function with arguments but no return values

There are actual and format arguments. Actual arguments are the one
that are passed to the called function e.g. a in above example and format
arguments are the one that are given in the called function to store the
value passed from function. They should match in their data type and
order.

• Arguments matching between calling function and the called


function:-

We should ensure that the function call has matching arguments. Incase
the actual arguments are amore than the formal arguments (m >n), the
extra actual arguments are discarded on the other hand, if the actual
argument are less than the formal argument the unmatched formal
arguments are initialized to some garbage values. Any mismatch in data
types will give error.

While the formal arguments may be variables names, the actual


arguments may be variable names, expression or constants. The variable
used in actual arguments must be assigned values before the Function
call is made. When a function call is made only a copy of the values of
actual arguments is passed into the called function. What occurs inside
the function will have no effect on the variables used in the actual
arguments list.

Fundamentals of Computer Operating and Programming 303


C.O.P.A. Trade of I.T.I RD S

• Parameter Passing:-

We can pass the value of parameter to the function using two methods.
1) Call by value.
2) Call by reference.

• Call by value:-
In this method we have to pass the value to the function by directly
specifying the variable name with the function call. In this method a
copy of the original arguments gets created in the function and value in
the actual variable will remain same.

• Call by reference:-
In this method the value should be passed by passing the address
(reference) of variable. In this method the original value will gets
changed by the function. The variable inside the function should be of
pointer type.

Examples based on first method are discussed here. The second method
will be used with pointer concept further.

Example: - Program to create a UDF add ( ) by passing parameter


to the function.

# include<stdio.h>
void add (int, int);
main ( )
{
int a, b;
printf ("Enter two numbers:");
scanf ("%d %d", & a, & b);
add (a, b);
getch ( );
}
void add ( int x , int y )
{
int c;
c = x+y;
printf ("Addition of %d and %d is = %d", x ,
y , c);
}

Fundamentals of Computer Operating and Programming 304


C.O.P.A. Trade of I.T.I RD S

Here a , b are the actual arguments and x , y are the formal arguments.
Two numbers are accepted into a and b and they will be passed to the
function when it is called. The value a will be passed into x and value of
b will be passed to y. Similarly we can pass float or character values to
the function. The name of the actual arguments and formal arguments
can be same as they are considered as local variables.
The result will be printed if a = 10 and b = 20 as

Addition of 10 and 20 is = 30.

• Function with Return Values :-


Unlike passing values to a function, function can return a value also. A
function that receive a predefined form of input and again returns
desired values. Such function will have two way data communication.
Function can return a single value at a time.

Fig: - Two way data communication between functions.

Function ( ) Value of Function 2 (b)


{ Arguments. {
Var; -----------------
-------------- -----------------
Var = Function 2 (a) return (value);
----------------- }
} Result

Functions with Return Values.

Fundamentals of Computer Operating and Programming 305


C.O.P.A. Trade of I.T.I RD S

Example: - The above add ( ) function with returning values.


# include <stdio.h>
int add (int , int);
main ( )
{
int a,b,c;
scanf ("%d %d", &a , &b);
c = add (a , b);
printf ("Addition = %d",c);
OR
printf ("Addition = %d", add (a,b);
getch ( );
}
int add (int x , int y)
{
int c;
c = a+b;
return c; OR return (a + b);
}

Here the add ( ) function is returning an integer value i.e. the addition of
number passed which gets stored into c in main ( ) function and then it is
printed.

Function with Arrays :-

Like the values of simple variable it is also possible to pass the value of
an array to a function. Entire array can not be passed directly to the
function. It can be passed element by element.

Fundamentals of Computer Operating and Programming 306


C.O.P.A. Trade of I.T.I RD S

Following example illustrates this

# include<stdio.h>
# include<conio.h>
void show (int);
main ( )
{
int n[5] = { 10 , 20, 30, 40, 50};
int i;
for (i = O; i<5; i++)
{
show (n [i]);
}
getch ( );
}
void show (int k)
{
printf ("\n %d", k);
}

Here the array is passed element by element to the function so the


function should be called multiple times in the loop.

We can pass an entire array to a called function at a time. It is sufficient


to list the name of the array, without any subscript, and the size of the
array as arguments. This avoids multiple function calls. For example,
the call largest
(a, n) will pass all the elements contained in the array 'a' of size 'n' the
called function expecting this call must be appropriately defined. The
largest ( ) function header might look like:

float largest (float array [ ], int size)

{ }

The function largest is defined with two arguments, the array name and
the size of the array to specify the number of element in the array. The
declaration of the normal argument array is made as follows:
float array [ ];

The pair of brackets informs the compiler that the argument array is an
array of number . It is not necessary to specify the size of the array here.
Another way to pass an entire array to the called function at a time is
using pointer.

Fundamentals of Computer Operating and Programming 307


C.O.P.A. Trade of I.T.I RD S

Example :- Program to find largest stored in the array by defining a


function.

# include<stdio.h>
float largest (float [ ], int);
main ( )
{
float num [4] = {2, 5, - 4.75, 13.67, 4.20 };
printf ("\n Largest number is = %.2f", largest
(num,4));
}
float largest (float a[ ], int n)
{
int i;
float max = 0;
for (i=0; i< n; i++)
{ if (a[i] > max )
max = a[i];
}
return (max);
}

In above example largest ( ) function finds the largest number present in


the array passed as an argument. The function takes two arguments, the
entire array is passed by specifying the array name (i.e. num) and second
argument is the size of the array (i.e. 4) . Function returns the largest
value to main ( ) function. In the largest function the size (dimension) of
the array is not specified.

 Passing structure data to function :-


Unlike arrays structure data can also be passed to the function. Structure
contains different type of data. We can entire structure at a time to the
function or individual members can also be passed. To pass the whole
structure to the function specify the structure variable in the function
call i.e. function can take argument of structure type.

Fundamentals of Computer Operating and Programming 308


C.O.P.A. Trade of I.T.I RD S

Example :- Program to display structure data through function.


# include<stdio.h>
struct stud
{ int rno, m1, m2, tot;
char name [15];
float per;
};
void display ( struct stud);
main ( )
{ struct stud s1;
printf ("\n Enter rno, name and marks of two subjects:");
scanf (" %d %s %d %d ", %d", &s1.rno, s1.name, &s1.m1,
&s1.m2);
s1.tot = s1.m1 + s1.m2;
s1.per = s1.tot / 2;
display (s1);
getch ( );
}
void display (struct stud s2)
{
printf ("\n Roll no. Name Sub1 Sub2 Total Percentage ");
printf ("\n -------------------------------------------------------------------");
printf ("\n %d %s %d %d %d %.2f", s2.rno,
s2.name, s2.m1, s2.m2, s2.tot, s2.per);
}

Here the complete structure variable s1 is passed to the function to


access all the members. We can also pass individual members to the
function as per the requirement.

Fundamentals of Computer Operating and Programming 309


C.O.P.A. Trade of I.T.I RD S

Example :- Program to pass individual members to the function.


# include<stdio.h>
struct stud
{
int rno, m1,m2, tot;
char name [15];
float per;
};
void calc (int, int)
main ( )
{
struct stud s1;
printf ("\n Enter rno, name and marks of two subjects for one
student :"); scanf ("%d %d %d %d", &s1.rno, s1.name, &s1.m1,
&s1.m2);
printf ("\n \n STUDENTS INFORMATION ");
printf ("\n ---------------------------------------------");
printf ("\n\n Roll no. Name Sub1 Sub2 Total Percentage");
printf ("\n
------------------------------------------------------------------");
printf ("\n %d %s %d %d", s1.rno, s1.name,
s1.m1, s1.m2);
calc (s1.m1, s1.m2);
getch ( );
}
void calc ( int a, int b)
{
int t;
float p;
t=a+b;
p = t / 2;
printf (" %d %.2f", t , p);

In above example the structure members m1 and m2 are passed to the


function to calculate total and percentage.

Fundamentals of Computer Operating and Programming 310


C.O.P.A. Trade of I.T.I RD S

POINTERS
Consider the declaration

int i = 3;

When a variable is defined , three attributes gets associated with it : 1)


Location number (Address). 2) value at location (variable). 3) Location
name. We may represent location in memory by the following memory.

Location
Number 6485

3 Value at
Location I
Location
Name

Memory Map of a variable

See that computer has selected memory location 6485 as the place to
store the value 3 & it is i's address in a memory. In general programs
whenever a variable is used in any statement, to access its value we have
to search the memory by the variable name. This requires lot of time
when there is large amount of data to be accessed like structure, arrays
etc. Every time the variable is encountered it has to be searched in the
memory. To reduce this time Pointers can be used.

" A pointer is a kind of variable that holds the address of another -


variable".

Fundamentals of Computer Operating and Programming 311


C.O.P.A. Trade of I.T.I RD S

 Declaration of pointers :-
To declare a pointer '*' operator is used. The pointer name statement
must precede with '*' operator.
Pointer name can be any valid name.

Syntax :-
Datatype *pointername;

Example :-
int *p;
char *str;

Here 'p' is an integer pointer and 'str' is a character pointer. The


datatype of the pointer should be same as the datatype of that variable
whose address is stored in the pointer.

Using Pointers the value can be accessed by its address i.e. 6485 in
above example. We can print this address through the following
program.

Example 1 :- Program that demonstrates pointer concept.


# include<stdio.h>
main ( )
{
int i = 3;
printf ("\n Address of i = %u", & i);
printf ("\n Value of i = %d", i);
}
The output of program :-

Address of i = 6485
Value of i = 3

Here "&" used in this statement is 'address of operator' which takes


the address (location number) of the variable i i.e. 6485. We have seen
the use of '&' operator in scanf ( ) function to get address of variable. %u
is used as unsigned integer to print this address. The location number is
a long type of value and it may exceed the integer range 32767 and the
address may get printed negative using '%d' operator. To print the
correct address '%u' is used.

Fundamentals of Computer Operating and Programming 312


C.O.P.A. Trade of I.T.I RD S

Pointers are manipulated using two operators.

'&' :- 'Address of' operator


'*' :- 'Value at address' operator.

'&' is used to take the address of variable and '*' is used to get the value
stored at a particular address. The value at address operator is also called
"indirection" operator.

Following program illustrates the use of pointers to access the value.

Example: - Program to print the value of a variable using pointer.


# include<stdio.h>
main ( )
{
int i =3;
int *p;
printf ("\n Address of i = %u", & i);
printf ("\n Address of i = %u", p);
printf ("\n Value of i = %d", i);
printf ("\n Value of i = %d", * (& i));
printf ("\n Value of i = %d", *p);
getch ( );
}

Output:-
Address of i = 6485.
Address of i = 6485.
Value of i = 3
Value of i = 3
Value of i = 3

Note that printing the values of "*(&i)" is same as printing the value of
"i" as '*' refers to the value at the address given using '&i'.

Here we have declared a pointer as *p. The address of the variable must
be assigned to the pointer before accessing.

Fundamentals of Computer Operating and Programming 313


C.O.P.A. Trade of I.T.I RD S

Example:-
p = & i;

Now the memory map is

6485
6530
3
I 6485
P

Memory map

As you can see,

i's value is 3 and


p's value is address of i.

Example: - Program for addition of two numbers using pointers.


# include<stdio.h>
main ( )
{
int a= 10, b=20, c;
int *p,*q,*r;
p = & a;
q = & b;
r = & c;
*r = *p +*q;
printf ("Addition of two no. is = %d", *r);
}

Fundamentals of Computer Operating and Programming 314


C.O.P.A. Trade of I.T.I RD S

 Pointer to function:-
Arguments can be passed to the function using two methods.
1) Call by value. / / As discussed in Function
concept.
2) Call by reference.

In the call by value method the value of each argument in the calling
function is copied to the corresponding formal arguments of the called
function. With this method the changes made to the format arguments in
the called function will not affect to the values of actual arguments in
the calling function. That is in this method original values will not be
updated by the function.

In call by reference method the address of the actual arguments in the


calling function are copied to the format arguments of the called
function. That is using these address the actual arguments (values) are
accessible by the called function. Whatever the changes made by the
function will be affected to the actual arguments (values).

Example: - To interchange the value of two variables using call by


reference method.

# include<stdio.h>
main ( )
{
int a = 10, b =20;
printf ("\n A = %d B = %d", a,b);
swap (&a,&b);
printf ("\n A = %d B = %d", a,b);
}
swap (int *p, int*q)
{
int t;
t = *p;
*p = *q;
*q = t;
printf ("\n A = %d B = %d", *p, *q);
}

The output of above program is


A = 20 B = 10
The swap ( ) function interchanges the values of a and b using their
addresses stored in p and q. & a and & b will copy the address of a and b
into the p and q in the called function.

Fundamentals of Computer Operating and Programming 315


C.O.P.A. Trade of I.T.I RD S

 Pointer to structures:-

Unlike a simple variable we can access the structure members using


pointer. The pointer pointing to a structure is known as 'Structure
Pointer'. Structure members are accessed through the structure variable
using '.' operator. In pointer mechanism it is substituted by '-->' (arrow)
operator to access those members using pointers.

Syntax:-
Structure pointer -> structure member

 Pointer to function:-
Arguments can be passed to the function using two
1) Call by value. / / As discussed.
2) Call by reference.

Example: - Displaying the numbers stored in array using function


and pointer.

# include<stdio.h>
void display (int *. int);
main ( )
{
int n[5] = {10, 20, 30, 40, 50};
display (& n[0], 5);
}
display (int *p, int k)
{ int i;
for (i=0; i<k; i++)
{ printf ("\n %d", *p);
p++; /* Pointer pointing to next memory
location*/
}
}

Here the address of 0th element is passed to the display ( ) function.


Thus passing the base address of an array to a function is same as
passing in entire array. It is also necessary to pass the total number of
elements in the array.

Fundamentals of Computer Operating and Programming 316


C.O.P.A. Trade of I.T.I RD S

On specifying the name of the array we can get its base address i.e.
address of 0th element. An array name itself refers to its base address.
Thus following &n[0] and n will refer to the same element i.e. 0th
element. Thus by saying *n we would be able to access the 0th element
of the array. That means an array name itself acts as a pointer and it can
also be used to access the array elements using pointer. Similarly by
saying *(n+1) we can refer to the first element of the array and so on.
That is n[i] is same as *(n+i). This concept can be used to handle strings
(character arrays or two dimensional arrays easily.

Example :- To display the characters stored in the array using


pointer.

# include<stdio.h>
# include<string.h>
main ( )
{
char str[25];
int i;
printf ("\n Enter a string:");
gets(str);
for (i=0; i<strlen (str); i++)
{
printf ("%c", * (str +i));
}
}

Example :- Program to convert given string into uppercase using


pointers.

# include<stdio.h>
# include<string.h>
main ( )
{
char str[30];
int i;
printf ("\n Enter any string :");
gets (str);
for (i=0; i<strlen(str); i++)
{
if (*(str +i) >= 97 && *(str + i) <123)
printf ("%c", *(str +i) - 32);
else
printf ("%c", *(str + i));
}
}

FILE MANAGEMENT

Fundamentals of Computer Operating and Programming 317


C.O.P.A. Trade of I.T.I RD S

The function such as scanf ( ) and printf ( ) are used to read and
write data. These are the console input / output functions used to
perform input / output operations, which always use the terminal
keyboard and screen as the target place. This works line by line as the
data is small. However many real-life problems involve large volumes
of data and in such situations, the console oriented I/O operations cause
two major problems.

(1) It becomes cumbersome and time consuming to handle large


volumes of data through terminals.
(2) The entire data is lost when either the program is terminated or the
computer is turned off.

The data provided to the program is stored temporarily in the


memory. It is therefore necessary to have a more flexible approach
where data can be stored on the disks and read whenever necessary. This
method implies the concept of files to store data. The Disk input/output
operations are performed on entities called file.

"A file is a place on the disk where group of related data is stored".

"C" supports a number of functions that have the ability to perform basic
file operation. They are divided into two categories :
High level files I/O functions.
Low level files I/O functions.

High level I/O functions are more commonly used in C programs for file
operations because they do their own buffer management. Following is a
list of operations that can be performed on a file.

• Naming a file.
• Opening a file.
• Reading data from a file.
• Writing data to a file.
• Closing a file.

Fundamentals of Computer Operating and Programming 318


C.O.P.A. Trade of I.T.I RD S

Following are the High Level File I/O functions :-

• fopen ( ) : creates a new file or open an existing file for use.


• fclose ( ) : closes a file which has been opened for use.
• getc ( ) : reads a character from a file.
• putc ( ) : writes a character from a file.
• fprintf ( ) : writes a set of data values to file.
• fscanf ( ): reads of data values from file.
• getw ( ) : reads an integer from a file.
• putw ( ) : writes an integer from a file.
• fseek ( ) : sets the pointer to a desired position in the file.
• ftell ( ) : gives the current position in the file (in
terms of bytes from the start).
• rewind ( ) : sets the position to the beginning of the
file.

File handling can be done in two ways

(1) Sequential file handling.


(2) Random file handling.

In Sequential File Handling data gets accessed in sequential manner


i.e. from 0 positions to the end of file position.

In Random File Handling data can be accessed randomly from any


position in the file.

The first step of file manipulation is declaring a pointer to access a file


This pointer should of FILE type and known as 'File pointer'.

 Declaring a File Pointer:-


Before reading or writing the information to the file, it must be opened.
Opening a file establishes a link between the program and the operating
system about the file. This link is a structure called FILE that is defined
in the header file stdio.h. When operating system opens the file, a
pointer to this FILE structure is returned. So a pointer is used to access
any file.

Syntax:-
FILE pointer name;

Example:-
FILE *fp;

Fundamentals of Computer Operating and Programming 319


C.O.P.A. Trade of I.T.I RD S

Each file will have its own FILE structure. The FILE structure contains
information about the file being used like its current size, its location in
memory. It contains a character pointer which points to a location in file.
Further this pointer is used to open access or close the file.

 Opening a File:-
To open a file fopen ( ) function is used.

Syntax:-
Fopen ("filename"," mode of opening");

Example:-
FILE *fp;
fp = fopen ("data", "r");

In above example fp is a file pointer which contains the address of the


file data.

fopen ( ) will open the file "data" in read mode. The function takes two
arguments.1) name of the file to be opened. 2) mode of opening.
It tells the compiler in which mode the file should be opened. File can
be opened in following different modes:-

"w" :- Write Mode.


"r" :- Read Mode.
"a" :- Append Mode.

Write mode allows to write the data to the file, the specification used is
"w".Read mode is used to read the data from the file specification used
is "r". Append mode allows to append new data to the end of file i.e.
previous data will not be lost. Specification is "a".
e.g.
fp = fopen ("student", "r");

The fopen ( ) function searches the file in the current hard disk location.
If it is present, it loads it into the memory otherwise it returns NULL.
For "w" mode, if the file exists, its contents get overwritten. If file
doesn't exist, a new file is created. If a file is opened in "w' mode, it
doesn't allow to read the data.

Note: - Here both the filename and mode are specified as string. They
should be enclosed in double quotation marks.

Fundamentals of Computer Operating and Programming 320


C.O.P.A. Trade of I.T.I RD S

 Closing a file:-
A file must be closed as soon as all operation on it has been completed.
This ensures that all outstanding information associated with the file is
flushed out from the buffers and all links to the file are broken. It takes
the following form.

Syntax:-
fclose (file pointer);

e.g.:-
fclose (fp);

 Reading and writing data to a file:-


Once the file is opened, its contents are stored into the memory and a
pointer is set to the first character of the file. The first two simple
functions to read or write data to the file are :-

getc ( ) and putc ( ).

These functions are used to read or write character information to the


file.

putc ( ) function writes a single character to the file specified by the file
pointer.

Syntax:-
putc (char expression., file pointer);

It takes two arguments: 1) a character expression that has to be written


to the file. It can be a variable or a constant character. 2) A file pointer
which refers to the required file.
e.g.:-
char ch = 'A';
putc(ch,fp); where fp is filepointer.

Fundamentals of Computer Operating and Programming 321


C.O.P.A. Trade of I.T.I RD S

Example: - The program to write a string stored in an array to the


new file.

# include<stdio.h>
# include<string.h>
main ( )
{
FILE *fp;
char str[30];
int i=0;
strepy (str, "Happy Diwali");
fp = fopen ( "text", "w");
while (i< strlen (str) )
{ pute (str[i], fp);
i++;
}
fclose (fp);
getch ( );
}

Here fopen ( ) will open the file "text" in write mode and set the file
pointer fp to its zero position. putc ( ) function writes the array
characters element by element to the file. Finally the file will be closed.
The file gets stored permanently on the hard disk. To check whether the
characters are stored in the file, you can display the contents of file from
DOS prompt using the DOS :- type command or you can write another
program to read the contents of file.

getc ( ) function reads a single character from the file. It returns the
character from the current file pointers.

Syntax :-
getc (file pointer);

Example :-
char ch;
ch = getc (fp);

getc ( ) will read one character from the file specified by the pointer i.e.
fp and returns it to the variable ch.

Fundamentals of Computer Operating and Programming 322


C.O.P.A. Trade of I.T.I RD S

Example1: - To read the contents of file character by character.


# include<stdio.h>
main ( )
{
FILE *fp;
char ch;
fp = fopen ("text", "r");
while ( (ch = getc (fp)) ! = EOF)
{
printf ("%c", ch); OR putchar(ch);
}
fclose (fp);
getch ( );
}

getc (fp) reads a single character at a time from the file. The program
contains one new statement i.e. EOF keyword. The last position in the
file is known as end of file (EOF) position. The characters will be taken
up to end of file. The file will be closed using fclose ( ). Similarly C
provides two more functions fgetc ( ) and fputc ( ) to read and write
character data to the file.

• Note :-
when getc ( ) reads the character from the file, the pointer will be
automatically advanced (incremented to next position. So there is no
need to increment the pointer as i++ is given in the previous example.

Fundamentals of Computer Operating and Programming 323


C.O.P.A. Trade of I.T.I RD S

Example 2 :- Write a program to read data from the keyboard,


write it to a file called INPUT, again read the same
data from INPUT file, and display it on the
screen.

# include<stdio.h>
main ( )
{
FILE *f1;
char c;
printf ("Enter some characters:");
f1 = fopen ("Input", "w");
while ((c = getchar ( ) ) ! = EOF)
{ putc (c, f1); }
fclsose (f1);
printf ("\n Data stored in the file : \n");
f1 = fopen ("Input", "r");
while ( (c = getc(f1)) ! = EOF)
{ printf ("%c",c); }
fclose (f1);
getch ( );
}

Output :-
Data stored in the file : Happy Diwali

 Multiple file handling :-


Consider the following statement

FILE *p1, *p2;


p1 = fopen ("student", "r");
p2 = fopen ("decimal", "w");

Here p1 and p2 are the file pointers used to handle two files at a time.
Student file will be opened in read mode with p1 and decimal file will
be opened in write mode with p2.

Fundamentals of Computer Operating and Programming 324


C.O.P.A. Trade of I.T.I RD S

 getw ( ) and putw ( ) function :-

The getw ( ) & putw ( ) are number oriented functions. They are similar
to the getc ( ) and putc ( ) functions and are used to read & write
numeric data. The general forms of getw ( ) & putw ( ) are :

putw (numeric exp., fp);


getw (fp);

Example :- The program that writes 1 to 10 numbers to the file and


read it from file.

# include<stdio.h>
# include<conio.h>
main ( )
{
FILE *fp;
int n;
fp = fopen ("num","w");
for (n=1; n<=10; n++)
{
putw (n, fp);
}
fclose (fp);
getch ( );
}

A file named 'Data' contains a series of integer numbers, code a


program to read these numbers and then write all odd no to a file called
ODD and all even numbers to a file to be called EVEN.

 fprintf ( ) and fscanf ( ) functions :-


In previous programs we have seen how to read or write character or
numeric information from the file using different functions. To handle
different type of values like character, number, float using these function
is a time consuming task. To avoid this C provides another set of
functions which reads or writes multiple values at a time to the file:
fprintf ( ) and fscanf ( ).

Fundamentals of Computer Operating and Programming 325


C.O.P.A. Trade of I.T.I RD S

fprintf ( ) functions writes multiple data items to the specified stream.

Syntax:-
fprintf (output stream, "format string", variable list);

It takes three arguments:-

i) output streams to which data should be written. There are two output
streams that can be provided.
a) Standard Output stream i.e. stdout that refers to the standard output
device -screen.
b) File stream i.e. filepointer (fp) that refers to the file.
If filepointer is given, data will be written to the file. If stdout is given
data will be written to screen.
ii) format strings like %d %f etc.
iii) Variable list through which data will be provided to the file.

Example: - To write student data to file or screen.


fprintf ( fp, " %d %s %d %f", rno, name, tot, per); -- Writes data to file.
Or
fprintf (stdout, " %d %s %d %f", rno, name, tot,per); -- Writes data to
screen.

Syntax:-
fscanf (input stream,"format strings", & variable list);

It takes three arguments :-


i) input streams from which data should be taken. There are two input
streams that can be provided.
a) Standard input stream i.e. stdin that refers to the standard input
device - keyboard.
b) File stream i.e. filepointer (fp) that refers to the file.
ii) format strings like %d %f etc.
iii) Variable list in which data will be stored from the file. Here we have
to give '&' operator with the variable name to get is address.

Example :- To read data from file into variables.


fscanf (fp, " %d %s %d %f", &rno, name, &tot, &per);
Or
fscanf (stdin, "%d %s %d %f", &rno, name, &tot,
&per);

Fundamentals of Computer Operating and Programming 326


C.O.P.A. Trade of I.T.I RD S

Example :- Program to write employee data to the file.


# include<stdio.h>
main ( )
{
int eno, salary;
char name[20];
FILE *fp;
fp = fopen ("emp", "a");
fprintf (stdout, "Enter empno, name and salary for one
employee :");
fprintf (fp, "%d %s %d", eno, name, salary);
fclose (fp);
fp = fopen ("emp","r");
printf ("\n The employee information:");
fscanf (fp,"%d %s %d", &eno, name , & salary);
printf ("\n %d %s %d", rno, name , salary);
fclose (fp);
getch ( );
}

In above program the first fprintf ( ) function will write the data to
screen as "Enter eno, name, & salary for the employee". fscanf ( ) will
read the data through keyboard and then it will be written to the file
using next fprintf ( ) function. Then file will be opened into read mode
and fscanf ( ) function will read the data from file.

 Random File Accessing :-

In random file handling data can be accessed randomly from the file.
We can move file pointer to any position in the file to access the data. C
provides various functions to manipulate the file pointer. Following are
some pointer manipulation functions :-

i) fseek ( )
ii) ftell ( )
iii) feof ( )
iv) rewind ( )

Fundamentals of Computer Operating and Programming 327


C.O.P.A. Trade of I.T.I RD S

• Fseek ( ) :-
fseek ( ) function moves the file pointer to the specified position in the
file. It takes three arguments :-

Syntax :-
fseek (file pointer, offset, position)

i) filepointer: - Specifies the file that is to be accessed.


ii) offset :- It is the number by which the pointer should be
moved
iii) position :- It is the position from which the pointer should be
moved.

Position in the file is a long type of value so we have to specify the T as


long specification with the offset value. The offset value can be negative
also to move the pointer in back direction.

Example:-
21 - moves the pointer two positions ahead.
-51- moves the pointer five positions ahead.

There are three fixed positions in the file which can be specified as a
third argument for fseek ( ) function.
These positions are:-

0 :- Beginning of file.
1 :- Current position in file.
2 :- End of file.

Example:-
fseek (fp, 31, 0) :- Moves pointer three positions ahead from beginning
of file.
fseek (fp, 31, 1) :- Moves pointer three positions ahead from current
position.
fseek (fp, -21, 2) :- Moves pointer two positions back from current
position.
fseek (fp, -41, 2) :- Moves the pointer four positions back from end of
file.

Fundamentals of Computer Operating and Programming 328


C.O.P.A. Trade of I.T.I RD S

• feof ( ):-

To check whether the end of file is encountered or not feof ( ) function


is used. It takes one argument i.e. the file pointer. It returns true if
pointer is at end of file position otherwise it returns false.

Syntax:-

feof (filepointer);

Example:-

feof (fp);

• rewind ( ):-
rewind ( ) sets the file pointer back to the beginning of file from any
position. It takes one argument - file pointer

Syntax:-

rewind (filepointer);

e.g.:-

rewind (fp);

Fundamentals of Computer Operating and Programming 329


C.O.P.A. Trade of I.T.I RD S

Example: - Program for random file accessing using fseek ( )


function.

# include<stdio.h>
# include<conio.h>
main ( )
{
FILE *fp;
char ch;
long n;
clrscr ( );
n = 01; / / Sets the value is 0,'1' is the long datatype specification.
fp = fopen ("text","w");
while ( (ch = getchar ( )) ! = EOF)
{
putc (ch, fp);
}
fclose (fp);
fp = fopen ("text","r");
while (!feof (fp))
{
printf ("\n %c is at %d position ", getc(fp), fell(fp) );
n--- n | 2|; / / Incrementing the value of n by 2.
fseek (fp, n, 0); / / moves the file pointer two positions
ahead.
}
fclose (fp);
getch ( );
}

The above program will accept data from user using getchar ( )function.
To stop accepting data press F6 key this is recognized by EOF keyword.
Then it will print the characters from the alternate positions as 0,2,4 etc.
fseek ( ) function moves the file pointer two positions ahead for every
iteration. Once it reaches to the EOF, the loop will be terminated.
Position the file is a long type of value so 'I' for long specification is
used.

Fundamentals of Computer Operating and Programming 330


C.O.P.A. Trade of I.T.I RD S

 Command line arguments :-


To execute any application in C first we have to write a program,
compile it and then execute it through the C editor.
To improve this procedure following steps can be taken:

1) There should be no need to compile the program every time. The


program should be executable form command prompt.

2)We can provide data to the program through command prompt.i.e. the
program can be executed as a command.

The program will be executed based on the arguments passed from


command prompt known as command line arguments. As the program
execution starts from main ( ) function, the arguments has to be passed
to the main ( ) function. These arguments are argc and argv.

Syntax :-
main (int arge, char *argv [ ] )

The name of the arguments can be changed. First argument is the integer
argc which holds the count of the arguments i.e. total no. of arguments
passed. Second argument is an array of pointer to strings which holds
the actual arguments one by one in the element. The strings at the
command line are stored in the memory and their address will be stored
in each element of argv [ ]. These arguments will be used in the
program. The program name will be the first argument which goes in
argv[0]. It is the exe file or command file that is run on command
prompt. Using this we can create commands like dos copy con
command or dos copy command etc.

Fundamentals of Computer Operating and Programming 331


C.O.P.A. Trade of I.T.I RD S

Example :- The program to write a "create" command that operates


like a dos
"copy con" command.

# include<stdio.h>
# include<stdlib.h>
main (int argc, char *argv [ ])
{
FILE *fp;
char ch;
fp = fopen (argv[1],"w");
if (argc ! =2)
{
printf ("\n Invalid number of
arguments !");
exit (0);
}
while ( (ch = getchar ( ) ) ! = EOF)
{ putc (ch , fp);
fclose (fp);
printf ("\n One file is copied !");
getch ( );
}

Save above program by the name 'create' , compile and execute it ones
to generate its .exe file and give following command at the command
prompt to create a new file which will be stored on the hard disk..

c:\tc> create mced <press enter>

Fundamentals of Computer Operating and Programming 332


C.O.P.A. Trade of I.T.I RD S

Example 2 :- To create a "copy" command which will copy


contents of one file to another.

# include<stdio.h>
# include <stdlib.h>
main (int argc, char *argv [ ])
{
FILE *fp, *fp1;
char ch;
fp = fopen (argv[1],"r");
fp1 = fopen (argv[2],"w");
if (argc ! =3)
{
printf ("\n Invalid no. of arguments!");
exist (0);
}
while (ch = getc (fp)) ! = EOF)
{
putc (ch, fp1);
}
fclose all ( );
printf ("\n One file is copied !");
getch ( );
}

Fundamentals of Computer Operating and Programming 333


C.O.P.A. Trade of I.T.I RD S

GRAPHICS
Computer Graphics is one of the most powerful and interesting
feature of computer. It allows you to draw something. All video games,
animation, multimedia works using computer graphics. This chapter
describes how these things are achieved in C.
C provides various in built standard library graphics functions that
can be used to perform different operations. These functions are defined
in the header file Graphics. It contains the definitions of all the graphics
functions. Before starting the graphics application first let's learn
something about the graphics mode. There are two modes in computer.

i) CUI :- Character User Interface and


ii) GUI : - Graphical User Interface.

Windows is a good example of GUI in which everything is performed in


graphical form. We can see images, colors, shapes etc. The image
resolution depends upon the adapter and monitor installed on the
computer. The screen coordinates are measured in pixels for graphics
mode. The number of dots or picture elements (pixels) available to us on
the screen in the graphics mode is known as resolution. Greater number
of dots, higher is the resolution.

Consider the following program that draws a circle on screen.

# include<stdio.h>
# include<graphich.h>
main ( )
{
int gdriver = DETECT, gmode;
initgraph (&gdriver, &gmode," ");
setcolor (RED);
circle (100,150, 50);
closegraph ( );
}

The above program contains circle ( ) function that draws a circle of


radius 50 at 100, 150 position.

Syntax:-
Circle (x position, y position, radius)

Fundamentals of Computer Operating and Programming 334


C.O.P.A. Trade of I.T.I RD S

First two arguments are the x , y coordinates from where the circle will
be drawn on screen. Third argument is the radius fro the circle. You can
use a variable as a argument.

Example:-
a = 20
circle (200, 300, a);

setcolor ( ) function will set the background color as RED.

To run any graphics program first the graphics (mode) should be


initialized. To set the graphics mode that provides high resolution.
Initgraph ( ) function is used. It takes three arguments i) graphics driver
ii) graphics mode and iii) Path for the file. First two arguments passed
are gd and gm. gd. gm is two integer variables. The initgraph ( )
function figures out the best resolution and stores the number
corresponding to that mode in the variable gm. The gm number tells us
which monitor we are using. The variable gd refers to the graphics
driver. Device drivers are the small programs which directly
communicate with the hardware. Graphics drivers are set of device
drivers and are applicable only in the graphics mode. They execute the
task assigned to them. Turbo C provides certain graphics drivers. They
are the files with extension .bgi. Depending on what adapter is used, one
of these drivers gets selected by the DETECT statement. DETECT is
macro that selects the driver installed on the computer. Third argument
is the path for the driver file.

Ones the graphics is initialized, the cursor disappears and the


screen coordinates changes to pixels and we can draw any shape on
screen using the graphic functions.

Fundamentals of Computer Operating and Programming 335


C.O.P.A. Trade of I.T.I RD S

 Following are some graphics functions and


their use:-
• Initgraph (&gd, &gm, "path") :- Initializes
the graphics mode from
graphics operations.

• Line (x1, y1, x2, y2) :- Draws a line from


(x1, y2) to (x2,
y2) where x1. y1, x2, y2 are

integer variable that represents the


screen
Coordinates.

• Circle (xc, yc, rad) :- Draws a


circle with center xc, yc
and radius rad.

• Rectangle (x1, y1, x2, y2) :- Draws a


rectangle with (x1, y1)
and (x2, y2) as corners.
• Setcolor (color) :- Set the color
for the graphics
drawn.

• Get color ( ) :- Gets the


current drawing color.

• Getbkcolor ( ) :- Gets the


current background color.

• Setbkcolor (color) :- Sets the


background color.

• Out text (string) :- Displays a


string in the
view port(screen)

• Outtextxy (x, y, string) :- Displays a


string at specified
position.

• Setline style (type, pattern, thickness):-Sets


different styles for the line.

Fundamentals of Computer Operating and Programming 336


C.O.P.A. Trade of I.T.I RD S

• Getmaxx ( ) and getmax ( ) :- Gets the maximum


x, y
screen coordinates.

• Clearviewport ( ) :- Clears the


current view port
i.e. screen.

• Closegraph ( ) :- Close the


graphics system and
deallocates the memory
allocated
by the graphics system.

Fundamentals of Computer Operating and Programming 337


C.O.P.A. Trade of I.T.I RD S

Some examples using above graphics functions:-

Example 1:- Program which will print a face on screen.

# include<stdio.h>
# include<graphics.h>
main ( )
{
int gdriver = DETECT, gmode;
initgraph (&gdriver, &gmode." "); / / Initialises graphics.
clearviewport ( ); / / Clears the
graphics screen.
setbkcolor (CYAN);
setcolor (BLUE);
circle (300, 260, 60);
ellipse (275, 240, 10, 360, 8, 13);
ellipse (325, 240, 10, 360, 8, 13);
line (300, 240, 295, 270);
line (295, 270, 303, 269);
arc (300, 280, 182, 1, 20);
fillellipse (275, 245, 5, 9);
fillellipse (325, 245, 5, 9);
getch ( );
closegraph ( ); / / Closes(deinitialises)
graphics screen.
}

Fundamentals of Computer Operating and Programming 338


C.O.P.A. Trade of I.T.I RD S

Example 2 :- Program to Draw a clock screen.

# include<graphics.h>
# include<conio.h>
main ( )
{
int gdriver = DETECT, gmode;
initgraph (&gdriver, &gmode," ");
clearviewport ( );
fillellipse (280, 240, 104, 130);
setcolor (1);
ellipse (280, 240, 1, 360, 95, 120);
setfillstyle (SOLIE_FILL, 9);
fillellipse (279, 240,5, 5);
line (279, 135, 279, 240);
line (240, 178, 280, 240);
line (279, 239, 355, 270);
outtextxy (275, 125, "12");
outtextxy (365, 235, "3");
outtextxy( 190, 236, "9");
outtextxy (270, 350, "6");
fillellipse (199, 190, 2, 2);
fillellipse (223, 151, 2, 2);
fillellipse (360, 199, 2, 2);
fillellipse (338, 151, 2, 2);
fillellipse (199, 291, 2, 2);
fillellipse (225, 332, 2, 2);
fillellipse (360, 291, 2, 2);
fillellipse (337, 330, 2, 2);
getch ( );
closegraph ( );
}
PROGRAMMING IN C++ LANGUAGE
 Looping Structure in C++:-

In C++ language is a object oriented language it is developed in


bell laboratories by Bjarne startup. The C++ language consist of same

Fundamentals of Computer Operating and Programming 339


C.O.P.A. Trade of I.T.I RD S

special feature rather than C programming in C++ language is the next


version of C programming language due to some disadvantages of C
language there is development of C++ language. The C++ language
removes. The limitations of programming languages are as follows :-

1) The main thing is it is difficult to read the keyboard, invert the vector.
For display of data or a function that checks or correct input is important
but it cannot be check.

2) The data makes up the inventory is probebbaly read from a list into
memory it treated as global variable.

 Object oriented programming (OOPS):-

The fundamental ideas define the object oriented language is to


combine into a single a program in to birth data and functions. Such a
single program is called as object.
An object P is called member function in C++ difficulty it
provide the main the access it's data if we want to read data item of and
object. We can call a member function in the object. It will read the item
and return the value to gives you can not access the data directly the data
is hidden, so it is safe from accidental alteration. The data and its
function are enclosed input a single entity known as Encapsulation.

Data

We can't access data directly


Membership

Member fan

Fundamentals of Computer Operating and Programming 340


C.O.P.A. Trade of I.T.I RD S

If we want to modify the data in an object we know exactly that


function interface with a no other function can we access the data this
simplifies. Writing debugging and maintain the program.
A C++ program consists of a number of object that
communicates with each other by calling one another's member
functions. The member functions in C++ are called as methods.

 Features of Object Oriented Programming Language:-

The C++ programming language is an object programming


language it is more useful and easy for programming. We can handle
data of C++ programming language due to it's characteristics of
programming there are some major features of object oriented
programming language are as follows:-

1) Class
2) Object
3) Inheritance
4) Reusability
5) Facility of creating new data type
6) Polymorphism and overloading.

1) Class:-

A class is that block of Object Oriented Program where data and


functions are placed together, one below the other. In other words, a
class resembles the structure of C. In structure only data is placed
whereas in a class data and functions both are placed together. Therefore
a class of C++ is considered as an extension of structure of C. The data
and functions together from a capsule and the capsule so formed is
called as a "class". In other words, a class is a template of data and
function.

Fundamentals of Computer Operating and Programming 341


C.O.P.A. Trade of I.T.I RD S

2) Object:-

In c, after defining the template of structure, the structure


variables are declared. As soon as a structure variable is declared,
memory gets allocated to all the members of structure, depending upon
their memory requirements. In a similar manner, an object is nothing but
a variable of class type. Consider the following segment of Object
Oriented Program.

:
:
class vivek
{
private:
int fees;
public:
void accept_fees (void)
{
cout<<"Enter fees";
cin>> fees;
}
void show_fees (void)
{
cout<<"college fees is";
<<fees<<endl;
}
};

The above segment of Object Oriented Program shows the definition of


a class named "vivek" that has encapsulated the data member "fees" and
the functions named "accept_fees ( )" and "show_fees ( )". Now recall
the declaration of a structure variable in C. As a variable of structure
type can be declared, a variable of class type can also be declared.
Consider the following declarative statement.

class vivek nis;

Fundamentals of Computer Operating and Programming 342


C.O.P.A. Trade of I.T.I RD S

In the above example "vivek" is the template name of a class.


Using "vivek" a variable "nis" is declared in the above declarative
statement. This variable "nis" of class "vivek" type is called an object of
"vivek" (i.e. a variable of vivek).

The object "nis" gets its own private memory to place its data
member "fees" and member functions"accept_fees ( )".As we have
declared one object "nis" of class "vivek". We can declare as many
objects as we want. All these objects enjoy their own private memories
to place their own data members and member functions. Consider the
following declarative statement.

Class vivek ob1, ob2, ob3, ob4, ob5, ob6, ob7

Here all the objects ob1 to ob7 belongs to the same class "vivek" and so
we can also say that all these objects together are making a class named
"vivek". Thus a group of objects can also be considered as a class.

3) Inheritance:-

A newly born baby usually inherits some features


of father and some features of mother, say intelligence of father and
beauty of mother. In addition to this inheritance, the baby has her own
features too. In the same manner a class of OOP can inherit the features
of another existing class. Consider the following diagram that illustrates
the concept of inheritance in OOP.

4) Reusability:-

The concept of inheritance leads to the concept of


reusability of existing codes. By virtue of inheritance, the member
functions that are defined in one class can be called for execution by the
objects of derived classes. Consider a class that creates a menu, this
class works fine and we do not want to change it but want to add the
capability to make same menu entries flash on and off. To do this, we
can simply create a new class that inherits all the capabilities of the
existing one but adds flashing menu entries. This is nothing but the
reusability of the existing software.

Fundamentals of Computer Operating and Programming 343


C.O.P.A. Trade of I.T.I RD S

5) Facility of Creating New Data Types:-

The facility of creating new data types is not a new


concept in OOP. C has the concept of "structure" and "union" that lets
the programmer create a new user defined data type using the built in
data types of the language. C++ has implemented the same but in an
advanced and sophisticated manner. In C++ the class name is used as an
abstract data type for defining objects. One of the benefits of objects is
that they give the programmer a convenient way to construct new data
types.

6) Polymorphism and Overloading:-

Polymorphism / overloading is a new concept that is


given by Object Oriented Programming. This new concept can be
implemented either on the functions or on the operators. More than one
functions, if are given the same name, then such functions are called as
overloaded function. Similarly the operators can also be overloaded. A+
(plus) operator can add two isolated values together. But if we make the
+ operator to add two objects together when the operator is called an
overloaded operator.

Fundamentals of Computer Operating and Programming 344


C.O.P.A. Trade of I.T.I RD S

C++ IDE (Integrated development environment) structure of C++


program.

The program is stared with # include files the file form the
library can be used with help off # include structure .
The c out & c in is used in the C++ program. Consider once
statement of program.
# include <iostream.h>
void main ( )
{
char str[40]
int M1, M2, M3, avg;
cout << “Enter your name.”;
cin >> std;
cout << “Enter marks of three subjects”;
cin >> M1+M2+ M3;
avg = M1+M2+ M3/3;
cout << “Your name is”<<std;
cout << “ You Average marks are”<<avg;
}

 The identifier c out:-

The c out is actually then object it is predefined to the standard


out put stream a stream is on abstraction that refers to a flow of data it is
used for screen display.
The operator << is called us insertion or to operator it is used for
display of statement. The syntax of c out is a s follows.

Syntax:-
cout << “Enter your name”;

The identifier C is it is also as object predefined in C++ it is


related with standard input stream. It represents data coming from the
keyboard the >> is extraction or get operated.
The syntax of cin is as follows.

Syntax:-
cin >> M1>>M2>>M3;

It is word as like scanf function in C programming language.

 Void Pointer:-

The word void can be used to define a pointer. The C++


handles the assignment of void pointer with main keyword.

Fundamentals of Computer Operating and Programming 345


C.O.P.A. Trade of I.T.I RD S

1) Comment :- as like C C++ supports two types comment the


comment like with in the /*--*/ structure is ignored by the
compiler.
2) C++ supports the // notation.
avg = M1+M2+M3/3; /* calculate avg*/
avg = M1+M2+M3/3; // calculate avg

 Looping Structure of C++ :-

 Loops :-

The loop is a program which checks how many types to cycle


around the programming for true & false results.
Loops make decision on values that can be either true or false.
There are three type of looping structure C & C++ which helps
programmer to execute the program and expected type of circulation or
cycles the looping structure help us or repetitive work & save our time
& length of program.
The loops are as follows.
1) While loop.
2) For loop.
3) Do loop.

1) While Loop:-

A while loop help us to show the conditional statement.


For e.g. A while loop ask to user to enter a character. It continues the
cycle until the user enters the characters .

Syntax :-
While (Char !=x)
{
Body of loop cout << “Enter any character”;
cin >> ch;
}

Fundamentals of Computer Operating and Programming 346


C.O.P.A. Trade of I.T.I RD S

The while consists of the keyword while following by a


condition enclosed in parenthesis ( ). The body of loop is enclosed by
curley bracket { }.

(braces)

False
Go back to Condition Exit
while loop
revaluate

True

Execute statement

while looping Statement.

2) Do Loop :-

The do loop is also called as do while loop. This


loop is used when we always want to do one time the syntax for do
while loop is as follows.

do
{
cout << “Enter any character”;
cin >> ch;
cout << L-nd/n;
}
while (ch !=x)

Execute Statement

Loop
False
Exist while
Condition
loop
Go back to
revaluate

Fundamentals of Computer Operating and Programming 347


C.O.P.A. Trade of I.T.I RD S

Do-While looping Statement.

The Do loop is only loop that is end with semicolon the semicolon is
necessary because of the condition follows the loop a body so the
closing brace of the loop can not act end line for the entire loop.

3) For Loop :-

In while & do loops we don't know how many


time the loop will be executed. the condition that terminate the loop
arises continuously inside the loop if can't be happened in case of for
loop.
The for loop will be executed usually started at the
beginning of loop. The parenthesis followed by the keyword . For
contains three different parts of for loop separated by a semicolon. The
variable inside the loop is known as loop variable expressions of for
loop are

1) The instillation which usually to initialize value of loop variable.

2) The text expression, which usually checks the value of loop variable
to see whether the cycle again or exit from the loop.

3) The increment or decrement expression which usually, increment &


decrement the value of loop variable for

e.g. for (i=0; i<20; i++)

1) Initialization expression.
2) Test expression.
3) Increment / Decrement expression .
for e.g.
for (i=1; i<=20; ++i)
cout << "*";
int k , total = 0;
for (i=0; i<10; ++i)
{
total = total + i ;
cout = total ;
}

Fundamentals of Computer Operating and Programming 348


C.O.P.A. Trade of I.T.I RD S

 Decision Loop :-

i) If Statement :-

The simple way make a decision in C & C++ is


the if statement. The if Statement helps us to execute out desired
statement automatically the syntax of if Statement is as follows .

{
If (Door = "open")
cout << "Enter in class";
}

ii) If------else statement :-

The If----- else statement helps us to show the


statement when it is true & simultaneously it also shows false statement
the syntax. For if else statement is as follows.

If (marks>35)
{
cout << "Result = Pass";
else
cout << "Result = Fail";
}

iii) Nested if -----else statement :-

We can use if else statement more than


one time as per our requirement

If (Marathi>35)
{
cout << "Result = Pass";
else
If (Hindi>35)
cout << "Pass";
else
{
If (Phy>35)
cout << "Pass";
else
{
cout << "Result = Fail ";
}
}
}

Fundamentals of Computer Operating and Programming 349


C.O.P.A. Trade of I.T.I RD S

UNIX

 UNIX COMMAND:-

UNIX is operating system software used for oxidation of


application software the UNIX operating system, is easy to use, due to
its features the UNIX operating system is developed at 'A & T bell'
laborites. In 1971 by Stive Barned. The UNIX operating system is a
multi-user operating system it can be access or Run by the new user also
system.

 Components of Unix Operating System:-

UNIX operating system is classified into following components


depending on its function of consist of
1) Kernal
2) Shell
3) Unix tools & application.

1) Kernal:-

The Kernal is a care or operating system program it performs all


the low level jobs which is necessary to control al the task & hardware
devices all operating system have a kernal which is carried by kernal for
flash operating of the system. The kernal is used for operating of Utility
or application on software tools. The kernal interface with the help of
system call is call to an operating system operating this cell can be made
in C or assembly language program. The system calls are the basic
building blocks upon which UNIX commands are based.

2) Shell:-

It is the command interpreter it is the command operating system


it accepts command from user the $ prompt any lise these commands the
shell short exciting the exactable feel & ten request to kernal to carry
out the data transfer which finally gives output hence the shell. Act as
middle man between kernal & User operating system.

Fundamentals of Computer Operating and Programming 350


C.O.P.A. Trade of I.T.I RD S

3) Unix tools & application:-

The outer most layer of Unix operating system is it's tools &
applications some versions of UNIX are having more than four hundred
tools these tools can be involved from the command line & helps to
perform complex task of te system tools consist many applications
programs which may be purses speciously such as electronic spread
sheet sophisticated word processing package.

 General Commands used in UNIX:-

The appearance of a $ prompt display command in UNIX


command. Type of C prompt. Result in command to get their are some
general commands used in UNIX.

1) $ Date:-

This command tells Unix system to print system date & time
every Unix command must be ended with Return the inform system that
user has finish typing $who.

2) $ Who:-

This command gives information about. The all users who are currently
logged on the system.

System: - $ Who

3) $ Who am I:-

This command used to get inforation about the user who is setting or
currently logged on the system

Syntax: - $ who am I
e.g. :- $ who am I

4) Echo:-

This is very simple & straight forward command it displays on the


screen. What ever the type after the command echo.

Syntax:- $ echo I am student of COPA

Fundamentals of Computer Operating and Programming 351


C.O.P.A. Trade of I.T.I RD S

I am student of COPA

5) $ ps (prace ss status) :-

The ps command makes process status Report the process. Status Report
is as line this.
Report is as line this

P/D TTY Time Command


2345 12 2:15 SW
2378 12 6:01 DS

The first column process identification number each time kernal assign
a unique p1 the sh is shell oph is processed status or other input device
which we are using & time command displays time which is used for
processing.

Syntax:- $ ps.

6) $ Clear:-

This command will clear the screen & view make true of command
press of word & tress new known name trace of the command directory
commands.

PWD :- (Print working directory):-

The command PWD tells us what directory we are $ PWD.

This command returns the path of currents directly within the root
directory their is a sub directory known as USR , within which there is
another directory it is known as user.

7) MKDIR :- (Create directory name)

To create a directory UNIX provides a mkdir command.

Syntax: - $ MKDIR DIR name


$ MKDIR ABC

8) RMDIR :- (Remove directory name)

The command is used to remove the directory at the shell prompt


type the command.

Syntax: - $ Rmdir
e.g.:- $ Rmdir ABC

Fundamentals of Computer Operating and Programming 352


C.O.P.A. Trade of I.T.I RD S

9) CD :- (Change directory name)

When a users create a directory we would like to change the


directory .

Syntax: - $ CD Dir name


e.g.:- $ CD ABC

 Basic File Command:-

1) LS :- ( list the file)

The command is list the file in the directory. The command LS


with no argument list the contents of ever current directory.

Syntax: - $ LS
Example: - $ LS

The LS command is used with same parameters.

LS - I: - Optional first line.


LS - D: - Directory.
LS --:- Ordinary

2) Cat :- (Create File):-

This command creates file on the system. The syntax or this is

Syntax: - $ Cat > First file name


I am student Comp.sci
Ctrl + D

In this Ctrl + D is used to store the file.

3) Rm (Remove file):-

This command is used to delete or remove the file on system.

Syntax: - $ Rm file name


e.g.:- $ Rm ABC

4) CP (Copy):-

The command is used to make a copy the file in this first


argument file copied into second argument.

Syntax: - $ CP (Source-target)

Fundamentals of Computer Operating and Programming 353


C.O.P.A. Trade of I.T.I RD S

e.g.:- CP ABC XYZ

5) MV :- (Method Vehicle)

The command is used to change the name of file the first name is
ole name & second name is new name after the command prompt.

Syntax : - $ my first file name (second file)


e.g.:- $ my XYZ CBZ

6) Chmod :- (Change mode of access)

This command changes made of indicated file & directory. The


file made is read write & executed permission separately for the each
class of user tat is user

Syntax: - $ chmod 777 ABC

Fundamentals of Computer Operating and Programming 354


C.O.P.A. Trade of I.T.I RD S

 UNIX EDITOR:-

The UNIX editor is an important part of the system it helps to


create & modify to user files & data there are two text editors available
under the UNIX operating system. Te two text editor are vied.

VI - it is stand for visual & c


Ed - it is stands for simple editor.

The VI editor can be access in three ways this are shown below.
i) Vi - it edits & empty editing buffer.
ii) Viname - it edits & file with specified file name
iii) Vi+3 name: - it opens file with a specified name and goes third line
idefine
iv) vi+/bye name: - it searches for the first occurrence of bye in the file
commands used with other users.

1) Write:-

The easy way to communicate with other user who are logged in
the syntax of write command is as following type.

Syntax: - $ Write used (TTV)

2) Mesg Command:-

It is used to sent receive massage from other user te syntax of


mesg command is

Syntax: - $ mesg x

3) News:-

It permits the user to read massages published by the system


administrator the important new is saved as a file in the news directory
so that file in the news directory so that file in the news directory so that
it may be available to all user.

Syntax: - $ news

Fundamentals of Computer Operating and Programming 355


C.O.P.A. Trade of I.T.I RD S

4) WX:-

This commands counts line words & character the syntax is

Syntax: - WX - (option) (filename)

Option

I - Count line.
W- Count word.
C- Count Char.

5) Pq ( paiqinator) :-

These command arrows to view on screen full of a time. The pq


command display a prompt that pauses for the user to strike the dental
key to continue scrolling at the end of file it displays.

6) Sort:-

The sort command sorts the more mud file.

Syntax: - $ sort file / file 2 > file3

The contains of file / & file 2 are merge, stored & redirected to
file 3

7) Cut:-

This command is used to cut out selected fields from a file &
display. The syntax of cut command is below.

Syntax: - $ Cut - [option] [file name]

• Paste:-

The paste merges the contains of multiple file & display them
and screen this fielder is used to generate output in column format the
syntax is

Syntax: - $ paste [option] [file name]

Fundamentals of Computer Operating and Programming 356


C.O.P.A. Trade of I.T.I RD S

• Tar Command:-

The Tar stand for take achieved the Tar command is used for
making a back up copy of entired directory it takes as its argument a
command a directory to be achived on a tape or other tape

Syntax: - $ Tar ABC

Wall: - [Write to all]

This command is used to display a message to all user on the


system # wall

Tar Hello friends


I have joined now

Ctrl + D

• Path:-

This command is used to display path of your directory when we


logging our path variable is set to some difficult value.

Syntax: - $ Echo $path

• GREP :- (global regular expression printer)

This command is used to search & print to specified


pattern from a file or standard input

Syntax :- $ GREP [patton] [file name]


e.g. :- $ Cut data
$ GRED in data.

Fundamentals of Computer Operating and Programming 357


C.O.P.A. Trade of I.T.I RD S

• Characteristics of Shell:-

The shell is important & useful path of UNIX operating system


due to this characteristic it is more useful some of these characteristic
are as follows

1) It acts as interface to UNIX operating.


2) System it acts as command interpreter.
3) It provides a programming language with powerful syntax.
4) The Standard input output can be redirected to files.
5) Process on communicate through pipe.

• Characteristics of Unix Operating System :-


Or
• Features of UNIX Operating System:-

1) The Unix Operating system is mainly silence feature some of this


important
Feature is as follows:-

1) Multi tasking.
2) Multi-user.
3) System Portability.
4) Communication:-
5) System security:-

1) Multitasking:-

This capability permits the operating system to perform several


takes at a time, UNIX & print one document, edit mother & sort list of
file at the same time the multiple task can be carry down by placing
other task in the back ground.

2) Multi user:-

The multi-user operating system permits several users to use te


same computer to carryout there job the serval terminals are connected
to server computer other computer can access files & print document at
the same time te multi-user environment gives complete coordination &
competitive & saves amount of time.

Fundamentals of Computer Operating and Programming 358


C.O.P.A. Trade of I.T.I RD S

3) System portability:-

The UNIX operating system can install software without any


major changes this ability of UNIX operating systems makes UNIX
popular UNIX run on more brands of computer

4) Communication:-

The UNIX supports two major type of communication.


a) Communication between different terminals connected to the same
computer.
b) Communication between users of is computer as specific location to
the users or another type or size of computer.

5) System Security:-

The user data is highly secure in there are several level of


security in UNIX the first level is

i) System security. The standard log in procedure secured user data. The
next level of security is the permission to access the files are read, write,
execute is unsigned by the owner of the file this is level of security
allows the users to in script data files on this so that the data remains
secure.

Fundamentals of Computer Operating and Programming 359


C.O.P.A. Trade of I.T.I RD S

DATABASE MANAGEMENT SYSTEM

 Database Environment:-

Information is very important in any business or organization it


is required to manage this information it is required to manage this
information as per our requirement the information is useful when it is
accurate & available as on when required by the user. This can be occur
only if an organization organizes & manages it's data properly data base
is shared collection of logically related data & designed to fulfill the
information needs of an organization data is the Row material from
which useful information is required.

 Data:-

Data is the Row material from which use full information is


received data is commonly used in both similar & plural form it is
defined as row facts of organization on fact or observation typical
phenomenal.

 Information:-

The data which is converted into useful & meaningful form is


known as information. The data & information are used i9nterchange
the data are Row material resources that are processed into information
products information product can be defined as data has been converted
into meaningful & useful form for the end user information is processed
data placed in a way that gives value for specific and user.

The software of data base management systems are as follows


which is used by people

1) FoxPro
2) Oracle
3) Ms-Access

Fundamentals of Computer Operating and Programming 360


C.O.P.A. Trade of I.T.I RD S

FOXPRO

 INTROEDUCTION TO FOXPRO:-

 PROGRAM:-

The set of instructions provided to computer to accomplish a


particular task is called as program.

 SOFTWARE:-

The collection of program which are used between the user and
the computer is called as software.

There are two main classes of software.

1) Application software.

2) System software.

Fundamentals of Computer Operating and Programming 361


C.O.P.A. Trade of I.T.I RD S

 DIFFERENCE BETWEEN PACKAGE AND


LANGAUAGE:-

PACKAGE LANGUAGE
It is application software It is a system software
Here a limited set of instruction used It is used for communication purpose
It is slower compared to language It is faster
e.g. Word-star, Lotus, account package, e.g. Basic , Cobol , C , Fortran , Pascal
FoxPro , D.T.P. package

 DATA BASE:-

The collection of information which is arranged in structured and


table manner is called as data base.

e.g. 1) A telephone directory.


2) Library system.

 DATA FIELD:-

Individual entity in the database is called as data field.


E.g. Serial No., Name, Salary etc.

 DATA RECORD:-

The collection of related fields is called as data record.

 DIFFERENCE BETWEEN FIELDS AND RECORDS:-

RECORD FIELD
Record is a collection of related fields Individual entity in the database is called as
fields
Collection of records constitute Collection of fields constitutes a record
e.g. Roll-no, Name, Course, fees is a record Name, Roll-no, Course, fees are the separate
of single student fields.

Fundamentals of Computer Operating and Programming 362


C.O.P.A. Trade of I.T.I RD S

 STRUCTURE OF DATABASE FILE:-

The structure of a database is like a table which contains the


no.of records of different information related subject.

A database could be a address book database because each rows


or records contains information about a different person or entity. In the
following table, record no.1 for SUNIL contains in the column or fields
identified as name, address, and city.

DATA BASE

RECORD FIELD1 FIELD2 FIELD3


NUMBER (NAME) (ADDRESS) (CITY)
1 SUMIL GULMANDI A'BAD
2 ANIL M.G.ROAD PUNE
3 VIJAY CAMP PUNE

 TYPES OF FILES:-

The most commonly used files in FoxPro are as follows. Each


file type has a unique extension to indicate its type.

1) .DBF DATA BASE FILE


2). DBT MEMO file
3) .PRG PROGRAM file
4). IDX INDEX file
5). FRX REPORT file
6). LBX LABEL file
7). SCX &. SPR SCREEN file

 FIELDS & DATA TYPES:-

There are 6 types of fields available in FoxPro.

Fundamentals of Computer Operating and Programming 363


C.O.P.A. Trade of I.T.I RD S

1) Character Field:-

Here you can use alphabets and also numbers. Maximum allow
able range is 255 characters.

2) Numeric Field:-

It is used for numerical operation. The numeric type data is


stored in this field. Maximum range is 20 digits.

3) Date Field:-

When you use data in your file, use this field to store data type
information.

4) Memo Field:-

It is also same type as character. But there is no limitation of


alphabets. No limitation of character. One database can have only one
memo field.

5) Logical field:-

When there is a condition e.g. true or False, Yes or no then


logical field is used. Maximum range is 1.

6) Float Field:-

Here you can include decimal Points, Maximum range 20 digit.

Fundamentals of Computer Operating and Programming 364


C.O.P.A. Trade of I.T.I RD S

 RULES FOR NAMING DATA FIELDS:-

1) Field name can be up to 10 characters.

2) Field name must have to begin with alphabets. Remaining 9


characters may be alphabets or digits.

3) There should not have blank space, in the field name.

4) Special characters are not allowed in field name except underscore


i.e. "-"

 WHAT IS FOXPRO?

FoxPro is database management system. This is the faster


DBMS. It is developed by fox software incorporation.

 ADVANTAGES OF FOXPRO:-

1) We can add, correct or delete records in database file.

2) We can generate mailing labels.

3) Programming facility is available with FoxPro.

4) Screen generation facility is available which is more powerful


compared to other DBMS.

5) The editor of FoxPro is more powerful which provide cut, paste and
copy etc.

6) The report facility is available which is very useful.

7) Memo field has unlimited capacity which depends on memory space.

8) The records can be arranged order i.e. the record can be sorted, or
indexed.s

Fundamentals of Computer Operating and Programming 365


C.O.P.A. Trade of I.T.I RD S

ELEMENTS OF FOXPRO SCREEN

 MODES OF OPERATION:-

You can operate the FoxPro in 3 different modes.

1) Command line mode


2) Programming mode
3) Assist mode

1) Command Line mode:-

After starting FoxPro we get a window through which we can


give the commands. This is command line window.

2) Programming Mode:-

We can write the program in this made. These programs can be


used repeatedly.

3) Assist Mode:-

It is a menu driven mode from which you can select the options.

 INSTRUCTION SET:-

The instruction set consists of command, function and statement.

1) Command:-

Commands are used to have some specific work.

2) Functions:-

This is a ready-made program and can do the specific work.

3) Statement:-

It is a set of commands and can be used in programs.

Fundamentals of Computer Operating and Programming 366


C.O.P.A. Trade of I.T.I RD S

 FOXPRO SCREEN:-

Fox Pro screen consist of 3 parts.

1) Command Window
2) Menu mode
3) Status line

1) Command Window:-

By default the cursor is in command window and you can give


the command directly. You can change the size of the command window
by pressing ^F8 and move the window by pressing ^F7 from one place
to another. The command mode is faster than menu mode.

2) Menu Mode:-

All the menus are displayed at the top of the screen and a single
character is high lighted to switch over to menu mode, use Alt and
highlighted character.
Then it displays the commands available in the menu. To
execute any command from the menu, move the cursor to that option
and then press enter.

3) Status Line:-

At the bottom of the screen, there is a white strip which is called


as status line. The status line gives as following information.

a) The current drive e.g. C:

b) The DBF name which is in use.

c) The total no. of records in the DBF and the position of record pointer.

d) Status of special keys like insert, num lock, caps lock etc.

Fundamentals of Computer Operating and Programming 367


C.O.P.A. Trade of I.T.I RD S

 OPERATORS IN FOXPRO:-

In FoxPro mainly there are three types of operators.

1) Mathematical Operators:-

These are +, -, *, /

2) Relational Operators:-

These show the relation between the two quantities.


These are =, >, <, < =, > =, #

3) Logical Operators:-

There are AND, OR, NOT. The logical operators must be


enclosed in dots.

e.g.:- .And . . . . Or. .Not.

Fundamentals of Computer Operating and Programming 368


C.O.P.A. Trade of I.T.I RD S

COMMANDS IN FOXPRO

 CREATE:-

This command is used to create a new database (DBF).

Syntax: - CREATE <File name >

After this command, we will get the screen where you have to
provide information about the field of DBF.

Structure of Database File (DBF). In structure we have to


provide field name, field type, field width and decimal places. (Only for
numeric fields)

The DBF created by CREATE command will have the extension


.DBF

E.g. CREATE STUDENT


E.g. CREATE EM PLOYEE

After pressing enter key, you have to create database structure by


specifying the required fields & their types.

After creating the structure it will ask you a question

Input data record now?

< Yes > < no >

Type "y" or select yes to input the data records in a file. Then enter the
record in the file and use 'Ctrl +W' key to save the file.

Fundamentals of Computer Operating and Programming 369


C.O.P.A. Trade of I.T.I RD S

 LIST:-

This command is used to see the contents of DBF.

Syntax: - LIST

We can also we the list command with condition. In this case for
clause is used.

Syntax: - with condition

List for < condition >


E.g. List for name = "A"

This will display the list which contains the name starting from A.

List for salary = 1000 OR


List for salary > 1000 .AND. name = "A"

This will display the list which contain the record having salary
>1000 .AND.

Name = "A"

List for salary > 1000. OR. Name = "A"

This will display the list which contains the record having salary, 1000
or name starting with "A".

 USE:-

This command is used to close the opened DBF or to open the


DBF, which is already created.

Syntax: - USE <File name >


e.g.:- USE ACTIVE

This will open a file ACTIVE

Syntax: - USE

This will close the opened DBF.

Fundamentals of Computer Operating and Programming 370


C.O.P.A. Trade of I.T.I RD S

 QUIT:-

This command is used to exit from the FoxPro & returns to the
operating system.

Syntax: - QUIT

 CLEAR:-

This command is used to close the entire file, which are opened.
We can close any type of FoxPro file using this command.

Syntax: - CLOSE ALL.

 APPEND:-

This command is used to add records at the end of the currently


opened file.

Syntax: - APPENED.

 APPENED BALNK:-

This command is used to add one blank record at the ened of the
currently opened file.

Syntax: - APPEND BLANDK.

 RECORD POINTER:-

This is a pointer which indicates record no.in a DBF which is in


operation currently.

 GO TO:-

This command is used to move the record pointer at the specific


record.

Syntax: - GOTO < NUMBER>


e.g.:- Go To 5

 GO TO TOP:-

This command is used to move the record pointer to the first


record of the DBF in use.

Syntax: - GO TO TOP

Fundamentals of Computer Operating and Programming 371


C.O.P.A. Trade of I.T.I RD S

 GO TO BOTTOM:-

This command is used to move the record pointer to the last


record of DBF in use.

Syntax: - GO TO BOTTOM.

 SKIP:-

This command is used to skip the record that is to move the


record pointer to the next record.

Syntax: - SKIP < RECORD NUMBER >

E.g. :- First of all record pointer is in third position, that is give


command as skip 2, after skip the record pointer is on the 5th
position.

This is called as forward skipping. If record pointer is on rec 5 &


if we issue command skip-2, then it will shift that printer 2 records back,
i.e. on rec.no3.
This is called as backward skipping.

 EDIT:-

This command is used to modify the record in a database.

Syntax: - EDIT

Syntax: - EDIT < RECORD NUMBER>

E .g. EDIT 5

Fundamentals of Computer Operating and Programming 372


C.O.P.A. Trade of I.T.I RD S

 BROWSE:-

This command is used to edit the records in a database file. This


command opens a browse window & display records in a table format
you can move from record to record. In browse window records can be
edited, added or marked for deletion. Using different options.

Syntax: - Browse
e.g.:- Use Student
Browse.

To add records in a browse windows press Ctrl+N key. It will


add one blank record at the end of records.
To mark the records for deletion in brose windows press Ctrl+T.
To save the changes made in brose windows press Ctrl+W, & to
discard changes press Ctrl+Q.

 DISPLAY:-

This command is used to display the single record at a time. The


record on which the record pointer is present that will be displayed.

Syntax: - DISPLAY.

Syntax: - DISPLAY RECORD <RECORD NO>


E.g.:- DISPLAY RECORDS.

To display set of record use command as bellow.


Suppose record printer at first record i.e I and you want to display only 4
records from current position i.e. from 1 to 4. Then give command a
bellow.

e.g.:- DISPLAY NEXT4

Fundamentals of Computer Operating and Programming 373


C.O.P.A. Trade of I.T.I RD S

 DISPLAY STRUCTURE:-

This command is used to display the structure of currently opend


DBF. This will show the field names, their types and field widths along
with the total width.

Syntax: - DISPLAY STRUCTURE.

 MODIFY STRUCTURE:-

This command is used to modify structure of existing file. Using


this command; we can add new field, we can delete old field, we can
delete old field, we can change width of field etc.

To add new field use Alt+I


To delete old field use Alt+D.

Fundamentals of Computer Operating and Programming 374


C.O.P.A. Trade of I.T.I RD S

DELETION & RECALLING OF


RECORDS

 DELETION:-

In FoxPro deletion of record is of two types.

 Logical deletion:-

In this deletion record is temporarily deleted and it is mark with


(star). You can undelete the logically deleted records.
In the structure of a file the total width of a field is greater by 1.
This one additional column is used for the star.

 Physical deletion:-

In this deletion the record is permanently deleted from the DBF.


For this purpose the PACK Command is used.

 DELETE:-

This command is used to delete a record logically or temporally


from the DBF.

Syntax: - DELETE.

The record on which the record pointer is present is deleted logically


using this command.

Syntax: - DELETE RECORD <NO >

The specified record is deleted logically from the DBF.

E.g. delete record 4

 PACK:-

This command is used to delete the logically deleted record


permanently.

Syntax: - PACK

Fundamentals of Computer Operating and Programming 375


C.O.P.A. Trade of I.T.I RD S

 ZAP:-

This Command is used to delete all the record permanently from DBF.

Syntax: - ZAP

The structure of the fill will remain same only the record will deleted.

 RECALL OF LOGICALLY DELETED RECORDS:-

This command is used to undelete a logically deleted record.

Syntax: - RECALL: OR:

Syntax: - Recall RECORD <NO> :OR:


RECALL ALL

This command is used to undelete the all logically deleted record at one
time.

Fundamentals of Computer Operating and Programming 376


C.O.P.A. Trade of I.T.I RD S

COMMAND USED FOR CALCULATIONS

 SUM:-

This command is used to find total of numeric fields.

Syntax: - SUM <FIELD NAME>

The result of this command can be store into some variable by


giving command as sum <field name> to memvar

e.g.:- Sum Salary to S1.

Sum Salary for CITY = "A'bad". to S2.

It will select all records whose address are "A'bad" & add their salaries.
The result is stored into memory variable S2.

 AVERAGE:-

To find average value of numeric field

Syntax: - AVERAGE <Field name > To < Memvar>


e.g.:- To find the average salary belonging to same city.
Average salary for CITY = "A'bad" to S3.

 COUNT:-

To count the no. of records satisfying certain condition & result


is stored in memvar.

Syntax: - Count for (Condition) to memvar.


e.g.:- Count for Upper (Address) = "A'BAD" To S2

It will count all the records whose address is "A'BAD" & result is stored
in S2.

 CALCULATE:-

This command is used with some other fun?

Fundamentals of Computer Operating and Programming 377


C.O.P.A. Trade of I.T.I RD S

SEARCHING TECHNIQUES
Following techniques are used to search particular record satisfying
certain condition from the DBF.

1) Locate
2) Seek
3) Filter

LOCATE FOR CITY = "A'BAD"

It returns you the rec.no. having city "A'BAD" i.e. it will search for that
field. This command is used to search and unindexed single record.

LOCATE must have FOR - Clause.

The basic way of using the LOCATE dialogue box is by checking the
FOR check box & then in the expression builder, enter the logical
expectation you will be using as the criterion for the search LOCATE
FOR will begin it's search with the first rec. & read it sequentially until
it finds the matching record. It moves the record pointer to that record.

If you want to search the next rec. that matches the criterion then give
CONTINUE command after LOCATE command.

 CONTINUE:-

The search for locate command can be continue using continue


command. If there are more than one record that matches with the
condition mentioned in locate command then this command will move
the pointer to next matching command.

Syntax: - CONTINUE

Fundamentals of Computer Operating and Programming 378


C.O.P.A. Trade of I.T.I RD S

 SEEK:-

To search for a single record based on controlling index, use the


seek command.
INDEX ON City to CC
SEEK "A'bad"

DISPLAY

INDEX ON Salary to S
SEEK 5000

DISPLAY

 FILTER:-

It extracts the records satisfying condition fro the DBF.

Syntax: - SET FILTER to <exp>


E.g.:- Set Filter to City = "PUNE"

 REPLACE:-

This command is used for change the contents of one field or


more fields. We can change data of one record or all records.

Expression may be any name i.e. "ACCOUNT", value i.e. 100 or


formula
i.e. SUB1+SUB2+SUB3 etc.

e.g.:- 1) Replace City with "Bombay"


2) Replace Salary with 1500
3) Replace Salary with (400+800)

 REPLACE ALL:-

It will replace all the record in the specified feld with the new
expression in a entire DBF.

Syntax: - REPLACE ALL <Field Name> WITH <new expressions>


e.g.:- Replace All Salary With 1500
e.g.:- Replace All Netsal with (Basic + Da + Hra - Lic -Pf)

Fundamentals of Computer Operating and Programming 379


C.O.P.A. Trade of I.T.I RD S

FILE HANDLING COMMANDS

 DELETE FILE:-

This command is used to delete a file from the disk.

Syntax: - DELETE FILE <File Name>


e.g.:- Delete File ABC.DBF

The file to be deleted must be closed.

 COPY TO:-

This command is used to copy the contents of currently opened


dbf in a new file.

Syntax: - COPY TO <New File Name>


e.g.:- Copy To ABC

This command is used only with DBF the new file will have the
extension DBF.

 COPY STRUCTURE:-

This command is used to copy the structure only of currently


opened DBF file to new file.

Syntax: - COPY STRUCTURE TO <New File Name>


e.g.:- Copy Structure to PRAKASH

The new file will have the extension .DBF

 COPY FILE:-
This command is used to copy the contents of any file into a new
file.
This is similar with copy command in DOS.

Syntax: - COPY FILE <File Name with Extension >


To <Target File Name with Extension>
e.g.:- Copy File ABC.Prg To XYZ.Prg

 RENAME:-

This command is used to change the name of any file.

Fundamentals of Computer Operating and Programming 380


C.O.P.A. Trade of I.T.I RD S

Syntax: - RENAME <Old File Name with Extension>


To <New File Name with Extension>
e.g.:- Rename ABC.DBF to ACTIVE.DBF

This is similar command to ren command in the DOS.

 SORT:-

To arrange the data in proper physical order is called as Sorting.


We can sort the data in ascending or descending order in case of
numeric field and alphabetically ascending or descending in case of
character field.

Syntax: - SORT ON <FIELD NAME> to <NEW FILE NAME>


e.g.:- SORT ON NAME TO STUDENT

New file created is a database file. Here the sorted record will be in file
student. To see those records, you will have to use that file i.e. student
and then give LIST command. The sort command will sort the data
which was randomly entered.

You can sort the file on multiple fields also.

Syntax 2:- SORT ON <Field Name 1, Field Name 2>


To <New File Name>
e.g.:- Sort on salary, name to emp12

In this case the first field is primary field.

You can open the sorted field files using "Use" command.

Fundamentals of Computer Operating and Programming 381


C.O.P.A. Trade of I.T.I RD S

SORTING & INDEXING


 SORTING:-

This command allows you to sort entered data in alphanumeric


order. It gives the ability of copy records & structure of a database to
another database file arranged in alphabetical, numerical or
alphanumerical orders. The SORT is done on one or more fields within
the active database. You can specify also whether the SORT should be
in ascending or descending order.

You can sort the file on multiple fields also. When entries in the first
KEY field are same then second key field determines the order.

To sort the dbf that database file should be opened first.

USE Trial

Sort on name to sortum - Single filed sorting


Sort on name, city to city - Multiple field sorting

Here name is primary & city is secondary KEY Field for sorting the
database file TRIAL, CITY.DBF gets created. To see the Sorted records.
We should open sorted file.

USE CITY.

BROWSE. : OR: LIST

INTRODUCTION TO INDEX

One of the main advantages of having computerized database is that the


data can be retrieved & processed very quickly. Database can be
organized efficiently. An INDEX is one way of organizing a database in
order to retrieve relevant information.

Indexing means arranging the records into ascending or descending


order. This is a logical arrangement of data. Original dbf is not affected
after indexing.

Database file can be INDEXED on particular key fields to organize the


data.

For example, if you want names of employess in alphabetical order, the


file can be indexed on the field which contains the employee name. Here
the field containing the name of the employee would be called the KEY
field.

Fundamentals of Computer Operating and Programming 382


C.O.P.A. Trade of I.T.I RD S

FoxPro supports two types of Index.

1) Simple Index.
2) Compound Index.

In simple index file, the FoxPro creates a separate index file for each
KEY Field.
This index file will have the extension .IDX. The index file will contain
information about the KEY fields & the location of data in the database.
When the database file is opened using the USE command, the
corresponding index file will also have to be opened.

Any addition or modification to the data in DBF would also be updated


in the index file However, if the index file is not explicitly opened, the
updation will not take place in the index file.

To open a dbf along with index file command is

USE EMPDATA INDEX EMP <Enter>

Fundamentals of Computer Operating and Programming 383


C.O.P.A. Trade of I.T.I RD S

 STEPS IN CREATING SIMPLE INDEX FILE:-

1) Before creating an index file, the database file has to be in USE.


For Ex. Let us use the file EMPDATA & we want to index that file
using EMPNAME AS key field, then give command.

USE EMPDATA <enter>

2) To index EMPDATA.DBF
We select file menu & select NEW from the sub-options. The new
dialog box will displayed.

3) Select index file radio button. The INDEX dialog box appears. This
dialog box allows you to create the index file.

4) You can select field (s) to be used as the key field from the FIEED
list box. As the fields are selected they appear in the INDEX KEY list
on the right.

The file can be indexed in ASCENDING or DESCENDING order of the


key fields.

Indexes can also be UNIQUE, which means no two records in the


database file will have the same value.

5) Choose the type of index file a compound or a single index file.

6) Now select [ok] push-button to create the index file.

Another way of indexing a file is to use the INDEX command. The


INDEX command can be entered through the COMMAND WINDOW

Syntax: - INDEX ON <Field exp> To <COMPACT file name>

[FOR <exp>] [ASCENDING/ DESCENDING] [UNIQUE]

The Options for the INDEX ON Command are as follows:-

The for clause make the index include only records for which the logical
expression is true.

The COMPACT option creates a COMPACT file which requires less


memory space. The ASCENDING & DECENDING options allow you
to tell FoxPro whether the file has to be indexed in ascending or
descending order of the KEY. By default the file is indexed in
ASCENDINNG order.

Fundamentals of Computer Operating and Programming 384


C.O.P.A. Trade of I.T.I RD S

The UNIQUE option makes the index include only records with unique
values of the key field, i.e. if a file contains more than one record having
the same KEY values then only the first record will be indexed.

E.g. INDEX ON EMPNAME TO EMP <enter>

Note the EMP in the to clause will have extension.IDX & whenever the
database is opened, then the index file must also be opened, otherwise
the index file will not be updated.

To open index file along with the database file, the following command
can be entered from command window.

USE EMPDATA INDEX EMP <enter>

Now display the data using BROWSE Command.

BROWSE

It will show an indexed record list on to the screen.

 EXPRESSIONS IN INDEXES:-

An expression can also be used in the index command. For example, if


we index the file on the KEY field EMPNAME, it may be possible that
the index is not always in alphabetical order, especially if the data
within the field is in both upper & lower cases. To make sure that the
index takes place in the correct order, we can use the function UPPER ()
to force the INDEX command to convert the data in the key field into
upper case before indexing. The command for which is as follows:
INDEX ON UPPER (EMPNAME) TO EMP<enter>
This command will force the index command to convert all the
employee names into upper case before indexing the file.

Fundamentals of Computer Operating and Programming 385


C.O.P.A. Trade of I.T.I RD S

 REINDEX A FILE:-

We have seen that s single index file must always be opened along with
the data file, if the changes made in the data file have to be updated in
the index file. However, sometimes this may not get done. This would
result in a mismatch between the data in the index file& the data file.
However this can be corrected by using the REINDEX command. The
REINDEX command reindeers the file on the same key as specified
during the creation of the INDEX file . Note that both the data file as
well as the index file has to be opened

USE EMPDATA INDEX EMP<enter>


REINDEX<ENTER>

The file is now reindeer & the index file is updated. This command is
not necessary if the index file is already updated

 COMPOUND INDEXING:-

Simple indexing is used for indexing on the single field. But for
multiple indexes in compound indexing is used. You can create multiple
index files (.IDX) using simple indexing. Which are crated on different
fields?

In compound indexing, all indexes of different fields are stored in the


same index file with extension (.CDX) under different tag names.
FoxPro itself gives same name as that of database file with extension.
CDX to the indexed file. Means single index file with same name as
database file gets created which store multiple indexes. Under different
tag name

INDEX ON<field name> TAG<Tag name> or <File Name>


e.g. INDEX ON EMPNAME TAG NAME<enter>
.INDEX ON EMPNAME TAG CITY <enter>

Compound index on field EMPNAME which is stored under tag name


NAME. & using second command, we made compound index on field
EMPCITY which is stored under a tag name CITY.
Both indexes are stored in a single file EMPDATA.CDX.
To activate particular index save under certain tag name. Command is

Set Order to<tag name>


E.g. Set Order to NAME <ENTER>
This will activate index tag NAME

Fundamentals of Computer Operating and Programming 386


C.O.P.A. Trade of I.T.I RD S

 DIFFERENCE BETWEEN SIMPLE INDEX & COMPO0UND


INDENX:-

SIMPLE INDEX COMPOUND INDEX


• This is used for indexing on the single • This is used for multiple field indexing.
field • The file is created with extension. CDX
• The file is created with extension .IDX • All indexes on different fields are stored in
• One index is stored in single index file the same file under different tags.
• User should give the new file name for • FoxPro itself gives the same name with the
index file. extension. CDX. as that of dbf to name the
• Index file should be opened by the index file
user for further use • In this case. CDX File gets likened with
DBF when dbf is opened

 DIFFERENCE BETWEEN INDEXING &


SORTING:-

INDEXING SORING
• Organize records logically • Organize records physically.
• Remain record no. unchanged. • Changes original record no.
• Create index file. IDX or .CDX • Created file for sorted records.
• Allow random search also. • Allow sequential search only.
• Require less time to retrieve any • Required more time to retrieve any
record. recode.
• Allow to open index file with dbf file • Cannot open sorted file with db file
• Any changes in dbf will be • Have to resort if any changes made in
automatically updated in index file dbf file.
• Index file requires less memory • Sorted file requires same memory

 DISADVANTAGES OF SORT:-

1. The added data in a DBF will not be sorted automatically


2. Each time it will create a new sorted file which will have extension
DBF and so their is a wastage of space in the memory.
3. This is slow compared to index command.

 ADVANTAGES OF INDEX :-

1. This saves memory space


2. If you will add the record in the original DBF then it will get sorted
automatically

Fundamentals of Computer Operating and Programming 387


C.O.P.A. Trade of I.T.I RD S

3. Index command is fast compared to sort you can use the index file
along with DBF using following syntax
Syntax Use<DDF File Name > Index<Index File Name> exg. USE
STUDENT INDEX STD 1
Here STUDEND is name of database file and STD1 is name of index
file. The database file and index file name may be same.

 FIND:-

This command is used to search a record in indexed DBF.

Syntax: - FIND<Character String>


E.g. Find PRAKASH

This command is used to search only character types of data so it is not


necessary to enclose the charter type of data is quotation mark is
command.

 SEEK:-

This command is used to search a record in an index DBF.

Syntax: - SEEK< Expression>


E.g. Seek 3000

This command is used with both Numeric and character type of data.
Here the character types of data must be enclosed in quotes.

E.g. Seek "PRAKASH"

Fundamentals of Computer Operating and Programming 388


C.O.P.A. Trade of I.T.I RD S

SET COMMANDS

These Commands are used to change the environment settings of


FoxPro.

 SET STATUS ON/OFF:-

This command is used to set the status line on/off .By default status line
is on.

 SET CONFIRMATION ON/OFF:-

This command is used to set the confirmation ON /OFF.

When you are entering the data using APPEND command and other
commands then after the selected field width is complete the cursor will
lcome to next field automatcially if it is off

When you will set the confirm ON the cursor will not come to next line
until you press ENTER. Other wise the last character in the Field will
be upgraded by default it is OFF.

Set date

This command is used to set the Date Format


1. Set date American : MM/DD/YY
2. Set date British : DD/MM/YY
3. Set date French : DD/MM/YY
4. Set date Italian : DD-MMY-YY
5. Set date Japan : YY/MM/DD
6. Set date ANSI : YY.MM.DD

 SET DELETED ON/OFF:-

This command is used to set the deleted On/Off. When it is ON it will


not show the logically deleted records in the list.

When it is OFF then only it will show the logically deleted records in
the list . By default it is OFF.

Fundamentals of Computer Operating and Programming 389


C.O.P.A. Trade of I.T.I RD S

 SET EXACT ON/OFF:-

It you are using the commands like list, display etc. It will show the
records depending on the tentative character.
E.g. List For Name= "G ".

This command will show the name like Geeta, Gresham etc.
If you will set the exact ON then you will have to provide the Exact
name in the command
e.g. List for name=" Geeta ". By default the exact is OFF.

 SET CLOCK ON/OFF :-

By default is it OFF. When it is on you will see clock on right top corner
of screen

 SET CLOCK TO <ROW,COLUMN>:-

This command is used to set the clock at particular row & column
e.g.set c;pcl tp 15.7

 SET DECIMAL TO<VALUE>:-

This command is used to control is used to control the no. of decimal


place. Which are displayed on the screen?
E.g. set decimal to 5. O/P will be 125.00000

 SET BELL TO FRERQUENCY, DURATION:-

E.g. set bell to 1000.10

To adjust the frequency 7 duration of hipping sound when set bell is


ON.
The frequency is in between 19 to 10,000 Hz,
Default value is 512 Hz duration in is 2 sec

 SET CENTURY ON/OFF:-

To see the date with century, set century ON. By default it is OFF
SET DEFULT TO (DRIVA/DIRECTORY)
E.g. set default toC:/Foxpro
To change logged drive or directory set default to command is used.

 SET FILTER TO <CONDITION>:-

This command is used to filter records from.dbf which satisfies certain


condition .e.g. Set filter to city = A, bad.
Brow- >

Fundamentals of Computer Operating and Programming 390


C.O.P.A. Trade of I.T.I RD S

By this command all records with city is "A' bad" are displayed
Set filter to
By this command all records in the dbf will be displayed

 SET HEADING ON/OFF :-

To set field heading ON or off in list, browse command this


command is used by default, it is ON

 SET INDEX TO:-

It is used with compound index .To open simple index file.

Syntax: - Set index to<File name>


E.g. Set index to Name<enter>

 SET MARGING TO<expn>:-

To set merging while executing the command .By default left margin is
0. The effect will be seen in printed output.

 SET ORDER TO:-

To choose master index this command is used.

 SET SAFETY ON/OFF:-

The warning messages are displayed if it is set to ON.

Fundamentals of Computer Operating and Programming 391


C.O.P.A. Trade of I.T.I RD S

FUNCTIONS

Functions means the set of program which is designed for some specific
purpose

In FOXPRO mainly there are 5 types of functions.


1. Numeric Functions
2. Database Functions.
3. Environment Functions
4. Date Functions
5. String Functions

 NUMERIC FUNCTIONS. :-

1) Abs ( ):-

This function gives the absolute value of number

Syntax: - Abs (<Numeric Value>)


e.g. Abs (-78)
O/P: 78

2) Int ( ):-

This function gives integer value of Numeric expression

Syntax: - Int (< Numeric Expression>)


e.g.? Int :( 78.65)
O/P 78

3) Log ( ):-

This function gives Logarithmic value of given numeric expression

Syntax: - Log (<Numeric Value>)


e.g.? Log (7) O/P; 1.95
This will give the log value for base e

4) Max ( ):-

This function gives maximum value from given list of values.

Syntax: - Max (<Numeric expl> <Numeric exp 2> ,----)


e.g.? Max (25,45,78,56) O/P :78

Fundamentals of Computer Operating and Programming 392


C.O.P.A. Trade of I.T.I RD S

5) Min ( ) :-

This function gives maximum value from given list of values

Syntax: - Min (<Numeric expl>, <Numer exp2. -----)


e.g Min925,45,78.56)
O/P:25

6) Sqrt ( ) :-

This function gives square root of the given no.

Syntax: - Sqrt (, Numeric Value>).


E.g. Sqrt (9) O/P: 3

7) Mod ( ):-

This function gives remainder of division of two numbers.

Syntax:-Mod (< Numeric expl>, <exp2>


e.g.> Mod (10, 3)
O/P: 1

on whether logical condition is true or false.

Syntax: - IIf (< Logical exp>, <exp2>, <exp2>


In this function, expression one end exp two should be of same type
E.g. store 50 to marks
? IIF (marks >35." pass"," fail")
O/P: Pass
Stpre 33 tp, arls
?IIF (marks<35,"pass","fail")
O/P: fail
If condition is true then first value will be considered otherwise second
value will be considered.

 DATABASE FUNCTIONS:-

8) Round ( ):-

This function gives rounded value of given number to specified no.of


decimal places
Syntax: - Round (< Numer exp>, <number of Decimal Places>)

Fundamentals of Computer Operating and Programming 393


C.O.P.A. Trade of I.T.I RD S

O/P: 65.8
? round (68.567.2)
O/P :68.57

9) IIF ( ):-

This function is used to extract one out of two values depending

1) Deleted ( ):-

This function gives true value if record is logically deleted


Syntax: - Deleted ( )
E.g. suppose at present you are on record no.3 then give command
as
Below
/deleted ( )
O/P: F. (false)
It means that the third record is not logically deleted.

Now delete the record by DELETE command Then Give command as


below
? Deleted ( )
O/P: T (true)

2) Field ( ) :-

This function gives name of the field in opened database file


Use Address
Syntax: - ? Field (4)
O/P: City
It means in address dbf fourth field is city.

3) Recounts ( ):-

This function gives total number of record in opened database file

Syntax: - Recounts ( )
e.g./ reccount ( )
O/P: 6

4) Recno ( ):-

This function gives the current record number

Fundamentals of Computer Operating and Programming 394


C.O.P.A. Trade of I.T.I RD S

Syntax: - ? Reccount ( )
e.g.? Recno ( ) O/P:

5) Recsize ( ):-

This function gives total width of the record.

Syntax: - Recsize ( )
e.g.? Recsize () O/P: 72

6) EOF ( ) (end of file):-

This function gives true value if record point is after the last record at
the end of file i.e. it gives true or false states about the end of
file.

 DATE FUNCTIONS:-

1) DATE ( ):-

This function gives us current date

Syntax: - Date ( )
e.g.:- ? Date ( ) O/p: 25/10/98

2) DOW ( ):-

This function gives numeric day of the week

Syntax: - Dow (date exp.)?Dow (date ( )) O/P:7


Note: Sunday is first day.

3) CDOW ( ):-

This function is used to give character day of week

Syntax: - Dow (Date exp)


? Cdow (date ( ))
O/P: Saturday

Fundamentals of Computer Operating and Programming 395


C.O.P.A. Trade of I.T.I RD S

4) MONTH ( ):-

This function gives numeric month from given date

Syntax: - C Month (date exp.)


? Months (date ( ))
O/P: 1

5) CMONTH ( ):-

This function gives character months of date or name of month

Syntax: - Cmonts (date exp.))


? Cmont (date ( ))
O/P: January

6) Day ( ):-

This function gives day number of month

Syntax: - Day ((Day ex. ( )


?day (Date ( ))
O/P: 25

7) Year ( ):-

This function gives us the year is four digits.

Syntax: - Year ((date exp. ( )


? Year (date ( ))
O/P: 1998

8) CTOD ( ):-

This function is used to convert the character type date to date


format.

Syntax: - CTOD (<character type date in quotation mark>)


? Ctod ("01/01/98)
O/P: - 01/01/98

Fundamentals of Computer Operating and Programming 396


C.O.P.A. Trade of I.T.I RD S

9) DTOC ( ):-

This function is used to convert date type data to character


format.

Syntax: - DTOC (<Date in date format>)


? DTOC ((date ( ))
O/P: - 01/01/97

 ENVIRONMENT FUNCTIONS:-

1) DISKSPACE ( ):-

This function gives us the total number of bytes available on the


disk.

Syntax: - Disk space ( )

2) FILE ( ):-

This function is used to check whether the specified file is


present on the disk or not. It returns True OR False result.

Syntax: - ? File ("file name with extension")

3) OS ( ):-

This function gives name of operating system with version.

 STRING FUNCTIONS:-

1) AT ( ):-

This function gives position of a character in given string.

Syntax: - AT (<character expression>), <character expression>)


e.g. ? AT ("C", ACTIVE")
Then output wills be2

Fundamentals of Computer Operating and Programming 397


C.O.P.A. Trade of I.T.I RD S

2) LEFT ( ):-

This function gives specified number of characters from left side


of character string.

Syntax: - ? LEFT (<Character expression>, <Numeric expression>)


e.g.? LEFT ("ACTIVE")
After giving this command, output will be ACT.

3) RIGHT ( ):-

This function gives specified no. of characters form the right side
of given string.

Syntax: - RIGHT (<Character expression>,<Numeric expression>)


e.g.? RIGHT ("COMPUTER", 4)

If such command is given then output will be UTER.

4) LTRIM ( ):-

This function removes blank spaces to the left of the character


string.

Syntax: - Ltrim (<Character expression>)


e.g. ? "ABC"+" XYZ"
O/P: ABC XYZ
Now use Ltrim on XYZ to remove blank spaces.
? "ABC" + LTRIM ("XYZ") The output is as below.
O/P: - ABCXYZ.

5) RTRIM ( ):-

This function is used to remove blank spaces to the Right of the


character string.

Syntax: - RTRIM (<Character string>)


? ABC "+ XYZ"
O/P: - ABC XYZ
? RTRIM (" ABC ") + "XYZ"
O/P: - ABCXYZ.

6) REPLACE ( ):-

Fundamentals of Computer Operating and Programming 398


C.O.P.A. Trade of I.T.I RD S

The function is used to repeat the specified character for specifed


number of times.

Syntax: - REPLACE (<Character exp.>,<Numeric exp.>)


e.g. 7 REPLICATE ("*", 10)
O/P: - *********

Here the star is printed 10 times.

7) SUBSTR ( ):-

This function extracts the specified no of characters from


specific position to specified position from given string.

Syntax: - ? SUBSTR (< String>, no1, no2)

It will give character from no1 up to no2.

Ex: - SUBSTR ("PRAKASH", 3, 2)


O/P: - AK

8) SPACE ( ):-

This function is used to store blank space to some character


variable.
E.g. Store space (20) to name
It will store 20 blank spaces to name.

Fundamentals of Computer Operating and Programming 399


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 400


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 401


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 402


C.O.P.A. Trade of I.T.I RD S

Fundamentals of Computer Operating and Programming 403

You might also like