Book Class Ix and X
Book Class Ix and X
INTRODUCTION TO COMPUTER
UNIT I: INTRODUCTION TO COMPUTER
Computer is an advanced electronic device that takes raw data as
an input from the user and processes it under the control of a set
of instructions (called program), produces a result (output), and
saves it for future use.
Computer - Overview
Today’s world is an information-rich world and it has become a necessity for everyone to know
about computers. A computer is an electronic data processing device, which accepts and stores data
input, processes the data input, and generates the output in a required format.
The purpose of this tutorial is to introduce you to Computers and its fundamentals.
Functionalities of a Computer
If we look at it in a very broad sense, any digital computer carries out the following five functions −
Step 1 − Takes data as input.
Step 2 − Stores the data/instructions in its memory and uses them as required.
Step 3 − Processes the data and converts it into useful information.
Step 4 − Generates the output.
Step 5 − Controls all the above four steps.
Advantages of Computers
Following are certain advantages of computers.
High Speed
Computer is a very fast device.
It is capable of performing calculation of very large amount of data.
The computer has units of speed in microsecond, nanosecond, and even the picosecond.
It can perform millions of calculations in a few seconds as compared to man who will spend many
months to perform the same task.
Accuracy
In addition to being very fast, computers are very accurate.
The calculations are 100% error free.
Computers perform all jobs with 100% accuracy provided that the input is correct.
Storage Capability
Memory is a very important characteristic of computers.
A computer has much more storage capacity than human beings.
It can store large amount of data.
It can store any type of data such as images, videos, text, audio, etc.
Diligence
Unlike human beings, a computer is free from monotony, tiredness, and lack of concentration.
It can work continuously without any error and boredom.
It can perform repeated tasks with the same speed and accuracy.
Versatility
A computer is a very versatile machine.
A computer is very flexible in performing the jobs to be done.
This machine can be used to solve the problems related to various fields.
At one instance, it may be solving a complex scientific problem and the very next moment it may be
playing a card game.
Reliability
A computer is a reliable machine.
Modern electronic components have long lives.
Computers are designed to make maintenance easy.
Automation
Computer is an automatic machine.
Automation is the ability to perform a given task automatically. Once the computer receives a
program i.e., the program is stored in the computer memory, then the program and instruction can
control the program execution without human interaction.
Reduction in Paper Work and Cost
The use of computers for data processing in an organization leads to reduction in paper work and
results in speeding up the process.
As data in electronic files can be retrieved as and when required, the problem of maintenance of
large number of paper files gets reduced.
Though the initial investment for installing a computer is high, it substantially reduces the cost of
each of its transaction.
Disadvantages of Computers
Following are certain disadvantages of computers.
A computer is a machine that has no intelligence to perform any task.
Each instruction has to be given to the computer.
A computer cannot take any decision on its own.
Dependency
It functions as per the user’s instruction; thus, it is fully dependent on humans.
Environment
The operating environment of the computer should be dust free and suitable.
No Feeling
Computers have no feelings or emotions.
It cannot make judgment based on feeling, taste, experience, and knowledge unlike humans.
In older computer monitors and televisions, the CRT (cathode ray tube) was widely used as a screen is a kind of
vacuum tube. First, it was invented as a basic component for electronic devices and most commonly used in the
evolution of analog as well as digital computers in the first half of the twentieth century.
The vacuum tube produces electrons and an anode as it was made of a cathode, and the anode collects the
electrons called a diode. However, there were other kinds of vacuum tubes available, which were categorized on
the basis of the number of electrodes presented. Then, these electrodes are surrounded typically in glass, in a
casing; when energized enough, it can act as a conductor with all the air detached. As lightning travels through the
air, in the same way, a pathway becomes for electrons. Therefore, it is commonly known as the vacuum tube due
to the shape of the vacuum.
Also, the vacuum tube produced a lot of heat as it needed massive amounts of power; because it required a heating
filament for producing electrons. Due to a lot of heat, the components were quickly degraded; therefore, they
burned out quickly. In order to work, three different power sources are also required by vacuum tubes, which are
based on capacities and ratings. The power consumption and size became smaller with the progress of vacuum
tube technology. Also, they were cost-effective, and transistors work effectively only for low frequencies. With
the transistors in a cascade, a hundred transistors in parallel and wired together will be required for high
frequencies. That led to the need for heat sinks, which creates massive heat.
An equivalent transmitter needs significantly less power and only uses a single tube. Also, it can be coded with the
help of forced air or water cooling. The speaker damping effect of vacuum tubes and solid-state amplifiers cannot
repeat the peculiar distortion; hence, in sound amplifiers, the vacuum tubes are more common. The vacuum tube
started to replace by the transistor in the 1950s. Due to the size of the transistors, they were become much ideal to
use as the size of computing devices started to become smaller. In smaller computing devices, vacuum tubes did
not fit as they were large in size, which led to becoming less useful.
Additionally, today vacuum tubes are still used in high-end audio equipment and big radio stations, especially
those using frequencies more than 50 MHz and energy levels more than 10,000 W; hence, the vacuum tube
technology is not completely obsolete.
2 Second Generation
The period of second generation: 1959-1965. Transistor based.
What is a Transistor? A transistor is a type of a semiconductor device that can be used to both conduct and
insulate electric current or voltage. A transistor basically acts as a switch and an amplifier. In simple
words, we can say that a transistor is a miniature device that is used to control or regulate the flow of
electronic signals.
Transistors are one of the key components in most of the electronic devices that are present today.
Developed in the year 1947 by three American physicists John Bardeen, Walter Brattain and William
Shockley, the transistor is considered as one of the most important inventions in the history of science.
Parts of a Transistor
A typical transistor is composed of three layers of semiconductor materials or more specifically terminals
which helps to make a connection to an external circuit and carry the current. A voltage or current that is
applied to any one pair of the terminals of a transistor controls the current through the other pair of
terminals. There are three terminals for a transistor. They are:
3 Third Generation
The period of third generation: 1965-1971. Integrated Circuit based.
What is an Integrated Circuit (IC)?
The circuits that were made previously were large and
bulky, consisting of circuit components like resistor,
capacitor, inductor, transistor, diodes, etc., which were
connected with copper wires. This factor limited the use
of the circuits to big machines. It was not possible to
create small and compact appliances with these big
circuits. Moreover, they were not entirely shockproof
and reliable.
Integrated Chip
Integrated circuits can function as an oscillator, amplifier, microprocessor or even as a computer memory.
5 Fifth Generation
The period of fifth generation: 1980-onwards. ULSI microprocessor based.
The history of the computer dates back to several years. There are five prominent generations of
computers. Each generation has witnessed several technological advances which change the functionality
of the computers. This results in more compact, powerful, robust systems which are less expensive.
The history of the computer dates back to several years. There are five prominent generations of
computers. Each generation has witnessed several technological advances which change the
functionality of the computers. This results in more compact, powerful, robust systems which are
less expensive. The brief history of computers is discussed below −
First Generation (1940-1956)
The first-generation computers had the following features and components −
Hardware
The hardware used in the first generation of computers was: Vacuum Tubes and Punch Cards.
Features
Following are the features of first generation computers −
It supported machine language.
It had slow performance
It occupied large size due to the use of vacuum tubes.
It had a poor storage capacity.
It consumed a lot of electricity and generated a lot of heat.
Memory
The memory was of 4000 bits.
Data Input
The input was only provided through hard-wired programs in the computer, mostly through
punched cards and paper tapes.
Examples
The examples of first generation computers are −
ENIAC
UNIVACTBM 701
Second Generation (1956-1963)
Several advancements in the first-gen computers led to the development of second generation
computers. Following are various changes in features and components of second generation
computers −
Hardware
The hardware used in the second generation of computers were −
Transistors
Magnetic Tapes
Features
It had features like −
Batch operating system
Faster and smaller in size
Reliable and energy efficient than the previous generation
Less costly than the previous generation
Memory
The capacity of the memory was 32,000 bits.
Data Input
The input was provided through punched cards.
Examples
The examples of second-generation computers are −
Honeywell 400
CDC 1604
IBM 7030
Third Generation (1964-1971)
Following are the various components and features of the third-generation computers −
Hardware
The hardware used in the third generation of computers were −
Integrated Circuits made from semi-conductor materials
Large capacity disks and magnetic tapes
Features
The features of the third-generation computers are −
Supports time-sharing OS
Faster, smaller, more reliable and cheaper than the previous generations
Easy to access
Memory
The capacity of the memory was 128,000 bits.
Data Input
The input was provided through keyboards and monitors.
Examples
The examples of third generation computers are −
IBM 360/370
CDC 6600
PDP 8/11
Fourth Generation (1972-2010)
Fourth generation computers have the following components and features −
Hardware
The Hardware used in the fourth generation of computers were −
ICs with Very Large-Scale Integration (VLSI) technology
Semiconductor memory
Magnetic tapes and Floppy
Features
It supports features like −
Multiprocessing & distributed OS
Object-oriented high-level programs supported
Small & easy to use; hand-held computers have evolved
No external cooling required & affordable
This generation saw the development of networks and the internet
It saw the development of new trends in GUIs and mouse
Memory
The capacity of the memory was 100 million bits.
Data Input
The input was provided through improved hand held devices, keyboard and mouse.
Examples
The examples of fourth generation computers are −
Apple II
VAX 9000
CRAY 1 (super computers)
Fifth Generation (2010-Present)
These are the modern and advanced computers. Significant changes in the components and
operations have made fifth generation computers handy and more reliable than the previous
generations.
Hardware
The Hardware used in the fifth generation of computers are −
Integrated Circuits with VLSI and Nano technology
Large capacity hard disk with RAID support
Powerful servers, Internet, Cluster computing
Features
It supports features like −
Powerful, cheap, reliable and easy to use.
Portable and faster due to use of parallel processors and Super Large Scale Integrated Circuits.
Rapid software development is possible.
Memory
The capacity of the memory is unlimited.
Data Input
The input is provided through CDROM, Optical Disk and other touch and voice sensitive input
devices.
Examples
The examples of fifth generation computers are −
IBM
Pentium
PARAM
Computer - Types
Computers can be broadly classified by their speed and computing power.
S.No. Type Specifications
PC (Personal It is a single user computer system having
1
Computer) moderately powerful microprocessor
It is also a single user computer system,
2 Workstation similar to personal computer however has
a more powerful microprocessor.
It is a multi-user computer system,
3 Mini Computer capable of supporting hundreds of users
simultaneously.
It is a multi-user computer system,
capable of supporting hundreds of users
4 Main Frame
simultaneously. Software technology is
different from minicomputer.
5 Supercomputer It is an extremely fast computer, which
can execute hundreds of millions of
instructions per second.
PC (Personal Computer)
A PC can be defined as a small, relatively inexpensive computer designed for an individual user.
PCs are based on the microprocessor technology that enables manufacturers to put an entire CPU on
one chip. Businesses use personal computers for word processing, accounting, desktop publishing,
and for running spreadsheet and database management applications. At home, the most popular use
for personal computers is playing games and surfing the Internet.
Although personal computers are designed as single-user systems, these systems are normally
linked together to form a network. In terms of power, now-a-days high-end models of the
Macintosh and PC offer the same computing power and graphics capability as low-end workstations
by Sun Microsystems, Hewlett-Packard, and Dell.
Workstation
Workstation is a computer used for engineering applications (CAD/CAM), desktop publishing,
software development, and other such types of applications which require a moderate amount of
computing power and relatively high quality graphics capabilities.
Workstations generally come with a large, high-resolution graphics screen, large amount of RAM,
inbuilt network support, and a graphical user interface. Most workstations also have mass storage
device such as a disk drive, but a special type of workstation, called diskless workstation, comes
without a disk drive.
Common operating systems for workstations are UNIX and Windows NT. Like PC, workstations
are also single-user computers like PC but are typically linked together to form a local-area
network, although they can also be used as stand-alone systems.
Minicomputer
It is a midsize multi-processing system capable of supporting up to 250 users simultaneously.
Mainframe
Mainframe is very large in size and is an expensive computer capable of supporting hundreds or
even thousands of users simultaneously. Mainframe executes many programs concurrently and
supports many simultaneous execution of programs.
Supercomputer
Supercomputers are one of the fastest computers currently available. Supercomputers are very
expensive and are employed for specialized applications that require immense amount of
mathematical calculations (number crunching).
For example, weather forecasting, scientific simulations, (animated) graphics, fluid dynamic
calculations, nuclear energy research, electronic design, and analysis of geological data (e.g. in
petrochemical prospecting).
Computer – Components
All types of computers follow the same basic logical structure and perform the following five basic
operations for converting raw input data into information useful to their users.
S.No. Operation Description
The process of entering data and instructions
1 Take Input
into the computer system.
Saving data and instructions so that they are
2 Store Data available for processing as and when
required.
3 Processing Performing arithmetic, and logical
operations on data in order to convert them
Data
into useful information.
The process of producing useful information
Output
4 or results for the user, such as a printed
Information
report or visual display.
Control the Directs the manner and sequence in which
5
workflow all of the above operations are performed
Control Unit
This unit controls the operations of all parts of the computer but does not carry out any actual data
processing operations.
Functions of this unit are −
It is responsible for controlling the transfer of data and instructions among other units of a
computer.
It manages and coordinates all the units of the computer.
It obtains the instructions from the memory, interprets them, and directs the operation of the
computer.
It communicates with Input/Output devices for transfer of data or results from storage.
It does not process or store data.
ALU (Arithmetic Logic Unit)
This unit consists of two subsections namely,
Arithmetic Section
Logic Section
Arithmetic Section
Function of arithmetic section is to perform arithmetic operations like addition, subtraction,
multiplication, and division. All complex operations are done by making repetitive use of the above
operations.
Logic Section
Function of logic section is to perform logic operations such as comparing, selecting, matching, and
merging of data.
Computer - Input Devices
Following are some of the important input devices which are used in a computer −
Keyboard
Mouse
Joy Stick
Light pen
Track Ball
Scanner
Graphic Tablet
Microphone
Magnetic Ink Card Reader(MICR)
Optical Character Reader(OCR)
Bar Code Reader
Optical Mark Reader(OMR)
Keyboard
Keyboard is the most common and very popular input device which helps to input data
to the computer. The layout of the keyboard is like that of traditional typewriter, although
there are some additional keys provided for performing additional functions.
Keyboards are of two sizes 84 keys or 101/102 keys, but now keyboards with
104 keys or 108 keys are also available for Windows and Internet.
The keys on the keyboard are as follows –
Advantages
Easy to use
Not very expensive
Moves the cursor faster than the arrow keys of the keyboard.
Joystick
Joystick is also a pointing device, which is used to move the cursor
position on a monitor
screen. It is a stick having a spherical ball at its both lower and upper ends. The lower spherical
Ball moves in a socket. The joystick can be moved in all four directions.
The function of the joystick is similar to that of a mouse. It is mainly used in
Computer Aided Designing (CAD) and playing computer games.
Light Pen
Light pen is a pointing device similar to a pen. It is used to select a
displayed menu item or
draw pictures on the monitor screen. It consists of a photocell and an
optical system placed
in a small tube.
When the tip of a light pen is moved over the monitor screen and the pen button is pressed, its
photocell sensing element detects the screen location and sends the corresponding signal to the
CPU.
Track Ball
Track ball is an input device that is mostly used in notebook or
laptop computer, instead of a mouse.
This is a ball which is half inserted and by moving fingers on the
ball, the pointer can be moved.
Since the whole device is not moved, a track ball requires less
space than a mouse. A track ball comes in various shapes like a
ball, a button, or a square.
Scanner
Scanner is an input device, which works more like a photocopy
machine. It is used when some information
is available on paper and it is to be transferred to the hard disk of
the computer for further manipulation.
Digitizer
Digitizer is an input device which converts analog information into digital form. Digitizer can
convert a signal from the television or camera into a series of numbers that could be stored in a
computer. They can be used by the computer to create a picture of whatever the camera had been
pointed at.
Digitizer is also known as Tablet or Graphics Tablet as it converts
graphics and pictorial data into binary inputs. A graphic tablet as
digitizer is used for fine works of drawing and image
manipulation applications.
Microphone
Microphone is an input device to input sound that is then stored in
a digital form.
The microphone is used for various applications such as adding sound
to a multimedia presentation or for mixing music.
OCR scans the text optically, character by character, converts them into
a machine readable code, and stores the text on the system memory.
Bar Code Readers
Bar Code Reader is a device used for reading bar coded data (data in the
form of light and dark lines). Bar coded data is
generally used in labelling goods, numbering
the books, etc. It may be a handheld scanner or may be embedded in a
stationary scanner.
Bar Code Reader scans a bar code image, converts it into an alphanumeric
value, which is then fed to the computer that the bar code reader is
connected to.
Optical Mark Reader (OMR)
OMR is a special type of optical scanner used to recognize the type of mark made by pen or pencil.
It is used where one out of a few alternatives is to be
selected and marked.
A finite number of characters can be displayed on a screen at once. The screen can be divided into a
series of character boxes - fixed location on the screen where a standard character can be placed.
Most screens are capable of displaying 80 characters of data horizontally and 25 lines vertically.
There are some disadvantages of CRT −
Large in Size
High power consumption
Flat-Panel Display Monitor
The flat-panel display refers to a class of video devices that have
reduced volume, weight and power requirement in comparison to the
CRT. You can hang them on walls or wear them on your wrists.
Current uses of flat-panel displays include calculators, video games,
monitors, laptop computer, and graphics display.
Advantages
Inexpensive
Widely Used
Other language characters can be printed
Disadvantages
Slow Speed
Poor Quality
Daisy Wheel
Head is lying on a wheel and pins corresponding to characters
are like petals of Daisy (flower) which is why it is called
Daisy Wheel Printer. These printers are generally used for
word-processing in offices that require a few letters to be sent
here and there with very nice quality.
Advantages
More reliable than DMP
Better quality
Fonts of character can be easily changed
Disadvantages
Slower than DMP
Noisy
More expensive than DMP
Line Printers
Line printers are the printers which print one line at a time.
Advantages
Very high speed
Very high quality output
Good graphics quality
Supports many fonts and different character size
Disadvantages
Expensive
Cannot be used to produce multiple copies of a document in a single printing
Inkjet Printers
Inkjet printers are non-impact character printers based on a
relatively new technology. They print characters by spraying small
drops of ink onto paper. Inkjet printers produce high quality output
with presentable features.
They make less noise because no hammering is done and these have
many styles of printing modes available. Color printing is also
possible. Some models of Inkjet printers can produce multiple
copies of printing also.
Advantages
High quality printing
More reliable
Disadvantages
Expensive as the cost per page is high
Slow as compared to laser printer
Computer - Memory
Computer - Memory
A memory is just like a human brain. It is used to store data and instructions. Computer memory is
the storage space in the computer, where data is to be processed and instructions required for
processing are stored. The memory is divided into large number of small parts called cells. Each
location or cell has a unique address, which varies from zero to memory size minus one. For
example, if the computer has 64k words, then this memory unit has 64 * 1024 = 65536 memory
locations. The address of these locations varies from 0 to 65535.
Memory is primarily of three types −
Cache Memory
Primary Memory/Main Memory
Secondary Memory
Cache Memory
Cache memory is a very high speed semiconductor memory which can speed up the CPU. It acts as
a buffer between the CPU and the main memory. It is used to hold those parts of data and program
which are most frequently used by the CPU. The parts of data and programs are transferred from the
disk to cache memory by the operating system, from where
the CPU can access them.
Advantages
The advantages of cache memory are as follows −
Cache memory is faster than main memory.
It consumes less access time as compared to main memory.
It stores the program that can be executed within a short
period of time.
It stores data for temporary use.
Disadvantages
The disadvantages of cache memory are as follows −
Cache memory has limited capacity.
It is very expensive.
Primary Memory (Main Memory)
Primary memory holds only those data and instructions on which the computer is currently working.
It has a limited capacity and data is lost when power is switched
off. It is generally made up of semiconductor device. These
memories are not as fast as registers. The data and instruction
required to be processed resides in the main memory. It is divided
into two subcategories RAM and ROM.
Computer – RAM
RAM (Random Access Memory) is the internal memory of the CPU for storing data, program, and
program result. It is a read/write memory which stores data until the machine is working. As soon as
the machine is switched off, data is erased.
Let us now discuss the various types of ROMs and their characteristics.
MROM (Masked ROM)
The very first ROMs were hard-wired devices that contained a pre-programmed set of data or
instructions. These kind of ROMs are known as masked ROMs, which are inexpensive.
PROM (Programmable Read Only Memory)
PROM is read-only memory that can be modified only once by a user. The user buys a blank
PROM and enters the desired contents using a PROM program. Inside the PROM chip, there are
small fuses which are burnt open during programming. It can be programmed only once and is not
erasable.
EPROM (Erasable and Programmable Read Only Memory)
EPROM can be erased by exposing it to ultra-violet light for a duration of up to 40 minutes.
Usually, an EPROM eraser achieves this function. During programming, an electrical charge is
trapped in an insulated gate region. The charge is retained for more than 10 years because the
charge has no leakage path. For erasing this charge, ultra-violet light is passed through a quartz
crystal window (lid). This exposure to ultra-violet light dissipates the charge. During normal use,
the quartz lid is sealed with a sticker.
EEPROM (Electrically Erasable and Programmable Read Only Memory)
EEPROM is programmed and erased electrically. It can be erased and reprogrammed about ten
thousand times. Both erasing and programming take about 4 to 10 ms (millisecond). In EEPROM,
any location can be selectively erased and programmed. EEPROMs can be erased one byte at a
time, rather than erasing the entire chip. Hence, the process of reprogramming is flexible but slow.
Advantages of ROM
The advantages of ROM are as follows −
Non-volatile in nature
Cannot be accidentally changed
Cheaper than RAMs
Easy to test
More reliable than RAMs
Static and do not require refreshing
Contents are always known and can be verified
Motherboard
The motherboard serves as a single platform to
connect all of the parts of a computer together. It
connects the CPU, memory, hard drives, optical
drives, video card, sound card, and other ports and
expansion cards directly or via cables. It can be
considered as the backbone of a computer.
Features of Motherboard
A motherboard comes with following features −
Motherboard varies greatly in supporting various types of components.
Motherboard supports a single type of CPU and few types of memories.
Video cards, hard disks, sound cards have to be compatible with the motherboard to function
properly.
Motherboards, cases, and power supplies must be compatible to work properly together.
Popular Manufacturers
Following are the popular manufacturers of the motherboard.
Intel
ASUS
AOpen
ABIT
Biostar
Gigabyte
MSI
Description of Motherboard
The motherboard is mounted inside the case and is securely attached via small screws through pre-
drilled holes. Motherboard contains ports to connect all of the internal components. It provides a
single socket for CPU, whereas for memory, normally one or more slots are available.
Motherboards provide ports to attach the floppy drive, hard drive, and optical drives via ribbon
cables. Motherboard carries fans and a special port designed for power supply.
There is a peripheral card slot in front of the motherboard using which video cards, sound cards, and
other expansion cards can be connected to the motherboard.
On the left side, motherboards carry a number of ports to connect the monitor, printer, mouse,
keyboard, speaker, and network cables. Motherboards also provide USB ports, which allow
compatible devices to be connected in plug-in/plug-out fashion. For example, pen drive, digital
cameras, etc.
Computer - Memory Units
Memory unit is the amount of data that can be stored in the storage unit. This storage capacity is
expressed in terms of Bytes.
The following table explains the main memory storage units −
S.No. Unit & Description
Bit (Binary Digit)
1 A binary digit is logical 0 and 1 representing a passive or an
active state of a component in an electric circuit.
Nibble
2
A group of 4 bits is called nibble.
Byte
3 A group of 8 bits is called byte. A byte is the smallest unit,
which can represent a data item or a character.
Word
A computer word, like a byte, is a group of fixed number of
bits processed as a unit, which varies from computer to
computer but is fixed for each computer.
4
The length of a computer word is called word-size or word
length. It may be as small as 8 bits or may be as long as 96 bits.
A computer stores the information in the form of computer
words.
The following table lists some higher storage units −
S.No. Unit & Description
Kilobyte (KB)
1
1 KB = 1024 Bytes
Megabyte (MB)
2
1 MB = 1024 KB
GigaByte (GB)
3
1 GB = 1024 MB
TeraByte (TB)
4
1 TB = 1024 GB
PetaByte (PB)
5
1 PB = 1024 TB
Computer - Ports
A port is a physical docking point using which an external device can be connected to the computer.
It can also be programmatic docking point through which information flows from a program to the
computer or over the Internet.
Characteristics of Ports
A port has the following characteristics −
External devices are connected to a computer using cables and ports.
Ports are slots on the motherboard into which a cable of external device is plugged in.
Examples of external devices attached via ports are the mouse, keyboard, monitor, microphone,
speakers, etc.
Let us now discuss a few important types of ports −
Serial Port
Used for external modems and older computer mouse
Two versions: 9 pin, 25 pin model
Data travels at 115 kilobits per second
Parallel Port
Used for scanners and printers
Also called printer port
25 pin model
IEEE 1284-compliant Centronics port
PS/2 Port
Used for old computer keyboard and mouse
Also called mouse port
Most of the old computers provide two PS/2 port, each for the mouse and keyboard
IEEE 1284-compliant Centronics port
Universal Serial Bus (or USB) Port
It can connect all kinds of external USB devices such as external hard disk, printer, scanner, mouse,
keyboard, etc.
It was introduced in 1997.
Most of the computers provide two USB ports as minimum.
Data travels at 12 megabits per seconds.
USB compliant devices can get power from a USB port.
VGA Port
Connects monitor to a computer's video card.
It has 15 holes.
Similar to the serial port connector. However, serial port connector has pins, VGA port has holes.
Power Connector
Three-pronged plug.
Connects to the computer's power cable that plugs into a power bar or wall socket.
Firewire Port
Transfers large amount of data at very fast speed.
Connects camcorders and video equipment to the computer.
Data travels at 400 to 800 megabits per seconds.
Invented by Apple.
It has three variants: 4-Pin FireWire 400 connector, 6-Pin FireWire 400 connector, and 9-Pin
FireWire 800 connector.
Modem Port
Connects a PC's modem to the telephone network.
Ethernet Port
Connects to a network and high speed Internet.
Connects the network cable to a computer.
This port resides on an Ethernet Card.
Data travels at 10 megabits to 1000 megabits per seconds depending upon the network bandwidth.
Game Port
Connect a joystick to a PC
Now replaced by USB
Digital Video Interface, DVI port
Connects Flat panel LCD monitor to the computer's high-end video graphic cards.
Very popular among video card manufacturers.
Sockets
Sockets connect the microphone and speakers to the sound card of the computer.
Computer - Hardware
Hardware represents the physical and tangible components of a computer, i.e. the components that
can be seen and touched.
Examples of Hardware are the following −
Input devices − keyboard, mouse, etc.
Output devices − printer, monitor, etc.
Secondary storage devices − Hard disk, CD, DVD, etc.
Internal components − CPU, motherboard, RAM, etc.
Relationship between Hardware and Software
Hardware and software are mutually dependent on each other. Both of them must work together to
make a computer produce a useful output.
Software cannot be utilized without supporting hardware.
Hardware without a set of programs to operate upon cannot be utilized and is useless.
To get a particular job done on the computer, relevant software should be loaded into the hardware.
Hardware is a one-time expense.
Software development is very expensive and is a continuing expense.
Different software applications can be loaded on a hardware to run different jobs.
A software acts as an interface between the user and the hardware.
If the hardware is the 'heart' of a computer system, then the software is its 'soul'. Both are
complementary to each other.
MCQ
2. A computer assisted method for the recording and analyzing of existing or hypothetical systems
is
A. Data transmission
B. Data flow
C. Data capture
D. Data processing
E. None of the above
4. What difference does the 5th generation computer have from other generation computers?
A. Technological advancement
B. Scientific code
C. Object Oriented Programming
D. All of the above
E. None of the above
5. Which of the following computer language is used for artificial intelligence?
A. FORTRAN
B. PROLOG
C. C
D. COBOL
E. None of the above
6. The tracks on a disk which can be accessed without repositioning the R/W heads is
A. Surface
B. Cylinder
C. Cluster
D. All of the above
E. None of the above
11. Codes consisting of light and dark marks which may be optically read is known as
A. Mnemonics
B. Bar code
C. Decoder
D. All of the above
E. None of the above
12. A type of channel used to connect a central processor and peripherals which uses multipling is
known as
A. Modem
B. Network
C. Multiplexer
D. All of the above
E. None of the above
13. The first generation of computers available was based on the bit micro processors.
A. 4
B. 8
C. 16
D. 64
E. None of the above
14. The complete picture of data stored in database is known as
A. Record
B. Schema
C. System flowchart
D. DBMS
E. None of the above
15. Which of the following is intended to be used in all applications runs on mainframe computers.
A. LOGO
B. APL
C. PL/1
D. OCCAM
E. None of the above
16. A language which is close to that used within the computer is
A. High-level language
B. Assembly language
C. Low-level language
D. All of the above
E. None of the above
17. Which is a unit representing the no bits of discrete.
A. Baud
B. Byte
C. Bit
D. All of the above
E. None of the above
18. The device that can both feed data into and accept data from a computer is
A. ALU
B. CPU
C. Input-Output device
D. All of the above
E. None of the above
19. The personnel who deals with the computer & its management put together are called
A. Software
B. Humanware
C. Firmware
D. Hardware
E. None of the above
20. A modern digital computer has
A. Extremely high speed
B. Large memory
C. Almost unlimited array
D. All of the above
E. None of the above
21. Backing storage is so named because it
A. is always kept at the back of the CP.U.
B. is slow and backward
C. backs up the computer's main memory
D. lags behind the main memory
E. None of the above
22. The ASCII code for the character J is:
A. 1001 0001
B. 1001 1010
C. 0100 1010
D. 1010 0001
E. None of the above
23. Off-line operation is the operation of devices without the control of
A. Memory
B. CPU
C. ALU
D. Control unit
E. None of the above
24. What is meant by a dedicated computer?
A. Which is used by one person only
B. Which is assigned one and only one task
C. Which uses on kind of software
D. Which is meant for application software only
E. None of the above
25. Which of the following is the user programmed semiconductor memory?
A. SRAM
B. DRAM
C. EPROM
D. All of the above
E. None of the above
26. An instruction that transfers program control to one or more possible paths is known as
A. Utility program
B. System software
C. Broadband channel
D. Application program
E. None of the above
27. The two kinds of main Memory are:
A. Primary and secondary
B. Random and sequential
C. ROM and RAM
D. All of the above
E. None of the above
28. Name of the first guided weapon in the world which used a programmable digital computer:
A. Sting Ray Torpedo
B. Mk 46 Torpedo
C. Air-Launched Cruise Missile (ALCM)
D. Tomahawk Missile
E. None of the above
29. Programs designed to perform specific tasks is called known as
A. System software
B. Application software
C. Utility programs
D. Operating system
E. None of the above
30. What is the name given to the weapons which use computerised guidance system?
A. Guided weapons
B. Smart weapons
C. Dumb weapons
D. Starwars weapons
E. None of the above
QUESTION :-
1 What is a Computer? Write the functions of computer?
2 Write the advantages and disadvantages of computer?
3 Discuss about 1st and 2nd generation of computer?
4 Discuss about 3rd and 4th generations of computer?
5 Discuss about fifth generation of computer? What is AI?
6 Short note :- Workstation , mini, supercomputer, mainframe, CPU ,ALU,RAM,
ROM,EPROM.EROM.STATIC RAM, DIANAMIC RAM?
7. Discuss about various type of monitor and printer?
8. What if cache memory? write advantage and disadvantage?
9. What is motherboard? write the name of its components?
10. what is port? Discuss about various ports of computer?
Binary to Decimal
In this conversion, a number with base 2 is converted into number with base 10. Each binary digit
here is multiplied by decreasing power of 2. Let us see one example:
Octal to Decimal
In this conversion, a number with base 8 is converted into number with base 10. Each digit of octal
number here is multiplied by decreasing power of 8. Let us see one example:
Decimal to Octal
Here the decimal number is required to be divided by 8 until the quotient is 0. Then, in the same way,
we count the remainder from LSB to MSB to get the equivalent octal number.
Hexadecimal to Decimal
In this conversion, a number with base 16 is converted into number with base 10. Each digit of hex
number here is multiplied by decreasing power of 16. Let us understand with the help of an example:
Decimal to Hexadecimal
The given decimal number here is divided by 16 to get the equivalent hex. The division of the
number continues until we get the quotient 0.
Binary Arithmetic Operations
; Like we perform the arithmetic operations in numerals, in the same way, we can perform addition, subtraction,
multiplication and division operations on Binary numbers. Let us learn them one by one.
Binary Addition
Adding two binary numbers will give us a binary number itself. This is the simplest method. Addition
of two single-digit binary number is given in the table below.
Binary Subtraction
Subtracting two binary numbers will give us a binary
number itself. This is also an easy method. Subtraction of
two single-digit binary number is given in the table
below.
Let us take an example of two binary numbers and
subtract them.
Example: Subtract 11012 and 10102.
Solution:
Binary Multiplication
The multiplication process is the same for the Binary Division
binary numbers as it is for numerals. Let us The binary division is similar to the decimal number
understand it with example. division method. We will learn with an example
Let’s multiply 1101 x 1010 here.
Example: Divide 10102 by 102
Solution:
Logic gates are the basic building blocks of any digital system. It is an electronic circuit having one or more than
one input and only one output. The relationship between the input and the output is based on certain logic. Based
on this, logic gates are named as AND gate, OR gate, NOT gate etc.
OR GATE(Logical addition
• If the two input values are both 0, the
output value is 0; otherwise, the output is 1
NOT Gate
NOT gate is also known as Inverter. It has one
input A and one output Y.
XOR Gate
• XOR, or exclusive OR, gate
– An XOR gate produces 0 if its two inputs are
the same, and a 1 otherwise
– Note the difference between the XOR gate
and the OR gate; they differ only in one
input situation
– When both input signals are 1, the OR gate
produces a 1 and the XOR produces a 0
B. PRACTICE QUESTIONS :-
I- BINARY ADDITION :- 10110+10100+111010 , 1011101+10111+110101 , 101101010+1111110
II- Binary Substruction:- 101010-101010 , 1011010-101010 , 10111-1010
III- Binary Multiplication:- 1011010*101000 , 10101011*1110101 , 10111*101
IV- Divition:- 110101/1101 , 1011011/110 , 10110/10 , 10111/10 , 101111/111
V- Describe :- AND ,OR ,NOR, XOR ,NAND , NOR Gates with a proper logic diagram and truth table,
VI-What is negative number give example
VII -Add the number using 1’s and 2’s compliment 101101+101010 , 10110+10111, 101+101 , 1010111+1011,1010+1111
UNIT: III INTRODUCTION TO DOS AND
WINDOWS
Disk Operating System
DOS (Disk Operating System) is an operating system that runs from a hard disk drive. The term
can also refer to a particular family of disk operating systems, most commonly MS-DOS
(Microsoft Disk Operating System).
Features of Dos
* It is the primary system where the user will get an environment about the input and output
deviates, e.g. Monitor, Keyboard, Printers etc.
* It is helpful in performing file management e.g., creating, editing, deleting files etc.
* It is a single user operating system. ...
* It is Character Based interface system.
Booting: When we start our Computer then there is an operation which is performed
automatically by the Computer which is also called as Booting. In the Booting, System
will check all the hardware’s and Software’s those are installed or Attached with the
System and this will also load all the Files those are needed for running a system.
STARTING DOS
Step 1 : click on start button
Step 2 : Search for Command Prompt And click on it
Method 2
Step1 :-Press Windows + R key together
Step 2 : Type CMD in the run box
Step 3 : hit enter button and command prompt will open
DOS commands are small programs, which are made to perform a particular job. Every
DOS command performs different task. It is not possible to work on the computer
without these commands. There are two types of DOS command.
Internal Commands : These commands enter into the computer memory during
computer booting. These commands are not in the form of any file; so neither they can
be viewed nor can be edited or detected. For example : MD, CD, TIME, DATE,
COPY, COPR CON, TYPE ETC.
External Commands : These commands are stored in the computer list in the form of
files. These Commands can be viewed, copied, changed or deleted. For example :
FORMAT, COPY, PRINT, SYS, EDIT, TREE, SORT, PROMPT etc.
SOME DOS COMMANDS AND THERE TYPES:-
4. Windows will now load up and you will eventually come to a screen called the
Desktop.
Imagine your Desktop is just that the top of a desk, computers are designed
around the working world the office in particular. The Desktop was designed so
you have everything at hand just like sitting at your desk.
Let’s have a look at some Icons you may have in more detail:
2. These are Web Browsers we use for browsing the internet so we can visit
websites and search for information – we’ll look at these in detail in another
lesson.
Check the computer you are using to see what is on the Desktop, it may even
have them all
3. There are also other Icons, you can create Icons “ Also Known As Shortcuts”
they are shortcuts on the Desktop so we don’t have to delve deeper into the
computer to find the programs we want to launch.
This is a Microsoft Word File, a file you create when using Microsoft Word. For
example if you create a
letter called Hello Katie using Microsoft Word and then saved it on your Desktop the file
would look like this.
The Taskbar
1. The Taskbar is the thin strip that runs across the bottom of your screen. It is split
into a number of different areas: a Start button, Quick Launch icons, a notification
area, and a clock. All other areas are the Taskbar itself. The image below shows
the left hand side of the taskbar.
Connecting To Wi-Fi
In this lesson we will look at connecting to the internet using Wi-Fi or wireless internet. Before going ahead
make sure you are in an area where there is Wi-Fi available, you know the name of the network and that you
have the password to access it
4. Press the “ESC” key at the top right of the keyboard to come out of the network
connections. You are now connected to the internet!
WIFI(Wireless Fidelity)
Wi-Fi is the name of a wireless networking technology that uses radio waves to provide wireless
high-speed Internet and network connections. A common misconception is that the term Wi-Fi is
short for "wireless fidelity," however this is not the case. Wi-Fi is simply a trademarked phrase that
means IEEE 802.11x.
Bluetooth
Bluetooth is a wireless technology standard used for exchanging data between fixed and mobile
devices over short distances using short-wavelength UHF radio waves in the industrial, scientific and
medical radio bands, from 2.402 GHz to 2.480 GHz, and building personal area networks.
RJ 45 CONNECTOR:-RJ45 is a type
of connector commonly used for Ethernet
networking. ... The "RJ" in RJ45 stands for
"registered jack," since it is a standardized
networking interface. The "45" simply refers to the
number of the interface standard. Each RJ45
connector has eight pins, which means
an RJ45 cable contains eight separate wires.
TOPOLOGY
A network topology is the pattern in which nodes (i.e., computers, printers, routers or
other devices) are connected to a local area network (LAN) or other network via links
(e.g., twisted pair copper wire cable or optical fiber cable). There are four
principal topologies used in LANs: bus, ring, star and mesh
STAR TOPOLOGY
Alternatively referred to as a star network, star topology is one of the most common network setups.
In this configuration, every node connects to a central network device, like a hub, switch, or
computer. The central network device acts as a server and the peripheral devices act as clients.
Advantages of star topology
Easy to add another computer to the network.
If one computer on the network fails, the rest of the network continues to function normally.
Disadvantages of star topology
May have a higher cost to implement, especially when using a switch or router as the central network
device.
If the central computer, hub, or switch fails, the entire network goes down and all computers are
disconnected from the network.
RING TOPOLOGY
A ring topology is a network configuration in which device connections create a circular data path.
Each networked device is connected to two others, like points on a circle. Together, devices in a
ring topology are referred to as a ring network.
Advantages of ring topology
All data flows in one direction, reducing the chance of packet collisions.
Data can transfer between workstations at high speeds.
Additional workstations can be added without impacting performance of the network.
Disadvantages of ring topology
All data being transferred over the network must pass through each workstation on the network,
which can make it slower than a star topology.
The entire network will be impacted if one workstation shuts down.
MESH TOPOLOGY
A network setup where each computer and network device is interconnected with one another,
allowing for most transmissions to be distributed even if one of the connections go down. It is a
topology commonly used for wireless networks.
Advantages of a mesh topology
Manages high amounts of traffic, because multiple devices can transmit data simultaneously.
A failure of one device does not cause a break in the network or transmission of data.
Adding additional devices does not disrupt data transmission between other devices.
Disadvantages of a mesh topology
The cost to implement is higher than other network topologies, making it a less desirable option.
Building and maintaining the topology is difficult and time consuming.
The chance of redundant connections is high, which adds to the high costs and potential for reduced
efficiency.
TREE TOPOLOGY
In computer networks, a tree topology is also known as a star bus topology. It incorporates elements
of both a bus topology and a star topology. Below is an example network diagram of a tree topology,
in which the central nodes of two star networks are connected to one another.
In the picture above, if the main cable or trunk between each of the two star topology networks were
to fail, those networks would be unable to communicate with each other. However, computers on the
same star topology would still be able to communicate.
OS
OS
ref
fro
on
to
OS
per
OS
Org
and
for
OS
sm
ass
Eac
to
Firewalls
Firewalls put up a barrier between your trusted internal network and untrusted
outside networks, such as the Internet. They use a set of defined rules to allow or
block traffic. A firewall can be hardware, software, or both. Cisco offers unified
threat management (UTM) devices and threat-focused next-generation firewalls.
Access control
Not every user should have access to your network. To keep out potential attackers,
you need to recognize each user and each device. Then you can enforce your
security policies. You can block noncompliant endpoint devices or give them only
limited access. This process is network access control (NAC).
The Internet Protocol is the principal communications protocol in the Internet protocol suite for relaying
datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes
the Internet
Classes of IP addresses
TCP/IP defines five classes of IP addresses: class A, B, C, D, and E. Each class has a range of valid IP addresses.
The value of the first octet determines the class. IP addresses from the first three classes (A, B and C) can be
used for host addresses. The other two classes are used for other purposes – class D for multicast and class E for
experimental purposes.
The system of IP address classes was developed for the purpose of Internet IP addresses assignment. The
classes created were based on the network size. For example, for the small number of networks with a very
large number of hosts, the Class A was created. The Class C was created for numerous networks with small
number of hosts.
12 Modem is used in data transmission. When was it invented and in which country?
A. 1963, USA
B. 1965, Germany
C. 1950, USA
D. 1950, Japan
13 Computers in a LAN can be interconnected by radio and infrared technologies.
A. Wireless LANs
B. Network Topologies
C. Multiplexer
D. Modem
14 How many digits of the Network User Address are known as the DNIC (Data Network Identification Code)?
A. first three
B. first four
C. first five
D. first seven
15. What is the benefit of the Networking?
A. File Sharing
B. Easier access to Resources
C. Easier Backups
D. All of the Above
16. Which of the following is not the Networking Devices?
A. Gateways
B. Linux
C. Routers
D. Firewalls
17. What is the size of MAC Address?
A. 16-bits
B. 32-bits
C. 48-bits
D. 64-bits
18. Which of the following can be Software?
A. Routers
B. Firewalls
C. Gateway
D. Modems
19. What is the use of Ping command?
A. To test a device on the network is reachable
B. To test a hard disk fault
C. To test a bug in a Application
D. To test a Pinter Quality
20. MAC Address is the example of
A. Transport Layer
B. Data Link Layer
C. Application Layer
D. Physical Layer
21. Routing tables of a router keeps track of
A. MAC Address Assignments
B. Port Assignments to network devices
C. Distribute IP address to network devices
D. Routes to use for forwarding data to its destination
22. Layer-2 Switch is also called
A. Multiport Hub
B. Multiport Switch
C. Multiport Bridge
D. Multiport NIC
23. Difference between T568A and T568B is
A. Difference in wire color
B. Difference in number of wires
C. Just different length of wires
D. Just different manufacturer standards
24. The meaning of Straight-through Cable is
A. Four wire pairs connect to the same pin on each end
B. The cable Which Directly connects Computer to Computer
C. Four wire pairs not twisted with each other
D. The cable which is not twisted
25. What is internet?
a) a single network
b) a vast collection of different networks
c) interconnection of local area networks
d) interconnection of wide area networks
26 To join the internet, the computer has to be connected to a _________
a) internet architecture board
b) internet society
c) internet service provider
d) different computer
27. Internet access by transmitting digital data over the wires of a local telephone network
is provided by _______
a) leased line
b) digital subscriber line
c) digital signal line
d) digital leased line
28 ISP exchanges internet traffic between their networks by __________
a) internet exchange point
b) subscriber end point
c) isp end point
d) internet end point
29. Which of the following protocols is used in the internet?
a) HTTP
b) DHCP
c) DNS
d) DNS, HTTP and DNS
30 Internet works on _______
a) packet switching
b) circuit switching
c) both packet switching and circuit switching
d) data switching
HOME WORK
1. WHAT IS THE NEED OF NETWORKING?
2. WRITE THE ADVANTAGE AND DISADVANTAGE OF NETWORKING?
3. DIFERENCE BETWEEN LAN AND WAN?
4. WRITE SHORT NOTE ON LAN , MAN, WAN ? GIVE TWO ADVANTAGE AND
DISADVANTAGE?
4. DISCUSS ABOUT VERIOUS NETWORK TOPOLOGY?
5. WRITE SHORT NOTE ON VPN,FIREWALL,URL?
6. WRITE SHORT NOTE ON BRIDGE , ROUTER, MODEM, NIC, OPTIC FIBRE CABLE , CO-
EXCEL CABLE?
7.WHAT YOU UNDERSTAND BY INTERNET? WRITE ADVANTAGE AND DISADVANTAGE?
8. HOW INTERNET WORK?
9. WHAT IS COMMUTATION SATELLITE? WRITE ADVANTAGE AND DISADVANTAGE?
10. STAR , RING ,MASH, TREE AND BUS TOPOLOGY WITH PROPER DIAGRAM ?
11. WHAT IS OSI MODEL? NAME THE LAYER OF IT?
12. WRITE SHORT NOTE ON NETWORK SECURITY , URL?
13. DEFINE IP? WHAT ARE THE CLASS OF IP?
UNIT V: INTRODUCTION TO DATABASE
A database management system (DBMS) is a software package designed to define,
manipulate, retrieve and manage data in a database. A DBMS generally manipulates the
data itself, the data format, field names, record structure and file structure. It also
defines rules to validate and manipulate this data
BESIC IDEA ABOUT SQL | DDL, DQL, DML, DCL and TCL Commands
Structured Query Language(SQL) as we all know is the database language by the use of
which we can perform certain operations on the existing database and also we can use
this language to create a database. SQL uses certain commands like Create, Drop, Insert
etc. to carry out the required tasks.
These SQL commands are mainly categorized into four categories as:
DDL – Data Definition Language
DQl – Data Query Language
DML – Data Manipulation Language
DCL – Data Control Language
Though many resources claim there to be another category of SQL clauses TCL –
Transaction Control Language. So we will see in detail about TCL as well.
DDL(Data Definition Language) : DDL or Data Definition Language actually consists of the SQL commands
that can be used to define the database schema. It simply deals with descriptions of the database
schema and is used to create and modify the structure of database objects in the database.
Examples of DDL commands:
CREATE – is used to create the database or its objects (like table, index, function, views, store procedure
and triggers).
DROP – is used to delete objects from the database.
ALTER-is used to alter the structure of the database.
TRUNCATE–is used to remove all records from a table, including all spaces allocated for the records are
removed.
COMMENT –is used to add comments to the data dictionary.
RENAME –is used to rename an object existing in the database.
DQL (Data Query Language) :
DML statements are used for performing queries on the data within schema objects. The purpose of DQL
Command is to get some schema relation based on the query passed to it.
Example of DQL:
SELECT – is used to retrieve data from the a database.
DML(Data Manipulation Language) : The SQL commands that deals with the manipulation of data
present in the database belong to DML or Data Manipulation Language and this includes most of the SQL
TCL(transaction Control Language) : TCL commands deals with the transaction within the
database.
Examples of TCL commands:
COMMIT– commits a Transaction.
ROLLBACK– rollbacks a transaction in case of any error occurs.
SAVEPOINT–sets a save point within a transaction.
SET TRANSACTION–specify characteristics for the transaction.
The ER model defines the conceptual view of a database. It works around real-world
entities and the associations among them. At view level, the ER model is considered a
good option for designing databases.
Entity
An entity can be a real-world object, either animate or inanimate, that can be easily
identifiable. For example, in a school database, students, teachers, classes, and
courses offered can be considered as entities. All these entities have some attributes
or properties that give them their identity.
An entity set is a collection of similar types of entities. An entity set may contain
SQL OVERVIEW
SQL is a programming language for Relational
Databases. It is designed over relational
algebra and tuple relational calculus. SQL
comes as a package with all major
distributions of RDBMS.
SQL comprises both data definition and data
manipulation languages. Using the data
definition properties of SQL, one can design
and modify database schema, whereas data
manipulation properties allows SQL to store
and retrieve data from database.
DROP
Drops commands, views, tables, and databases from RDBMS.
For example−
Drop object_type object_name;
Drop database SCHOOL;
Drop table article;
Drop view for_students;
Data Manipulation Language
SQL is equipped with data manipulation language (DML). DML modifies the database
instance by inserting, updating and deleting its data. DML is responsible for all forms
data modification in a database. SQL contains the following set of commands in its
DML section −
SELECT/FROM/WHERE
INSERT INTO/VALUES
UPDATE/SET/WHERE
DELETE FROM/WHERE
These basic constructs allow database programmers and users to enter data and
information into the database and retrieve efficiently using a number of filter options.
SELECT/FROM/WHERE
SELECT − This is one of the fundamental query command of SQL. It is similar to the
projection operation of relational algebra. It selects the attributes based on the
condition described by WHERE clause.
FROM − This clause takes a relation name as an argument from which attributes are to be
selected/projected. In case more than one relation names are given, this clause corresponds to
Cartesian product.
WHERE − This clause defines predicate or conditions, which must match in order to qualify the
attributes to be projected.
For example −
Select author_name
From book_author
Where age > 50;
This command will yield the names of authors from the relation book_author whose
age is greater than 50.
INSERT INTO/VALUES
MULTIPLE CHOICE QUESTIONS
1.What do you mean by one to many relationship between Teacher and Class table?
A. One class may have many teachers
B. One teacher can have many classes
C. Many classes may have many teachers
D. Many teachers may have many classes
2.What are the different view to present a Table ?
A. Datasheet View
B. Design View
C. Pivote TableView
D. All Of Above
3.In one-to-many relationship the table on 'many' side is called _______
A. Parent
B. Child
C. Sister
D. Master
4.In which state one gathers and list all the necessary fields for the database design project.
A. Data Definition
B. Data Refinement
C. Establishing Relationship
D. None Of The Above
5.Which of the following enables us to view data from a table based on a specific criterion
A. Form
B. Query
C. Macro
D. Report
6. Which database object is ideal to view, change, andanalyze datain different ways ?
A. Table
B. Form
C. Query
D. Report
7. In one-to-many relationship the table in 'one' side is called _______
A. Child
B. Owner
C. Parent
D. Owner
8. Which data type allows alphanumeric characters and special symbols to be entered?
A. Text
B. Memo
C. Auto number
D. Mixed
9. It is used to establish an association between related tables.
A. Line
B. Relationship
C. Primary Key
D. Records
10.This key that uniquely identifies each record is called :
A. Primary Key
B. Key Record
C. Unique Key
D. Field Name
11.. Which name must be unique within a database ?
A. Table
B. Field
C. Record
D. Character
12. The third stage of designing a database is when we create___________ between tables
A. Relationship
B. Join
C. Query
D. None of These
13. Two tables can be linked with relationship to _____
A. Ensure data entry
B. Ensure data integrity
C. Create Primary Key
D. Ensure Foreign Key
14. In a database Table, the each category of information Is called __________
A. Tuple
B. Field
C. Record
D. All Of Above
15.Which of the following fields has width of 8 bytes?
A. Memo
B. Number
C. Date/time
D. Hyperlink
16. which of the following is not a database object?
A. Tables
B. Queries
C. Relationships
D. Reports
17. Which of the following is not a database model
A. Network Database Model
B. Relational Database Model
C. Object Oriented Database Model
D. None
18. The overall description of a database is called______.
A. Data integrity
B. Data manipulation
C. Database schema
D. Data definition
19. A data dictionary is a repository that manages _____
A. Memory
B. Metadata
C. Spell Checker
D. Data Validator
20. A Database Management System (DBMS) is
A. Collection of interrelated data
B. Collection of programs to access data
C. Collection of data describing one particular enterprise
D. All of the above
21. Which of the following is not a level of data abstraction?
A. Physical Level
B. Critical Level
C. Logical Level
D. View Level
22. Disadvantages of File systems to store data is:
A. Data redundancy and inconsistency
B. Difficulty in accessing data
C. Data isolation
D. All of the above
23. In an Entity-Relationship Diagram Rectangles represents
A. Entity sets
B. Attributes
C. Database
D. Tables
24. Which of the following is not a Storage Manager Component?
A. Transaction Manager
B. Logical Manager
C. Buffer Manager
D. File Manager
25. Data Manipulation Language enables users to
A. Retrieval of information stored in database
B. Insertion of new information into the database
C. Deletion of information from the database
D. All of the above
26. Which of the following is not an Schema?
A. Database Schema
B. Physical Schema
C. Critical Schema
D. Logical Schema
27. Which of the following is Database Language?
A. Data Definition Language
B. Data Manipulation Language
C. Query Language
D. All of the above
28. Which of the following in not a function of DBA?
A. Network Maintenance
B. Routine Maintenance
C. Schema Definition
D. Authorization for data access
29. Which of the following is a Data Model?
A. Entity-Relationship model
B. Relational data model
C. Object-Based data model
D. All of the above
Homework :-
1. WHAT IS DATABASE? DEFINE DATABASE MANAGEMENT SYSTEM?
2. WRITE THE ADVANTAGE AND DISADVANTAGE OF DATABASE MANAGEMENT
SYSTEM?
3. DESCRIBE THE THREE LAYER ARCHITECTURE OF DBMS?
4. WRITE SHORT NOTE ON DDL , DML, DCL AND DQL?
5. DESCRIBE THE ONE TO ONE , AND ONE TO MANY RELATIONSHIP OF DATABASE?
6. DEFINE PRIMARY KEY ,SECENDARY KEY?
7. WHT IS SQL?
8. DESCRIBE THE FUNCTION OF CREATE ,ALTTER, DELETE,DROP,SELECT ,GRANT
AND REVOKE SQL COMMANDS?
UNIT VI MICROSOFT WORD
Microsoft Office Word 2010 allows you to create and edit personal and business
documents, such as letters, reports, invoices, emails and books. By default, documents
saved in Word 2010 are saved with the .docx extension. Microsoft Word can be used for
the following purposes −
To create business documents having various graphics including pictures, charts, and
diagrams.
To store and reuse readymade content and formatted elements such as cover pages
and sidebars.
To create letters and letterheads for personal and business purpose.
To design different documents such as resumes or invitation cards etc.
To create a range of correspondence from a simple office memo to legal copies and
reference documents.
In this chapter, we will discuss how to get started with Word 2010. We will
understand how to start a Word 2010 application in simple steps. Assuming you have
Microsoft Office 2010 installed in your PC, to start the Word application, follow
these steps −
Step 1 − Click the Start button.
Step 3 − Search for Microsoft Office from the submenu and click it.
Step 4 − Search for Microsoft Word 2010 from the submenu and click it.
This will launch the Microsoft Word 2010 application and you will see the following
window.
We will understand how to explore Window in Word 2010. Following is the basic
window which you get when you start the Word application. Let us understand the
various important parts of this window..
File Tab
The File tab replaces the Office button from Word 2007. You can click it to check
the Backstage view. This is where you come when you need to open or save files, create
new documents, print a document, and do other file-related operations.
Quick Access Toolbar
This you will find just above the File tab. This is a convenient resting place for the
mostfrequently used commands in Word. You can customize this toolbar based on your
comfort.
Ribbon
If you already have an opened document, then it will display a window showing detail
about the opened document as shown below. Backstage view shows three columns when
you select most of the available options in the first column.
The first column of the backstage view will have following options −
S.N Option & Description
o
Save
1 If an existing document is opened, it will be saved as is,
otherwise it will display a dialogue box asking for the document
name.
Save As
2 A dialogue box will be displayed asking for document name and
document type, by default it will save in word 2010 format with
extension .docx.
Open
3
This option is used to open an existing word document.
Close
4
This option is used to close an open document.
Info
5
This option displays information about the opened document.
Recent
6
This option lists down all the recently opened documents
7 New
This option is used to open a new document.
Print
8
This option is used to print an open document.
Help
10
This option is used to get the required help about Word 2010.
Options
11
This option is used to set various option related to Word 2010.
Exit
12
Use this option to close the document and exit.
Document Information
When you click the Info option available in the first column, it displays the following
information in the second column of the backstage view −
Compatibility Mode − If the document is not a native Word 2007/2010 document,
a Convert button appears here, enabling you to easily update its format. Otherwise,
this category does not appear.
Permissions − You can use this option to protect your word document. You can set a
password so that nobody can open your document, or you can lock the document so
that nobody can edit your document.
Prepare for Sharing − This section highlights important information you should
know about your document before you send it to others, such as a record of the edits
you made as you developed the document.
Versions − If the document has been saved several times, you may be able to access
the previous versions of it from this section.
Document Properties
When you click the Info option available in the first column, it displays various properties
in the third column of the backstage view. These properties include the document size, the
number of pages in the document, the total number of words in the document, the name of
the author etc.
You can also edit various properties by clicking on the property value and if the property
is editable, then it will display a text box where you can add your text like title, tags,
comments, Author.
Exit Backstage View
It is simple to exit from the Backstage View. Either click on the File tab or press the Esc
button on the keyboard to go back to the working mode of Word.
let us discuss how to enter text with Microsoft Word 2010. Let us see how easy it is
to enter text in a Word document. We assume you know that when you start Word, it
displays a new document by default as shown below −
Document area is the area where you type your text. The flashing vertical bar is called the
insertion point and it represents the location where the text will appear when you type.
keep the cursor at the text insertion point and start typing the text. We typed only two
words "Hello Word" as shown below. The text appears to the left of the insertion point as
you type −
The following are the two important points that will help you while typing −
You do not need to press Enter to start a new line. As the insertion point reaches the
end of the line, Word automatically starts a new one. You will need to press Enter, to
add a new paragraph.
When you want to add more than one space between words, use the Tab key instead
of the spacebar. This way you can properly align text by using the proportional fonts.
Saving New Document
Once you are done with typing in your new Word document, it is time to save your
document to avoid losing work you have done on a Word document. Following are the
steps to save an edited Word document −
Step 1 − Click the File tab and select the Save As option.
Step 2 − Select a folder where you will like to save the document, Enter the file name
which you want to give to your document and Select the Save As option, by default it is
the .docx format.
Step 3 − Finally, click on the Save button and your document will be saved with the
entered name in the selected folder.
Saving New Changes
There may be an instance when you open an existing document and edit it partially or
completely, or an instance where you may like to save the changes in between editing of
the document. If you want to save this document with the same name, then you can use
either of the following simple options −
Just press the Ctrl + S keys to save the changes.
Optionally you can click on the floppy icon available at the top left corner and just
above the File tab. This option will also help you save the changes.
You can also use the third method to save the changes, which is the Save option
available just above the Save As option as shown in the above screenshot.
If your document is new and it was never saved so far, then with either of the three
options, Word will display a dialogue box to let you select a folder, and enter the
document name as explained in case of saving new document.
You can use a shortcut to open a blank document anytime. Try using the Ctrl + N keys
and you will see a new blank document similar to the one in the above screenshot.
Opening Existing Document
There may be a situation when you open an existing document and edit it partially or
completely. Follow the steps given below to open an existing document −
Step 1 − Click the File tab and select the Open option.
Step 2 − This will display the following file Open dialog box. This lets you navigate
through different folders and files, and also lets you select a file which you want to open.
Step 3 − Finally, locate and select a file which you want to open and click the small
triangle available on the Open button to open the file. You will have different options to
open the file, but simply use the Open option.
This will open your selected file. You can use the Open Read-Only option if you are
willing just to read the file and you have no intention to modify, i.e., edit the file. Other
options can be used for advanced usage.
we will understand how to close a document in Word 2010. When you finish working
with a document, you will proceed to close the document. Closing a document removes it
from your computer screen and if you had other documents open, Word displays the last
document you used otherwise, you see a blank Word window. Here are simple steps to
close an opened document −
Step 1 − Click the File tab and select the Close option.
Step 2 − When you select the Close option and if the document is not saved before
closing, it will display the following Warning box asking whether the document should be
saved or not.
Step 3 − To save the changes, click Save, otherwise click Don't Save. To go back to the
document, click Cancel. This will close the document and if you have other documents
open, Word displays the last document you used, otherwise, you see a blank Word
window as shown below −
we will discuss how to copy, cut and paste in Word 2010. In the previous chapter, we
understood how we can select the desired text and move it to any other location in the
same document or in any other document. This tutorial will teach you how to use copy,
cut and paste techniques to duplicate a text leaving the original text intact or removing the
original text completely.
To use copy and paste or cut and paste operations, Word makes use of a temporary
memory which is called the clipboard. When you copy or cut a text, it stay on the
clipboard temporarily and in the second step you can paste this content at the desired
location.
Copy & Paste Operation
The Copy operation will just copy the content from its original place and create a
duplicate copy of the content at the desired location without deleting the text from it's the
original location. Following is the procedure to copy the content in word −
Step 1 − Select a portion of the text using any of the text selection methods.
Step 2 − You have various options available to copy the selected text in clipboard. You
can make use of any one of the options −
Using Right-Click − When you right-click on the selected text, it will display
the copy option, click this option to copy the selected content in clipboard.
Using Ribbon Copy Button − After selecting text, you can use the copy button
available at the ribbon to copy the selected content in clipboard.
Using Ctrl + c Keys − After selecting a text, just press Ctrl + c keys to copy the
selected content in clipboard.
Step 3 − Finally click at the place where you want to copy the selected text and use either
of these two simple options −
Using Ribbon Paste Button − Just click the Paste button available at the ribbon to
paste the copied content at the desired location.
Using Ctrl + v Keys − This is simplest way of pasting the content. Just press Ctrl +
v keys to paste the content at the new location.
Note − You can repeat the Paste operation as many times as you like to paste the same
content.
Cut & Paste Operation
The Cut operation will cut the content from its original place and move the content from
its original location to a new desired location. Following is the procedure to move the
content in word −
Step 1 − Select a portion of the text using any of the text selection methods.
Step 2 − Now, you have various options available to cut the selected text and put it in the
clipboard. You can make use of one of the options −
Using Right-Click − If right-click on the selected portion of text, it will
display cut option, just click this option to cut the selected content and keep it in
clipboard.
Using Ribbon Cut Button − After selecting a portion of text, you can use cut button
available at the ribbon to cut the selected content and keep it in clipboard.
Using Ctrl + x Keys − After selecting a portion of text, just press Ctrl + x keys to
cut the selected content and keep it in clipboard.
Step 3 − Finally, click at the place where you want to move the selected text and use
either of these two simple options −
Using Ribbon Paste Button − Just click the Paste button available at the ribbon to
paste the content at the new location.
Using Ctrl + v Keys − This is simplest way of pasting the content. Just press Ctrl +
v keys to paste the content at the new location.
Note − You can repeat the Paste operation as many times as you like to paste the same
content.
Copy, Cut & Paste in different documents
You can use the same procedure that we discussed above to copy and paste or cut and
paste content from one document to another document. This is very simple, just copy or
cut the desired content from one document and go into another document where you want
to paste the content and use mentioned step to paste the content.
You can use the Alt + Tab keys to switch through the different documents and select the
desired destination document.
we will discuss the Find and Replace operation in Word 2010. While working on editing a
document you come across a situation very frequently when you want to search a
particular word in your document and many times you will be willing to replace this word
with another word at a few or all the places throughout the document. Here, we will
understand how to find a word or phrase in a word document and how to replace an
existing word with any other word using simple steps.
Find Command
The Find command enables you to locate specific text in your document. Following are
the steps to find a word document in the following screen −
Step 1 − Let us work out on a sample text available in our Word document. Just type
=rand() and press Enter; the following screen will appear −
Step 2 − Click the Find option in the Editing group on the Home tab or press Ctrl +
F to launch the Navigation pane −
Step 3 − Enter a word which you want to search in the Search box, as soon as you finish
typing, Word searches for the text you entered and displays the results in the navigation
pane and highlights the word in the document as in the following screenshot −
Step 4 − You can click the clear button (X) to clear the search and results and perform
another search.
Step 5 − You can use further options while searching for a word. Click the option
button to display the options menu and then click the Options option; this will display a
list of options. You can select the options like match case to perform case-sensitive
search.
Step 6 − Finally, if you are done with the Search operation, you can click the close
button (X) to close the Navigation Pane.
Find & Replace Operation
We assume you are an expert in searching a word or phrase in a word document as
explained above. This section will teach you how you can replace an existing word in
your document. Following are the simple steps −
Step 1 − Click the Replace option in the Editing group on the Home tab or press Ctrl +
H to launch the Find and Replace dialog box shown in Step 2 −
Step 2 − Type a word which you want to search. You can also replace the word using
the Find and Replace dialog box as in the following screenshot −
Step 3 − Click the Replace button available on the Find and Replace dialog box and you
will see the first occurrence of the searched word would be replaced with the replace with
word. Clicking again on Replace button would replace next occurrence of the searched
word. If you will click Replace All button then it would replace all the found words in
one go. You can also use Find Next button just to search the next occurence and later you
can use Replace button to replace the found word.
Step 4 − You can use More >> button available on the dialog box to use more options
and to make your search more specific like case sensitive search or searching for whole
word only etc.
Step 5 − Finally, if you are done with the Find and Replace operation, you can click
the Close (X) or Cancel button of the dialog box to close the box.
we will discuss how to check spelling and grammar in Word 2010. Microsoft Word
provides a decent Spelling and Grammar Checker which enables you to search for and
correct all spelling and grammar mistakes in your document. Word is intelligent enough
to identify misspelled or misused, as well as grammar errors and underlines them as
follows.
A red underline beneath spelling errors.
A green underline beneath grammar errors.
A blue line under correctly spelled but misused words.
Check Spelling and Grammar using Review tab
Here is the simple procedure to find out the spelling mistakes and fix them −
Step 1 − Click the Review tab and then click the Spelling & Grammar button.
Step 2 − A Spelling and Grammar dialog box will appear and will display the wrong
spellings or errors in grammar. You will also get suggestions to correct as shown below −
Step 1 − Select the portion of text the font of which needs to be changed and click
the Home tab. Now click the Font Type button to list down all the fonts available as
shown below.
©SAYANTAN BERA
Step 2 − Try to move the mouse pointer over the listed fonts. You will see that the text
font changes when you move the mouse pointer over different fonts. You can use
the Font Scroll Bar to display more fonts available. Finally select a desired font by
clicking over the font name in the list. We have selected MV Boli as the font for our
sample text.
Step 3 − Similar way, to change the font size, click over the Font Size button which will
display a font size list. You will use the same procedure to select a desired font size that
you have used while selecting a font type.
Use Shrink and Grow Buttons
You can use a quick way to reduce or enlarge the font size. As shown in the first
screenshot, the Shrink Font button can be used to reduce the font size whereas the Grow
Font button can be used to enlarge the font size.
Try to click either of these two buttons and you will see the effect. You can click a single
button multiple times to apply the effect. Each time you click either of the buttons, it will
enlarge or reduce the font size by 1 point.
Clear Formatting Options
All of the setting can be reset to plain text, or the default formatting. To reset text to
default settings −
Step 1 − Select the portion of text that you want to reset.
Step 2 − Click the Clear Formatting button in the Home tab Font group, or simply
use Ctrl + SPACEBAR.
we will discuss how to adjust page margins in Word 2010. Margins are the space between
the edge of the paper and the text. You can adjust the right, left, top, and bottom margins
of your document. By default, Word sets all margins left, right, top, and bottom to 1 inch.
In the screenshot given below, I have shown top, left and right margins, if you will type
the complete page, word will leave 1-inch bottom margin as well.
Adjust Margins
The following steps will help you understand how to set margins for an open document.
Step 1 − Open the document the margins of which need to be set. If you want the margins
to be applied only to a selected part of a document, select that particular part.
Step 2 − Click the Page Layout tab, and click the Margins button in the Page Setup
group. This will display a list of options to be selected but you have to click the Custom
Margins option available at the bottom.
You can also select any of the predefined margins from the list, but using custom margins
option you will have more control on all the settings.
Step 3 − You will have to display a Page Dialog Box as shown below where you can set
top, left, right and bottom margins under the Margins Tab. Select the Apply to: option to
apply the margin on selected text or complete document.
Step 4 − If you are going to bind the document and want to add an extra amount of space
on one edge for the binding, enter that amount in the Gutter text box, and select the side
the gutter is on with the Gutter Position drop-down list. After setting all the desired
values for all the margins, click the OK button to apply the margins.
we will discuss how to add header and footer in Word 2010. Headers and footers are parts
of a document that contain special information such as page numbers and the total number
of pages, the document title, company logo, any photo, etc. The header appears at the top
of every page, and the footer appears at the bottom of every page.
Add Header and Footer
The following steps will help you understand how to add header and footer in a Word
document.
Step 1 − Click the Insert tab, and click either the Header button or the Footer
button that which needs to be added first. Assume you are going to add Header; when
you click the Header button it will display a list of built-in Headers from where you can
choose any of the headers by simply clicking on it.
Step 2 − Once you select any of the headers, it will be applied to the document in editable
mode and the text in your document will appear dimmed, Header and Footer
buttons appear on the Ribbon and a Close Header and Footer button will also appear at
the top-right corner.
Step 3 − Finally, you can type your information whatever you want to have in your
document header and once you are done, click Close Header and Footer to come out of
the header insertion mode. You will see the final result as follows.
Step 2 − Click on the Edit Header option and Word will display the editable header as
shown in the following screenshot.
Step 3 − Now you can edit your document header and once you are done, click Close
Header and Footer to come out of the edit header mode.
we will discuss how to add page numbers in Word 2010. Microsoft Word automatically
assigns page numbers on the pages of your document. Typically, page numbers are
printed either in header or footer but you have the option that can display the page number
in the left or right margins at the top or the bottom of a page.
Add Page Numbers
Following are the simple steps to add page numbers in a Word document.
Step 1 − Click the Insert tab, and click the Page Number button available in the header
and footer section. This will display a list of options to display the page number at the top,
bottom, current position etc.
Step 2 − When you move your mouse pointer over the available options, it displays
further styles of page numbers to be displayed. For example, when I take the mouse
pointer at the Bottom of Page option it displays the following list of styles.
Step 3 − Finally, select any one of the page number styles. I selected the Accent Bar
1 style by clicking over it. You will be directed to the Page Footer modification mode.
Click the Close Header and Footer button to come out of the Footer Edit mode.
You can format your page numbers using the Format Page Numbers option available
under the listed options.
Remove Page Numbers
The following steps will help you remove page numbering from a Word document.
Step 1 − Click the Insert tab, and click the Page Number button available in the header
and footer section. This will display a list of options to display page number at the top,
bottom, current position, etc. At the bottom, you will have the Remove Page
Numbers option. Just click this option and it will delete all the page numbers set in your
document.
we will discuss Almost all the good documents and books have an attractive first page
that includes the document title, its subject, author and publisher name etc. This first page
is is the Cover Page and Microsoft Word provides an easy way to add a cover page.
Add Cover Pages
Following are the simple steps to add a cover page in a Word document.
Step 1 − Click the Insert tab, and click the Cover Page button available in the Pages
group. This will display a list of Built-in Cover Pages as shown below.
Step 2 − Choose a cover page from the options available in the gallery. The selected
cover page will be added as the first page of your document which can later be modified
according to the requirements. If you want to place the cover page elsewhere except the
first page, right-click the cover page in the gallery and select the location you want from
the menu that appears.
Delete Cover Pages
The following steps will help you understand how to delete an existing cover page from a
Word document.
Step 1 − Click the Insert tab, and click the Cover Page button available in the Pages
group. This will display a list of Built-in Cover Pages as shown below. You will find
a Remove Current Cover Page option available at the bottom of the cover page gallery.
Step 2 − Click the Remove Current Cover Page option and your cover page will be
deleted from your document.
we will discuss how to create a table in Word 2010. A table is a structure of vertical
columns and horizontal rows with a cell at every intersection. Each cell can contain text
or graphics, and you can format the table in any way you want. Usually the top row in the
table is kept as a table header and can be used to put some informative instruction.
Create a Table
The following steps will help you understand how to create a table in a Word document.
Step 1 − Click the Insert tab followed by the Table button. This will display a simple
grid as shown below. When you move your mouse over the grid cells, it makes a table in
the table that appears in the document. You can make your table having the desired
number of rows and columns.
Step 2 − Click the square representing the lower-right corner of your table, which will
create an actual table in your document and Word goes in the table design mode. The
table design mode has many options to work with as shown below.
Step 3 − This is an optional step that can be worked out if you want to have a fancy table.
Click the Table Styles button to display a gallery of table styles. When you move your
mouse over any of the styles, it shows real time preview of your actual table.
Step 4 − To select any of the styles, just click the built-in table style and you will see that
the selected style has been applied on your table.
Delete a Table
Following are the simple steps to delete an existing table from a word document.
Step 1 − Click anywhere in the table you want to delete.
Step 2 − Click the Layout tab, and click the Delete Table option under the Delete Table
Button to delete the complete table from the document along with its content.
we will discuss how to work with rows and columns in Word 2010. As discussed in the
previous chapter, a table is a structure of vertical columns and horizontal rows with a cell
at every intersection. A Word table can contain as many as 63 columns but the number of
rows is unlimited. This chapter will teach you how to add and delete rows and columns in
a table.
Add a Row
Following are the simple steps to add rows in a table of a word document.
Step 1 − Click a row where you want to add an additional row and then click the Layout
tab; it will show the following screen.
Step 2 − Now use the Row & Column group of buttons to add any row below or above
to the selected row. If you click the Insert Below button, it will add a row just below the
selected row as follows.
If you click the Insert Above button, it will add a row just above the selected row.
Delete a Row
The following steps will help you delete rows from a table of a Word document.
Step 1 − Click a row which you want to delete from the table and then click the Layout
tab; it will show the following screen.
Step 2 − Click the Layout tab, and then click the Delete Rows option under the Delete
Table Button to delete the selected row.
Add a Column
The following steps will help you add columns in a table of a Word document.
Step 1 − Click a column where you want to add an additional column and then click
the Layout tab; it will show the following screen.
Step 2 − Now use the Row & Column group of buttons to add any column to the left or
right of the selected column. If you click the Insert Left button, it will add a column just
left to the selected column as follows.
If you click the Insert Right button, it will add a column just next to the selected column.
Delete a Column
Following are the simple steps to delete columns from a table of a word document.
Step 1 − Click a column which you want to delete from the table and then click
the Layout tab; it will show the following screen.
Step 2 − Click the Layout tab, and click the Delete Column option under the Delete
Table Button to delete the selected column.
We will discuss how to add formula to a table in Word 2010. Microsoft Word allows you
to use mathematical formula in table cells which can be used to add numbers, to find the
average of numbers, or find the largest or the smallest number in table cells you specify.
There is a list of formulae, you can choose from the many based on the requirement. This
chapter will teach you how to use formula in word tables.
Add a Formula
Following are the simple steps to add formula in a table cell available in Word document.
Step 1 − Consider the following table with the total number of rows. Click in a cell that
should contain the sum of the rows.
Step 2 − Now click the Layout tab and then click the Formula button; this will
display a Formula Dialog Box which will suggest a default formula, which is
=SUM(LEFT) in our case. You can select a number format using Number Format List
Box to display the result or you can change the formula using the Formula List Box.
Step 3 − Now click OK to apply the formula and you will see that the left cells have been
added and the sum has been put in the total cell where we wanted to have it. You can
repeat the procedure to have the sum of other two rows as well.
Cell Formulae
The Formula dialog box provides the following important functions to be used as formula
in a cell.
S.N Formula & Description
o
1 AVERAGE( )
The average of a list of cells
2 COUNT( )
The number of items in a list of cells
3 MAX( )
The largest value in a list of cells
4 MIN( )
The smallest value in a list of cells
5 PRODUCT( )
The multiplication of a list of cells
6 SUM( )
The sum of a list of cells
We assume you are familiar with how to create a spreadsheet program; you can construct
your word cell formula. Word formulae uses a reference system to refer to an individual
table cells. Each column is identified by a letter, starting with A for the first column, B for
the second column, and so on. After the letter comes the row number. Thus, the first cell
in the first row is A1, the third cell in the fourth row is C4, and so on.
Following are useful points to help you in constructing a word cell formula.
S.N Cell References and Description
o
LEFT, referring to all cells in the row to the left of the current
6
cell
RIGHT, referring to all cells in the row to the right of the current
7
cell
You can also construct simple Math expressions, such as B3+B5*10 by using simple
mathematical operators +, -, /, *, %.
UNIT VII: GETTING STARTED WITH EXCEL 2010
This chapter teaches you how to start an excel 2010 application in simple steps. Assuming
you have Microsoft Office 2010 installed in your PC, start the excel application following
the below mentioned steps in your PC.
Step 1 − Click on the Start button.
Step 3 − Search for Microsoft Office from the sub menu and click it.
Step 4 − Search for Microsoft Excel 2010 from the submenu and click it.
This will launch the Microsoft Excel 2010 application and you will see the following
excel window.
If you already have an opened sheet then it will display a window showing the details
about the opened sheet as shown below. Backstage view shows three columns when you
select most of the available options in the first column.
First column of the backstage view will have the following options −
S.No Option & Description
.
1 Save
If an existing sheet is opened, it would be saved as is, otherwise
it will display a dialogue box asking for the sheet name.
2 Save As
A dialogue box will be displayed asking for sheet name and
sheet type. By default, it will save in sheet 2010 format with
extension .xlsx.
3 Open
This option is used to open an existing excel sheet.
4 Close
This option is used to close an opened sheet.
5 Info
This option displays the information about the opened sheet.
6 Recent
This option lists down all the recently opened sheets.
7 New
This option is used to open a new sheet.
8 Print
This option is used to print an opened sheet.
10 Help
You can use this option to get the required help about excel
2010.
11 Options
Use this option to set various option related to excel 2010.
12 Exit
Use this option to close the sheet and exit.
Sheet Information
When you click Info option available in the first column, it displays the following
information in the second column of the backstage view −
Compatibility Mode − If the sheet is not a native excel 2007/2010 sheet, a Convert
button appears here, enabling you to easily update its format. Otherwise, this
category does not appear.
Permissions − You can use this option to protect the excel sheet. You can set a
password so that nobody can open your sheet, or you can lock the sheet so that
nobody can edit your sheet.
Prepare for Sharing − This section highlights important information you should
know about your sheet before you send it to others, such as a record of the edits you
made as you developed the sheet.
Versions − If the sheet has been saved several times, you may be able to access
previous versions of it from this section.
Sheet Properties
When you click Info option available in the first column, it displays various properties in
the third column of the backstage view. These properties include sheet size, title, tags,
categories etc.
You can also edit various properties. Just try to click on the property value and if property
is editable, then it will display a text box where you can add your text like title, tags,
comments, Author.
Exit Backstage View
It is simple to exit from the Backstage View. Either click on the File tab or press the Esc
button on the keyboard to go back to excel working mode.
Entering Values in Excel 2010
Entering values in excel sheet is a child’s play and this chapter shows how to enter values
in an excel sheet. A new sheet is displayed by default when you open an excel sheet as
shown in the below screen shot.
Sheet area is the place where you type your text. The flashing vertical bar is called the
insertion point and it represents the location where text will appear when you type. When
you click on a box then the box is highlighted. When you double click the box, the
flashing vertical bar appears and you can start entering your data.
So, just keep your mouse cursor at the text insertion point and start typing whatever text
you would like to type. We have typed only two words "Hello Excel" as shown below.
The text appears to the left of the insertion point as you type.
There are following three important points, which would help you while typing −
Press Tab to go to next column.
Press Enter to go to next row.
You can scroll your sheet by rolling your mouse wheel, which is equivalent to clicking
the up-arrow or down-arrow buttons in the scroll bar.
Up one box
You can move box by box or sheet by sheet. Now click in any box containing data in the
sheet. You would have to hold down the Ctrl key while pressing an arrow key, which
moves the insertion point as described here −
Key Where the Insertion Point Moves
Combination
Step 2 − Select a folder where you would like to save the sheet, Enter file name, which
you want to give to your sheet and Select a Save as type, by default it is .xlsx format.
Step 3 − Finally, click on Save button and your sheet will be saved with the entered name
in the selected folder.
Saving New Changes
There may be a situation when you open an existing sheet and edit it partially or
completely, or even you would like to save the changes in between editing of the sheet. If
you want to save this sheet with the same name, then you can use either of the following
simple options −
Just press Ctrl + S keys to save the changes.
Optionally, you can click on the floppy icon available at the top left corner and just
above the File tab. This option will also save the changes.
You can also use third method to save the changes, which is the Save option
available just above the Save As option as shown in the above screen capture.
If your sheet is new and it was never saved so far, then with either of the three options,
word would display you a dialogue box to let you select a folder, and enter sheet name as
explained in case of saving new sheet.
Create Worksheet in Excel 2010
Creating New Worksheet
Three new blank sheets always open when you start Microsoft Excel. Below steps explain
you how to create a new worksheet if you want to start another new worksheet while you
are working on a worksheet, or you closed an already opened worksheet and want to start
a new worksheet.
Step 1 − Right Click the Sheet Name and select Insert option.
Step 2 − Now you'll see the Insert dialog with select Worksheet option as selected from
the general tab. Click the Ok button.
Now you should have your blank sheet as shown below ready to start typing your text.
You can use a short cut to create a blank sheet anytime. Try using the Shift+F11 keys and
you will see a new blank sheet similar to the above sheet is opened.
Copy Worksheet in Excel 2010
Copy Worksheet
First of all, let us create some sample text before we proceed. Open a new excel sheet and
type any data. We've shown a sample data in the screenshot.
OrderDate Region Rep Item Units Unit Cost Total
Step 2 − Now you'll see the Move or Copy dialog with select Worksheet option as
selected from the general tab. Click the Ok button.
Select Create a Copy Checkbox to create a copy of the current sheet and Before sheet
option as (move to end) so that new sheet gets created at the end.
Press the Ok Button.
Now you should have your copied sheet as shown below.
You can rename the sheet by double clicking on it. On double click, the sheet name
becomes editable. Enter any name say Sheet5 and press Tab or Enter Key.
Hiding Worksheet in Excel 2010
Hiding Worksheet
Here is the step to hide a worksheet.
Step − Right Click the Sheet Name and select the Hide option. Sheet will get hidden.
Unhiding Worksheet
Here are the steps to unhide a worksheet.
Step 1 − Right Click on any Sheet Name and select the Unhide... option.
Step 2 − Select Sheet Name to unhide in Unhide dialog to unhide the sheet.
Press the Ok Button.
Now you will have your hidden sheet back.
Delete Worksheet in Excel 2010
Delete Worksheet
Here is the step to delete a worksheet.
Step − Right Click the Sheet Name and select the Delete option.
Sheet will get deleted if it is empty, otherwise you'll see a confirmation message.
Press the Delete Button.
Now your worksheet will get deleted.
Close Workbook in Excel 2010
Close Workbook
Here are the steps to close a workbook.
Step 1 − Click the Close Button as shown below.
Step 2 − Clicking the Open Option will open the browse dialog as shown below. Browse
the directory and find the file you need to open.
Step 3 − Once you select the workbook your workbook will be opened as below −
Context Help in Excel 2010
MS Excel provides context sensitive help on mouse over. To see context sensitive help for
a particular Menu option, hover the mouse over the option for some time. Then you can
see the context sensitive Help as shown below.
Inserting Formula
For inserting formula in MS Excel go to the formula bar, enter the formula and then press
enter or navigation key. See the screen-shot below to understand it.
Modifying Cell Content
For modifying the cell content just activate the cell, enter a new value and then press enter
or navigation key to see the changes. See the screen-shot below to understand it.
Click on Special button to see the below dialogue box. Select current region from the
radio buttons. Click on ok to see the current region selected.
As you can see in the below screen, the data is selected for the current region.
Cell Introduction
The intersection of rows and columns is called cell.
Cell is identified with Combination of column header and row number.
For example − A1, A2.
Copy & Paste in Excel 2010
MS Excel provides copy paste option in different ways. The simplest method of copy
paste is as below.
Copy Paste
To copy and paste, just select the cells you want to copy. Choose copy option after
right click or press Control + C.
Select the cell where you need to paste this copied content. Right click and select
paste option or press Control + V.
In this case, MS Excel will copy everything such as values, formulas, Formats,
Comments and validation. MS Excel will overwrite the content with paste. If you want to
undo this, press Control + Z from the keyboard.
Copy Paste using Office Clipboard
When you copy data in MS Excel, it puts the copied content in Windows and Office
Clipboard. You can view the clipboard content by Home → Clipboard. View the
clipboard content. Select the cell where you need to paste. Click on paste, to paste the
content.
Copy Paste in Special way
You may not want to copy everything in some cases. For example, you want to copy only
Values or you want to copy only the formatting of cells. Select the paste special option as
shown below.
You can replace the found text with the new text in the Replace tab.
Exploring Options
Now, let us see the various options available under the Find dialogue.
Within − Specifying the search should be in Sheet or workbook.
Search By − Specifying the internal search method by rows or by columns.
Look In − If you want to find text in formula as well, then select this option.
Match Case − If you want to match the case like lower case or upper case of words,
then check this option.
Match Entire Cell Content − If you want the exact match of the word with cell,
then check this option.
Zoom Out
You can zoom out the workbook by moving the slider to the left. It will change the only
view of the workbook. You can have maximum of 10% zoom in. See the below screen-
shot.
Special Symbols in Excel 2010
If you want to insert some symbols or special characters that are not found on the
keyboard in that case you need to use the Symbols option.
Using Symbols
Go to Insert » Symbols » Symbol to view available symbols. You can see many symbols
available there like Pi, alpha, beta, etc.
Select the symbol you want to add and click insert to use the symbol.
Press Shift+F2.
Initially, a comment consists of Computer's user name. You have to modify it with text
for the cell comment.
Modifying Comment
You can modify the comment you have entered before as mentioned below.
Select the cell on which the comment appears.
Right-click the cell and choose the Edit Comment from the available options.
Modify the comment.
Formatting Comment
Various formatting options are available for comments. For formatting a comment, Right
click on cell » Edit comment » Select comment » Right click on it » Format comment.
With formatting of comment you can change the color, font, size, etc of the comment.
Add Text Box in Excel 2010
Text Boxes
Text boxes are special graphic objects that combine the text with a rectangular graphic
object. Text boxes and cell comments are similar in displaying the text in rectangular box.
But text boxes are always visible, while cell comments become visible after selecting the
cell.
Adding Text Boxes
To add a text box, perform the below actions.
Choose Insert » Text Box » choose text box or draw it.
Initially, the comment consists of Computer's user name. You have to modify it with text
for the cell comment.
Formatting Text Box
After you have added the text box, you can format it by changing the font, font size, font
style, and alignment, etc. Let us see some of the important options of formatting a text
box.
Fill − Specifies the filling of text box like No fill, solid fill. Also specifying the
transparency of text box fill.
Line Colour − Specifies the line colour and transparency of the line.
Line Style − Specifies the line style and width.
Size − Specifies the size of the text box.
Properties − Specifies some properties of the text box.
Text Box − Specifies text box layout, Auto-fit option and internal margins.
You can reverse the effects of the past 100 actions that you performed by executing Undo
more than once. If you click the arrow on the right side of the Undo button, you see a list
of the actions that you can reverse. Click an item in that list to undo that action and all the
subsequent actions you performed.
Redo Changes
You can again reverse back the action done with undo in Excel by using the Redo
command. We can redo changes in following two ways.
From the Quick access tool-bar » Click Redo.
Press Control + Y.
Also you can change the foreground color by selecting the cell Right click » Format
cells » Font Tab » Color.
Text Alignments in Excel 2010
If you don’t like the default alignment of the cell, you can make changes in the alignment
of the cell. Below are the various ways of doing it.
Change Alignment from Home Tab
You can change the Horizontal and vertical alignment of the cell. By default, Excel aligns
numbers to the right and text to the left. Click on the available option in the Alignment
group in Home tab to change alignment.
Additional Options
The Home » Alignment group » Merge & Center control contains a drop-down list
with these additional options −
Merge Across − When a multi-row range is selected, this command creates multiple
merged cells — one for each row.
Merge Cells − Merges the selected cells without applying the Center attribute.
Unmerge Cells − Unmerges the selected cells.
Wrap Text and Shrink to Fit
If the text is too wide to fit the column width but don’t want that text to spill over into
adjacent cells, you can use either the Wrap Text option or the Shrink to Fit option to
accommodate that text.
Borders and Shades in Excel 2010
Apply Borders
MS Excel enables you to apply borders to the cells. For applying border, select the range
of cells Right Click » Format cells » Border Tab » Select the Border Style.
Then you can apply border by Home Tab » Font group »Apply Borders.
Apply Shading
You can add shading to the cell from the Home tab » Font Group » Select the Color.
o Black & White − Select this check box to have your color printer print the chart
draft-quality setting.
o Rows & Column Heading − Select this check box to have rows and column
heading to print.
Page Order −
o Down, then Over − It prints the down pages first and then the right pages.
o Over, then Down − It prints right pages first and then comes to print the down
pages.
Adjust Margins in Excel 2010
Margins
Margins are the unprinted areas along the sides, top, and bottom of a printed page. All
printed pages in MS Excel have the same margins. You can’t specify different margins for
different pages.
You can set margins by various ways as explained below.
Choose Page Layout » Page Setup » Margins drop-down list, you can select Normal,
Wide, Narrow, or the custom Setting.
These options are also available when you choose File » Print.
If none of these settings does the job, choose Custom Margins to display the Margins tab
of the Page Setup dialog box, as shown below.
Center on Page
By default, Excel aligns the printed page at the top and left margins. If you want the
output to be centered vertically or horizontally, select the appropriate check box in the
Center on Page section of the Margins tab as shown in the above screenshot.
Page Orientation in Excel 2010
Page Orientation
Page orientation refers to how output is printed on the page. If you change the orientation,
the onscreen page breaks adjust automatically to accommodate the new paper orientation.
Types of Page Orientation
Portrait − Portrait to print tall pages (the default).
Landscape − Landscape to print wide pages. Landscape orientation is useful when
you have a wide range that doesn’t fit on a vertically oriented page.
Changing Page Orientation
Choose Page Layout » Page Setup » Orientation » Portrait or Landscape.
You can choose the predefined header and footer or create your custom ones.
&[Page] − Displays the page number.
&[Pages] − Displays the total number of pages to be printed.
&[Date] − Displays the current date.
&[Time] − Displays the current time.
&[Path]&[File] − Displays the workbook’s complete path and filename.
&[File] − Displays the workbook name.
&[Tab] − Displays the sheet’s name.
Other Header and Footer Options
When a header or footer is selected in Page Layout view, the Header & Footer » Design
» Options group contains controls that let you specify other options −
Different First Page − Check this to specify a different header or footer for the first
printed page.
Different Odd & Even Pages − Check this to specify a different header or footer for
odd and even pages.
Scale with Document − If checked, the font size in the header and footer will be
sized. Accordingly if the document is scaled when printed. This option is enabled, by
default.
Align with Page Margins − If checked, the left header and footer will be aligned
with the left margin, and the right header and footer will be aligned with the right
margin. This option is enabled, by default.
Insert Page Break in Excel 2010
Page Breaks
If you don’t want a row to print on a page by itself or you don't want a table header row to
be the last line on a page. MS Excel gives you precise control over page breaks.
MS Excel handles page breaks automatically, but sometimes you may want to force a
page break either a vertical or a horizontal one. so that the report prints the way you
want.
For example, if your worksheet consists of several distinct sections, you may want to print
each section on a separate sheet of paper.
Inserting Page Breaks
Insert Horizontal Page Break − For example, if you want row 14 to be the first row of a
new page, select cell A14. Then choose Page Layout » Page Setup Group » Breaks»
Insert Page Break.
Insert vertical Page break − In this case, make sure to place the pointer in row 1.
Choose Page Layout » Page Setup » Breaks » Insert Page Break to create the page
break.
Removing Page Breaks
Remove a page break you’ve added − Move the cell pointer to the first row beneath
the manual page break and then choose Page Layout » Page Setup » Breaks »
Remove Page Break.
Remove all manual page breaks − Choose Page Layout » Page Setup » Breaks »
Reset All Page Breaks.
Set Background in Excel 2010
Background Image
Unfortunately, you cannot have a background image on your printouts. You may have
noticed the Page Layout » Page Setup » Background command. This button displays a
dialogue box that lets you select an image to display as a background. Placing this control
among the other print-related commands is very misleading. Background images placed
on a worksheet are never printed.
Alternative to Placing Background
You can insert a Shape, WordArt, or a picture on your worksheet and then adjust its
transparency. Then copy the image to all printed pages.
You can insert an object in a page header or footer.
Freeze Panes in Excel 2010
Freezing Panes
If you set up a worksheet with row or column headings, these headings will not be visible
when you scroll down or to the right. MS Excel provides a handy solution to this problem
with freezing panes. Freezing panes keeps the headings visible while you’re scrolling
through the worksheet.
Using Freeze Panes
Follow the steps mentioned below to freeze panes.
Select the First row or First Column or the row Below, which you want to freeze, or
Column right to area, which you want to freeze.
Choose View Tab » Freeze Panes.
Select the suitable option −
o Freeze Panes − To freeze area of cells.
If you have selected Freeze top row you can see the first row appears at the top, after
scrolling also. See the below screen-shot.
Unfreeze Panes
To unfreeze Panes, choose View Tab » Unfreeze Panes.
Conditional Format in Excel 2010
Conditional Formatting
MS Excel 2010 Conditional Formatting feature enables you to format a range of values so
that the values outside certain limits, are automatically formatted.
Choose Home Tab » Style group » Conditional Formatting dropdown.
Various Conditional Formatting Options
Highlight Cells Rules − It opens a continuation menu with various options for
defining the formatting rules that highlight the cells in the cell selection that contain
certain values, text, or dates, or that have values greater or less than a particular
value, or that fall within a certain ranges of values.
Suppose you want to find cell with Amount 0 and Mark them as red.Choose Range of cell
» Home Tab » Conditional Formatting DropDown » Highlight Cell Rules » Equal To.
After Clicking ok, the cells with value zero are marked as red.
Top/Bottom Rules − It opens a continuation menu with various options for defining
the formatting rules that highlight the top and bottom values, percentages, and above
and below average values in the cell selection.
Suppose you want to highlight the top 10% rows you can do this with these Top/Bottom
rules.
Data Bars − It opens a palette with different color data bars that you can apply to the
cell selection to indicate their values relative to each other by clicking the data bar
thumbnail.
With this conditional Formatting data Bars will appear in each cell.
Color Scales − It opens a palette with different three- and two-colored scales that
you can apply to the cell selection to indicate their values relative to each other by
clicking the color scale thumbnail.
See the below screenshot with Color Scales, conditional formatting applied.
Icon Sets − It opens a palette with different sets of icons that you can apply to the
cell selection to indicate their values relative to each other by clicking the icon set.
See the below screenshot with Icon Sets conditional formatting applied.
New Rule − It opens the New Formatting Rule dialog box, where you define a
custom conditional formatting rule to apply to the cell selection.
Clear Rules − It opens a continuation menu, where you can remove the conditional
formatting rules for the cell selection by clicking the Selected Cells option, for the
entire worksheet by clicking the Entire Sheet option, or for just the current data table
by clicking the This Table option.
Manage Rules − It opens the Conditional Formatting Rules Manager dialog box,
where you edit and delete particular rules as well as adjust their rule precedence by
moving them up or down in the Rules list box.
Creating Formulas in Excel 2010
Formulas in MS Excel
Formulas are the Bread and butter of worksheet. Without formula, worksheet will be just
simple tabular representation of data. A formula consists of special code, which is entered
into a cell. It performs some calculations and returns a result, which is displayed in the
cell.
Formulas use a variety of operators and worksheet functions to work with values and text.
The values and text used in formulas can be located in other cells, which makes changing
data easy and gives worksheets their dynamic nature. For example, you can quickly
change the data in a worksheet and formulas works.
Elements of Formulas
A formula can consist of any of these elements −
Mathematical operators, such as +(for addition) and *(for multiplication)
Example −
o =A1+A2 Adds the values in cells A1 and A2.
Values or text
Example −
o =200*0.5 Multiplies 200 times 0.15. This formula uses only values, and it
always returns the same result as 100.
Cell references (including named cells and ranges)
Example −
o=A1=C12 Compares cell A1 with cell C12. If the cells are identical, the formula
returns TRUE; otherwise, it returns FALSE.
Worksheet functions (such as SUMor AVERAGE)
Example −
o =SUM(A1:A12) Adds the values in the range A1:A12.
Creating Formula
For creating a formula you need to type in the Formula Bar. Formula begins with '=' sign.
When building formulas manually, you can either type in the cell addresses or you can
point to them in the worksheet. Using the Pointing method to supply the cell addresses
for formulas is often easier and more powerful method of formula building. When you are
using built-in functions, you click the cell or drag through the cell range that you want to
use when defining the function’s arguments in the Function Arguments dialog box. See
the below screen shot.
As soon as you complete a formula entry, Excel calculates the result, which is then
displayed inside the cell within the worksheet (the contents of the formula, however,
continue to be visible on the Formula bar anytime the cell is active). If you make an error
in the formula that prevents Excel from being able to calculate the formula at all, Excel
displays an Alert dialog box suggesting how to fix the problem.
Copying Formulas in Excel 2010
Copying Formulas in MS Excel
Copying formulas is one of the most common tasks that you do in a typical spreadsheet
that relies primarily on formulas. When a formula uses cell references rather than constant
values, Excel makes the task of copying an original formula to every place that requires a
similar formula.
Relative Cell Addresses
MS Excel does it automatically adjusting the cell references in the original formula to suit
the position of the copies that you make. It does this through a system known as relative
cell addresses, where by the column references in the cell address in the formula change
to suit their new column position and the row references change to suit their new row
position.
Let us see this with the help of example. Suppose we want the sum of all the rows at last,
then we will write a formula for first column i.e. B. We want sum of the rows from 3 to 8
in the 9th row.
After writing formula in the 9th row, we can drag it to remaining columns and the formula
gets copied. After dragging we can see the formula in the remaining columns as below.
column C : =SUM(C3:C8)
column D : =SUM(D3:D8)
column E : =SUM(E3:E8)
column F : =SUM(F3:F8)
column G : =SUM(G3:G8)
Suppose you need to determine the largest value in a range. A formula can’t tell you the
answer without using a function. We will use formula that uses the MAX function to
return the largest value in the range B3:B8 as =MAX(A1:D100).
Another example of functions. Suppose you want to find if the cell of month is greater
than 1900 then we can give Bonus to Sales representative. The we can achieve it with
writing formula with IF functions as =IF(B9>1900,"Yes","No")
Function Arguments
In the above examples, you may have noticed that all the functions used parentheses. The
information inside the parentheses is the list of arguments.
Functions vary in how they use arguments. Depending on what it has to do, a function
may use.
No arguments − Examples − Now(), Date(), etc.
One argument − UPPER(), LOWER(), etc.
A fixed number of arguments − IF(), MAX(), MIN(), AVERGAGE(), etc.
Infinite number of arguments
Optional arguments
Built-in Functions in Excel 2010
Built In Functions
MS Excel has many built in functions, which we can use in our formula. To see all the
functions by category, choose Formulas Tab » Insert Function. Then Insert function
Dialog appears from which we can choose the function.
Functions by Categories
Let us see some of the built in functions in MS Excel.
Text Functions
o LOWER − Converts all characters in a supplied text string to lower case
o TRIM − Removes duplicate spaces, and spaces at the start and end of a text
string
o CONCATENATE − Joins together two or more text strings.
text string.
o MID − Returns a specified number of characters from the middle of a supplied
text string
o RIGHT − Returns a specified number of characters from the end of a supplied
text string.
o LEN − Returns the length of a supplied text string
o FIND − Returns the position of a supplied character or text string from within a
Statistical
o MAX − Returns the largest value from a list of supplied numbers.
values.
o COUNTIF − Returns the number of cells (of a supplied range), that satisfies a
given criteria.
o SUM − Returns the sum of a supplied list of numbers
Logical
o AND − Tests a number of user-defined conditions and returns TRUE if ALL of
value or expression i.e. returns FALSE if the supplied argument is TRUE and
returns TRUE if the supplied argument is FAL
Math & Trig
o ABS − Returns the absolute value (i.e. the modulus) of a supplied number.
o MOD − Returns the remainder from a division between two supplied numbers.
If you want to sort data based on a selected column, Choose Continue with the
selection or if you want sorting based on other columns, choose Expand Selection.
You can Sort based on the below Conditions.
o Values − Alphabetically or numerically.
o Cell Color − Based on Color of Cell.
o Font Color − Based on Font color.
o Cell Icon − Based on Cell Icon.
Sorting option is also available from the Home Tab. Choose Home Tab » Sort & Filter.
You can see the same dialog to sort records.
Using Ranges in Excel 2010
Ranges in MS Excel
A cell is a single element in a worksheet that can hold a value, some text, or a formula. A
cell is identified by its address, which consists of its column letter and row number. For
example, cell B1 is the cell in the second column and the first row.
A group of cells is called a range. You designate a range address by specifying its upper-
left cell address and its lower-right cell address, separated by a colon.
Example of Ranges −
C24 − A range that consists of a single cell.
A1:B1 − Two cells that occupy one row and two columns.
A1:A100 − 100 cells in column A.
A1:D4 − 16 cells (four rows by four columns).
Selecting Ranges
You can select a range in several ways −
Press the left mouse button and drag, highlighting the range. Then release the mouse
button. If you drag to the end of the screen, the worksheet will scroll.
Press the Shift key while you use the navigation keys to select a range.
Press F8 and then move the cell pointer with the navigation keys to highlight the
range. Press F8 again to return the navigation keys to normal movement.
Type the cell or range address into the Name box and press Enter. Excel selects the
cell or range that you specified.
Selecting Complete Rows and Columns
When you need to select an entire row or column. You can select entire rows and columns
in much the same manner as you select ranges −
Click the row or column border to select a single row or column.
To select multiple adjacent rows or columns, click a row or column border and drag
to highlight additional rows or columns.
To select multiple (nonadjacent) rows or columns, press Ctrl while you click the row
or column borders that you want.
Borders
Pattern
Now, let us see how styles are helpful. Suppose that you apply a particular style to some
twenty cells scattered throughout your worksheet. Later, you realize that these cells
should have a font size of 12 pt. rather than 14 pt. Rather than changing each cell, simply
edit the style. All cells with that particular style change automatically.
Applying Styles
Choose Home » Styles » Cell Styles. Note that this display is a live preview, that is, as
you move your mouse over the style choices, the selected cell or range temporarily
displays the style. When you see a style you like, click it to apply the style to the
selection.
On-line Templates
These template data is available online at the Microsoft server. When you select the
template and click on it, it will download the template data from Microsoft server and
opens it as shown below.
Using Templates in MS Excel
Template is essentially a model that serves as the basis for something. An Excel template
is a workbook that’s used to create other workbooks.
Viewing Available Templates
To view the Excel templates, choose File » New to display the available templates screen
in Backstage View. You can select a template stored on your hard drive, or a template
from Microsoft Office Online. If you choose a template from Microsoft Office Online,
you must be connected to the Internet to download it. The Office Online Templates
section contains a number of icons, which represents various categories of templates.
Click an icon, and you’ll see the available templates. When you select a template
thumbnail, you can see a preview in the right panel.
On-line Templates
These template data is available online at the Microsoft server. When you select the
template and click on it, it will download the template data from Microsoft server and
opens it as shown below.
Using Macros in Excel 2010
Macros in MS Excel
Macros enable you to automate almost any task that you can undertake in Excel 2010. By
using macro recorder from View Tab » Macro Dropdown to record tasks that you
perform routinely, you not only speed up the procedure considerably but you are assured
that each step in a task is carried out the same way each and every time you perform a
task.
To view macros choose View Tab » Macro dropdown.
Macro Options
View tab contains a Macros command button to which a dropdown menu containing the
following three options.
View Macros − Opens the Macro dialog box where you can select a macro to run or
edit.
Record Macro − Opens the Record Macro dialog box where you define the settings
for your new macro and then start the macro recorder; this is the same as clicking the
Record Macro button on the Status bar.
Use Relative References − Uses relative cell addresses when recording a macro,
making the macro more versatile by enabling you to run it in areas of a worksheet
other than the ones originally used in the macro’s recording.
Creating Macros
You can create macros in one of two ways −
Use MS Excel’s macro recorder to record your actions as you undertake them in a
worksheet.
Enter the instructions that you want to be followed in a VBA code in the Visual Basic
Editor.
Now let's create a simple macro that will automate the task of making cell content Bold
and apply cell color.
Choose View Tab » Macro dropdown.
Click on Record Macro as below.
Now for finding the respective favorite color for that person from another sheet we need
to vlookup the data. First argument to the VLOOKUP is lookup value (In this case it is
person name). Second argument is the table array, which is table in the second sheet from
B2 to C11. Third argument to VLOOKUP is Column index num, which is the answer we
are looking for. In this case, it is 2 the color column number is 2. The fourth argument is
True returning partial match or false returning exact match. After applying VLOOKUP
formula it will calculate the color and the results are displayed as below.
As you can see in the above screen-shot that results of VLOOKUP has searched for color
in the second sheet table. It has returned #N/A in case where match is not found. In this
case, Andy's data is not present in the second sheet so it returned #N/A.
Printing Worksheets in Excel 2010
Quick Print
If you want to print a copy of a worksheet with no layout adjustment, use the Quick Print
option. There are two ways in which we can use this option.
Choose File » Print (which displays the Print pane), and then click the Print button.
Press Ctrl+P and then click the Print button (or press Enter).
Adjusting Common Page Setup Settings
You can adjust the print settings available in the Page setup dialogue in different ways as
discussed below. Page setup options include Page orientation, Page Size, Page Margins,
etc.
The Print screen in Backstage View, displayed when you choose File » Print.
The Page Layout tab of the Ribbon.
Choosing Your Printer
To switch to a different printer, choose File » Print and use the drop-down control in the
Printer section to select any other installed printer.
Click on Send using E-mail if your email system is configured. MS Outlook will
open with the file as attachment in the New Email Window. You can send mail this
workbook to anyone with valid email address.
Translate Worksheet in Excel 2010
Translate Worksheet
You can translate the text written in a different language, such as phrases or paragraphs,
individual words (by using the Mini Translator), or translate your whole file with MS
Excel 2010.
Translation is available in the review tab of the ribbon in MS Excel 2010. You can
quickly translate cell into different language with this option.
Performing Translation Step By Step
Select the content, which you want to translate to a different language.
Choose review tab » translation.
It will open the pane from which you can select the language to which you need to
translate.
You need to have an internet connection for performing translation. It will translate
using the Microsoft Translator.
Click on Insert to apply translation changes.
Workbook Security in Excel 2010
Workbook Security
We can apply security to the workbook by the concept of protection available in the
Review Tab of ribbon. MS Excel's protection-related features fall into three categories.
Worksheet protection − Protecting a worksheet from being modified, or restricting
the modifications to certain users.
Workbook protection − Protecting a workbook from having sheets inserted or
deleted, and also requiring the use of password to open the workbook.
Protect Worksheet
You may want to protect a worksheet for a variety of reasons. One reason is to prevent
yourself or others from accidentally deleting the formulas or other critical data. A
common scenario is to protect a worksheet, so that the data can be changed, but the
formulas can’t be changed.
To protect a worksheet, choose Review » Changes group » Protect Sheet. Excel
displays the Protect Sheet dialog box. Note that providing a password is optional. If you
enter a password, that password will be required to unprotect the worksheet. You can
select various options in which the sheet should be protected. Suppose we checked
Format Cells option then Excel will not allow to format cells.
When somebody tries to format the cells, he or she will get the error as shown in the
screenshot below.
To remove a password from a workbook, repeat the same procedure. In Step 2, however,
delete the existing password symbols.
Protecting Workbook’s Structure and Windows
To prevent others (or yourself) from performing certain actions in a workbook, you can
protect the workbook’s structure and windows. When a workbook’s structure and
windows are protected, the user may not Add a sheet, Delete a sheet, Hide a sheet, unhide
a sheet, etc., and may not be allowed to change the size or position of a workbook’s
windows respectively.
To protect a worksheet’s structure and windows, follow the below mentioned steps.
Choose Review » Changes group » Protect Workbook to display the Protect
Workbook dialog box.
In the Protect Workbook dialog box, select the Structure check box and Windows
check box.
(Optional) Enter a password.
Click OK.
Data Tables in Excel 2010
Data Tables
In Excel, a Data Table is a way to see different results by altering an input cell in your
formula. Data tables are available in Data Tab » What-If analysis dropdown » Data
table in MS Excel.
Now, for creation of data table select the range of data table. Choose Data Tab » What-If
analysis dropdown » Data table. It will give you dialogue asking for Input row and
Input Column. Give the Input row as Price cell (In this case cell B3) and Input column as
quantity cell (In this case cell B4). Please see the below screen-shot.
Clicking OK will generate data table as shown in the below screen-shot. It will generate
the table formula. You can change the price horizontally or quantity vertically to see the
change in the Net Price.
Pivot Tables in Excel 2010
Pivot Tables
A pivot table is essentially a dynamic summary report generated from a database. The
database can reside in a worksheet (in the form of a table) or in an external data file. A
pivot table can help transform endless rows and columns of numbers into a meaningful
presentation of the data. Pivot tables are very powerful tool for summarized analysis of
the data.
Pivot tables are available under Insert tab » PivotTable dropdown » PivotTable.
Pivot Table Example
Now, let us see Pivot table with the help of example. Suppose you have huge data of
voters and you want to see the summarized data of voter Information per party, then you
can use the Pivot table for it. Choose Insert tab » Pivot Table to insert pivot table. MS
Excel selects the data of the table. You can select the pivot table location as existing sheet
or new sheet.
This will generate the Pivot table pane as shown below. You have various options
available in the Pivot table pane. You can select fields for the generated pivot table.
Column labels − A field that has a column orientation in the pivot table. Each item
in the field occupies a column.
Report Filter − You can set the filter for the report as year, then data gets filtered as
per the year.
Row labels − A field that has a row orientation in the pivot table. Each item in the
field occupies a row.
Values area − The cells in a pivot table that contain the summary data. Excel offers
several ways to summarize the data (sum, average, count, and so on).
After giving input fields to the pivot table, it generates the pivot table with the data as
shown below.
Column − Column chart shows data changes over a period of time or illustrates
comparisons among items.
Bar − A bar chart illustrates comparisons among individual items.
Pie − A pie chart shows the size of items that make up a data series, proportional to
the sum of the items. It always shows only one data series and is useful when you
want to emphasize a significant element in the data.
Line − A line chart shows trends in data at equal intervals.
Area − An area chart emphasizes the magnitude of change over time.
X Y Scatter − An xy (scatter) chart shows the relationships among the numeric
values in several data series, or plots two groups of numbers as one series of xy
coordinates.
Stock − This chart type is most often used for stock price data, but can also be used
for scientific data (for example, to indicate temperature changes).
Surface − A surface chart is useful when you want to find the optimum combinations
between two sets of data. As in a topographic map, colors and patterns indicate areas
that are in the same range of values.
Doughnut − Like a pie chart, a doughnut chart shows the relationship of parts to a
whole; however, it can contain more than one data series.
Bubble − Data that is arranged in columns on a worksheet, so that x values are listed
in the first column and corresponding y values and bubble size values are listed in
adjacent columns, can be plotted in a bubble chart.
Radar − A radar chart compares the aggregate values of a number of data series.
Creating Chart
To create charts for the data by below mentioned steps.
Select the data for which you want to create the chart.
Choose Insert Tab » Select the chart or click on the Chart group to see various
chart types.
Select the chart of your choice and click OK to generate the chart.
Editing Chart
You can edit the chart at any time after you have created it.
You can select the different data for chart input with Right click on chart » Select
data. Selecting new data will generate the chart as per the new data, as shown in the
below screen-shot.
You can change the X axis of the chart by giving different inputs to X-axis of chart.
You can change the Y axis of chart by giving different inputs to Y-axis of chart.
Pivot Charts Excel 2010
Pivot Charts
A pivot chart is a graphical representation of a data summary, displayed in a pivot table.
A pivot chart is always based on a pivot table. Although Excel lets you create a pivot
table and a pivot chart at the same time, you can’t create a pivot chart without a pivot
table. All Excel charting features are available in a pivot chart.
Pivot charts are available under Insert tab » PivotTable dropdown » PivotChart.
Pivot Chart Example
Now, let us see Pivot table with the help of an example. Suppose you have huge data of
voters and you want to see the summarized view of the data of voter Information per party
in the form of charts, then you can use the Pivot chart for it. Choose Insert tab » Pivot
Chart to insert the pivot table.
MS Excel selects the data of the table. You can select the pivot chart location as an
existing sheet or a new sheet. Pivot chart depends on automatically created pivot table by
the MS Excel. You can generate the pivot chart in the below screen-shot.
Keyboard Shortcuts in Excel 2010
MS Excel Keyboard Short-cuts
MS Excel offers many keyboard short-cuts. If you are familiar with windows operating
system, you should be aware of most of them. Below is the list of all the major shortcut
keys in Microsoft Excel.
Ctrl + A − Selects all contents of the worksheet.
Ctrl + B − Bold highlighted selection.
Ctrl + I − Italicizes the highlighted selection.
Ctrl + K − Inserts link.
Ctrl + U − Underlines the highlighted selection.
Ctrl + 1 − Changes the format of selected cells.
Ctrl + 5 − Strikethrough the highlighted selection.
Ctrl + P − Brings up the print dialog box to begin printing.
Ctrl + Z − Undo last action.
Ctrl + F3 − Opens Excel Name Manager.
Ctrl + F9 − Minimizes the current window.
Ctrl + F10 − Maximize currently selected window.
Ctrl + F6 − Switches between open workbooks or windows.
Ctrl + Page up − Moves between Excel work sheets in the same Excel document.
Ctrl + Page down − Moves between Excel work sheets in the same Excel document.
Ctrl + Tab − Moves between Two or more open Excel files.
Alt + = − Creates a formula to sum all of the above cells
Ctrl + ' − Inserts the value of the above cell into cell currently selected.
Ctrl + Shift + ! − Formats the number in comma format.
Ctrl + Shift + $ − Formats the number in currency format.
Ctrl + Shift + # − Formats the number in date format.
Ctrl + Shift + % − Formats the number in percentage format.
Ctrl + Shift + ^ − Formats the number in scientific format.
Ctrl + Shift + @ − Formats the number in time format.
Ctrl + Arrow key − Moves to the next section of text.
Ctrl + Space − Selects the entire column.
Shift + Space − Selects the entire row.
Ctrl + - − Deletes the selected column or row.
Ctrl + Shift + = − Inserts a new column or row.
Ctrl + Home − Moves to cell A1.
Ctrl + ~ − Switches between showing Excel formulas or their values in cells.
F2 − Edits the selected cell.
F3 − After a name has been created F3 will paste names.
F4 − Repeat last action. For example, if you changed the color of text in another cell
pressing F4 will change the text in cell to the same color.
F5 − Goes to a specific cell. For example, C6.
F7 − Spell checks the selected text or document.
F11 − Creates chart from the selected data.
Ctrl + Shift + ; − Enters the current time.
Ctrl + ; − Enters the current date.
Alt + Shift + F1 − Inserts New Worksheet.
Alt + Enter − While typing text in a cell pressing Alt + Enter will move to the next
line allowing for multiple lines of text in one cell.
Shift + F3 − Opens the Excel formula window.
Shift + F5 − Brings up the search box.
Microsoft Access is a Database Management System (DBMS) from Microsoft that
combines the relational Microsoft Jet Database Engine with a graphical user interface and
softwaredevelopment tools. It is a member of the Microsoft Office suite of applications,
included in the professional and higher editions.
Microsoft Access is just one part of Microsoft’s overall data management product
strategy.
It stores data in its own format based on the Access Jet Database Engine.
Like relational databases, Microsoft Access also allows you to link related
information easily. For example, customer and order data. However, Access 2013
also complements other database products because it has several powerful
connectivity features.
It can also import or link directly to data stored in other applications and databases.
As its name implies, Access can work directly with data from other sources,
including many popular PC database programs, with many SQL (Structured Query
Language) databases on the desktop, on servers, on minicomputers, or on
mainframes, and with data stored on Internet or intranet web servers.
Access can also understand and use a wide variety of other data formats, including
many other database file structures.
You can export data to and import data from word processing files, spreadsheets, or
database files directly.
Access can work with most popular databases that support the Open Database
Connectivity (ODBC) standard, including SQL Server, Oracle, and DB2.
Software developers can use Microsoft Access to develop application software.
Microsoft Access stores information which is called a database. To use MS Access, you
will need to follow these four steps −
Database Creation − Create your Microsoft Access database and specify what kind
of data you will be storing.
Data Input − After your database is created, the data of every business day can be
entered into the Access database.
Query − This is a fancy term to basically describe the process of retrieving
information from the database.
Report (optional) − Information from the database is organized in a nice presentation
that can be printed in an Access Report.
Architecture
Access calls anything that can have a name an object. Within an Access desktop
database, the main objects are tables, queries, forms, reports, macros, data macros,
and modules.
If you have worked with other database systems on desktop computers, you might
have seen the term database used to refer to only those files in which you store data.
But, in Access, a desktop database (.accdb) also includes all the major objects related
to the stored data, including objects you define to automate the use of your data.
Ms Access - RDBMS
Microsoft Access has the look and feel of other Microsoft Office products as far as its
layout and navigational aspects are concerned, but MS Access is a database and, more
specifically, a relational database.
Before MS Access 2007, the file extension was *.mdb, but in MS Access 2007 the
extension has been changed to *.accdb extension.
Early versions of Access cannot read accdb extensions but MS Access 2007 and later
versions can read and change earlier versions of Access.
An Access desktop database (.accdb or .mdb) is a fully functional RDBMS.
It provides all the data definition, data manipulation, and data control features that
you need to manage large volumes of data.
You can use an Access desktop database (.accdb or .mdb) either as a standalone
RDBMS on a single workstation or in a shared client/server mode across a network.
A desktop database can also act as the data source for data displayed on webpages on
your company intranet.
When you build an application with an Access desktop database, Access is the
RDBMS.
Data Definition
Let us now understand what Data Definition is −
In document or a spreadsheet, you generally have complete freedom to define the
contents of the document or each cell in the spreadsheet.
In a document, you can include paragraphs of text, a table, a chart, or multiple
columns of data displayed with multiple fonts.
In spreadsheet, you can have text data at the top to define a column header for
printing or display, and you might have various numeric formats within the same
column, depending on the function of the row.
An RDBMS allows you to define the kind of data you have and how the data should
be stored.
You can also usually define rules that the RDBMS can use to ensure the integrity of
your data.
For example, a validation rule might ensure that the user can’t accidentally store
alphabetic characters in a field that should contain a number.
Data Manipulation
Working with data in RDBMS is very different from working with data in a word
processing or spreadsheet program.
In a word processing document, you can include tabular data and perform a limited
set of functions on the data in the document.
You can also search for text strings in the original document and, with ActiveX
controls, include tables, charts, or pictures from other applications.
In a spreadsheet, some cells contain functions that determine the result you want, and
in other cells, you enter the data that provides the source information for the
functions.
An RDBMS provides you many ways to work with your data. For example,
You can search a single table for information or request a complex search across
several related tables.
You can update a single field or many records with a single command.
You can write programs that use RDBMS commands to fetch data that you want to
display and allow the user to update the data.
Access uses the powerful SQL database language to process data in your tables. Using
SQL, you can define the set of information that you need to solve a particular problem,
including data from perhaps many tables.
Data Control
Spreadsheets and word processing documents are great for solving single-user problems,
but they are difficult to use when more than one person needs to share the data.
When you need to share your information with others, RDBMS gives you the
flexibility to allow multiple users to read or update your data.
An RDBMS that is designed to allow data sharing also provides features to ensure
that no two people can change the same data at the same time.
The best systems also allow you to group changes (which is also known as
transaction) so that either all the changes or none of the changes appear in your data.
You might also want to be sure that no one else can view any part of the order until
you have entered all of it.
Because you can share your Access data with other users, you might need to set some
restrictions on what various users are allowed to see or update.
Ms Access - Objects
MS Access uses “objects" to help the user list and organize information, as well as
prepare specially designed reports. When you create a database, Access offers you Tables,
Queries, Forms, Reports, Macros, and Modules. Databases in Access are composed of
many objects but the following are the major objects −
Tables
Queries
Forms
Reports
Together, these objects allow you to enter, store, analyze, and compile your data. Here is
a summary of the major objects in an Access database;
Table
Table is an object that is used to define and store data. When you create a new table,
Access asks you to define fields which is also known as column headings.
Each field must have a unique name, and data type.
Tables contain fields or columns that store different kinds of data, such as a name or
an address, and records or rows that collect all the information about a particular
instance of the subject, such as all the information about a customer or employee etc.
You can define a primary key, one or more fields that have a unique value for each
record, and one or more indexes on each table to help retrieve your data more
quickly.
Query
An object that provides a custom view of data from one or more tables. Queries are a way
of searching for and compiling data from one or more tables.
Running a query is like asking a detailed question of your database.
When you build a query in Access, you are defining specific search conditions to find
exactly the data you want.
In Access, you can use the graphical query by example facility or you can write
Structured Query Language (SQL) statements to create your queries.
You can define queries to Select, Update, Insert, or Delete data.
You can also define queries that create new tables from data in one or more existing
tables.
Form
Form is an object in a desktop database designed primarily for data input or display or for
control of application execution. You use forms to customize the presentation of data that
your application extracts from queries or tables.
Forms are used for entering, modifying, and viewing records.
The reason forms are used so often is that they are an easy way to guide people
toward entering data correctly.
When you enter information into a form in Access, the data goes exactly where the
database designer wants it to go in one or more related tables.
Report
Report is an object in desktop databases designed for formatting, calculating, printing, and
summarizing selected data.
You can view a report on your screen before you print it.
If forms are for input purposes, then reports are for output.
Anything you plan to print deserves a report, whether it is a list of names and
addresses, a financial summary for a period, or a set of mailing labels.
Reports are useful because they allow you to present components of your database in
an easy-to-read format.
You can even customize a report's appearance to make it visually appealing.
Access offers you the ability to create a report from any table or query.
Other MS Access Objects
Let us now take a look at other MS Access objects.
Macro
This object is a structured definition of one or more actions that you want Access to
perform in response to a defined event. An Access Macro is a script for doing some job.
For example, to create a button which opens a report, you could use a macro which will
fire OpenReport action.
You can include simple conditions in macros to specify when one or more actions in
the macro should be performed or skipped.
You can use macros to open and execute queries, to open tables, or to print or view
reports.
You can also run other macros or Visual Basic procedures from within a macro.
Data macros can be attached directly to table events such as inserting new records,
editing existing records, or deleting records.
Data macros in web apps can also be stand-alone objects that can be called from
other data macros or macro objects.
Module
Module is an object in desktop databases containing custom procedures that you code
using Visual Basic. Modules provide a more discrete flow of actions and allow you to trap
errors.
Everything that can be done in a macro can also be done in a module, but you don't
get the macro interface that prompts you what is needed for each action.
Modules are far more powerful, and are essential if you plan to write code for a
multi-user environment, because macros cannot include error handling.
Modules can be standalone objects containing functions that can be called from
anywhere in your application, or they can be directly associated with a form or a
report to respond to events on the associated form or report.
Ms Access - Create Database
In this chapter, we will be covering the basic process of starting Access and creating a
database. This chapter will also explain how to create a desktop database by using a
template and how to build a database from scratch.
To create a database from a template, we first need to open MS Access and you will see
the following screen in which different Access database templates are displayed.
To view the all the possible databases, you can scroll down or you can also use the search
box.
Let us enter project in the search box and press Enter. You will see the database templates
related to project management.
Select the first template. You will see more information related to this template.
After selecting a template related to your requirements, enter a name in the File
name field and you can also specify another location for your file if you want.
Now, press the Create option. Access will download that database template and open a
new blank database as shown in the following screenshot.
Now, click the Navigation pane on the left side and you will see all the other objects that
come with this database.
Click the Projects Navigation and select the Object Type in the menu.
You will now see all the objects types — tables, queries, etc.
Create Blank Database
Sometimes database requirements can be so specific that using and modifying the existing
templates requires more work than just creating a database from scratch. In such case, we
make use of blank database.
Step 1 − Let us now start by opening MS Access.
Step 2 − Select Blank desktop database. Enter the name and click the Create button.
Step 3 − Access will create a new blank database and will open up the table which is also
completely blank.
Ms Access - Data Types
Every field in a table has properties and these properties define the field's characteristics
and behavior. The most important property for a field is its data type. A field's data type
determines what kind of data it can store. MS Access supports different types of data,
each with a specific purpose.
The data type determines the kind of the values that users can store in any given field.
Each field can store data consisting of only a single data type.
Here are some of the most common data types you will find used in a typical Microsoft
Access database.
Type of Data Description Size
Currency 8 bytes
values and
numeric data
used in
mathematical
Currency calculations
involving
data with one
to four
decimal
places.
If you use previous versions of Access, you will notice a difference for two of those
data types.
In Access 2013, we now have two data types — short text and long text. In previous
versions of Access these data types were called text and memo.
The text field is referred to as short text and your memo field is now called long text.
Here are some of the other more specialized data types, you can choose from in Access.
Data Types Description Size
These are all the different data types that you can choose from when creating fields in a
Microsoft Access table.
Ms Access - Create Tables
When you create a database, you store your data in tables. Because other database objects
depend so heavily on tables, you should always start your design of a database by creating
all of its tables and then creating any other object. Before you create tables, carefully
consider your requirements and determine all the tables that you need.
Let us try and create the first table that will store the basic contact information concerning
the employees as shown in the following table −
Field Name Data Type
EmployeelD AutoNumber
Let us now have short text as the data type for all these fields and open a blank database
in Access.
This is where we left things off. We created the database and then Access automatically
opened up this table-one-datasheet view for a table.
Let us now go to the Field tab and you will see that it is also automatically created. The
ID which is an AutoNumber field acts as our unique identifier and is the primary key for
this table.
The ID field has already been created and we now want to rename it to suit our
conditions. This is an Employee table and this will be the unique identifier for our
employees.
Click on the Name & Caption option in the Ribbon and you will see the following dialog
box.
Change the name of this field to EmployeeID to make it more specific to this table. Enter
the other optional information if you want and click Ok.
We now have our employee ID field with the caption Employee ID. This is automatically
set to auto number so we don't really need to change the data type.
Let us now add some more fields by clicking on click to add.
Choose Short Text as the field. When you choose short text, Access will then highlight
that field name automatically and all you have to do is type the field name.
Type FirstName as the field name. Similarly, add all the required fields as shown in the
following screenshot.
Once all the fields are added, click the Save icon.
You will now see the Save As dialog box, where you can enter a table name for the table.
Enter the name of your table in the Table Name field. Here the tbl prefix stands for table.
Let us click Ok and you will see your table in the navigation pane.
Table Design View
As we have already created one table using Datasheet View. We will now create another
table using the Table Design View. We will be creating the following fields in this table.
These tables will store some of the information for various book projects.
Field Name Data Type
Project ID AutoNumber
Contracts Attachment
ProjectStart Date/Time
ProjectEnd Date/Time
Budget Currency
ProjectNotes Long Text
In the tables group, click on Table and you can see this looks completely different from
the Datasheet View. In this view, you can see the field name and data type side by side.
We now need to make ProjectID a primary key for this table, so let us
select ProjectID and click on Primary Key option in the ribbon.
You can now see a little key icon that will show up next to that field. This shows that the
field is part of the table’s primary key.
Let us save this table and give this table a name.
Click Ok and you can now see what this table looks like in the Datasheet View.
Let us click the datasheet view button on the top left corner of the ribbon.
If you ever want to make changes to this table or any specific field, you don't always have
to go back to the Design View to change it. You can also change it from the Datasheet
View. Let us update the PStatus field as shown in the following screenshot.
Similarly, add some data in the second table as well as shown in the following screenshot.
You can now see that inserting a new data and updating the existing data is very simple in
Datasheet View as working in spreadsheet. But if you want to delete any data you need to
select the entire row first as shown in the following screenshot.
Now press the delete button. This will display the confirmation message.
Click Yes and you will see that the selected record is deleted now.
In the tblEmployees table, double-click all those fields which you want to see as result of
the query. Add these fields to the query design grid as shown in the following screenshot.
Now click Run on the Design tab, then click Run.
The query runs, and displays only data in those field which is specified in the query.
Ms Access - Query Criteria
Query criteria helps you to retrieve specific items from an Access database. If an item
matches with all the criteria you enter, it appears in the query results. When you want to
limit the results of a query based on the values in a field, you use query criteria.
A query criterion is an expression that Access compares to query field values to
determine whether to include the record that contains each value.
Some criteria are simple, and use basic operators and constants. Others are complex,
and use functions, special operators, and include field references.
To add some criteria to a query, you must open the query in the Design View.
You then identify the fields for which you want to specify criteria.
Example
Let’s look at a simple example in which we will use criteria in a query. First open your
Access database and then go to the Create tab and click on Query Design.
In the Tables tab on Show Table dialog, double-click on the tblEmployees table and then
close the dialog box.
Let us now add some field to the query grid such as EmployeeID, FirstName, LastName,
JobTitle and Email as shown in the following screenshot.
Let us now run your query and you will see only these fields as query result.
If you want to see only those whose JobTitle are Marketing Coordinator then you will
need to add the criteria for that. Let’s go to the Query Design again and in Criteria row of
JobTitle enter Marketing Coordinator.
Let us now run your query again and you will see that only Job title of Marketing
Coordinators are retrieved.
If you want to add criteria for multiple fields, just add the criteria in multiple fields. Let us
say we want to retrieve data only for “Marketing Coordinator” and “Accounting
Assistant”; we can specify the OR row operator as shown in the following screenshot −
Let us now run your query again and you will see the following results.
If you need to use the functionality of the AND operator, then you have to specify the
other condition in the Criteria row. Let us say we want to retrieve all Accounting
Assistants but only those Marketing Coordinator titles with “Pollard” as last name.
Let us now run your query again and you will see the following results.
Ms Access - Action Queries
In MS Access and other DBMS systems, queries can do a lot more than just displaying
data, but they can actually perform various actions on the data in your database.
Action queries are queries that can add, change, or delete multiple records at one
time.
The added benefit is that you can preview the query results in Access before you run
it.
Microsoft Access provides 4 different types of Action Queries −
o Append
o Update
o Delete
o Make-table
An action query cannot be undone. You should consider making a backup of any
tables that you will update by using an update query.
Create an Append Query
You can use an Append Query to retrieve data from one or more tables and add that data
to another table. Let us create a new table in which we will add data from
the tblEmployees table. This will be temporary table for demo purpose.
Let us call it TempEmployees and this contains the fields as shown in the following
screenshot.
In the Tables tab, on the Show Table dialog box, double-click on the tblEmployees table
and then close the dialog box. Double-click on the field you want to be displayed.
In the Query Type, select the Append option button. This will display the following
dialog box.
Select the table name from the drop-down list and click Ok.
In the Query grid, you can see that in the Append To row all the field are selected by
default except Address1. This because that Address1 field is not available in
the TempEmployee table. So, we need to select the field from the drop-down list.
Let us now run your query and you will see the following confirmation message.
Click Yes to confirm your action.
When you open the TempEmployee table, you will see all the data is added from the
tblEmployees to the TempEmployee table.
Ms Access - Create Queries
Let us understand how to create queries in this chapter.
Create an Update Query
You can use an Update Query to change the data in your tables, and you can use an
update query to enter criteria to specify which rows should be updated. An update query
provides you an opportunity to review the updated data before you perform the update.
Let us go to the Create tab again and click Query Design.
In the Tables tab, on the Show Table dialog box, double-click on the tblEmployees table
and then close the dialog box.
On the Design tab, in the Query Type group, click Update and double-click on the field in
which you want to update the value. Let us say we want to update the FirstName of “Rex”
to “Max”.
In the Update row of the Design grid, enter the updated value and in Criteria row add the
original value which you want to be updated and run the query. This will display the
confirmation message.
Click Yes and go to Datasheet View and you will see the first record — FirstName is
updated to “Max” now.
On the Design tab, in the Query Type group, click Delete and double-click on
the EmployeeID.
In the Criteria row of the Design Grid, type 11. Here we want to delete an employee
whose EmployeeID is 11.
Let us now run the query. This query will display the confirmation message.
Click Yes and go to your Datasheet View and you will see that the specified employee
record is deleted now.
Select all those fields which you want to copy to another table.
In the Query Type, select the Make Table option button.
You will see the following dialog box. Enter the name of the new table you want to create
and click OK.
Click Yes and you will see a new table created in the navigation pane.
In the query design grid, in the Criteria row of the ProjectStart column, type [Enter a
project start data]. The string [Enter a project start data] is your parameter prompt.
The square brackets indicate that you want the query to ask for input, and the text
is Enter a project start data is the parameter prompt displays.
Let us now run your query and you will see the following prompt.
Click OK to confirm.
As a result, you will see the details of the project which started on 2/1/2007. Let us go to
the Design View and run the query again.
Enter the date as in the above screenshot and click Ok. You will now see the details of the
project which started on 5/1/2008.
Ms Access - Alternate Criteria
Queries come in with many advantages. You can save and run the same query again and
again, and a lot of times you want to add alternate criteria.
You can add alternate criteria in the following two ways −
You can use the OR operator to combine two sets of criteria.
You can also use the query design grid, but instead of specifying criteria on the same
line, you will need to separate it in multiple row.
Example
Let us look at a simple example of alternate criteria. Open database and in the Create tab
select Query Design.
You can now see that alternate criterion is specified in different rows of
the LastName field. When you run this query, you will see the employees whose last
name is either Pollard or Manning. Let us now run this query.
As you can see that only two employees have been retrieved, because of the alternate
criteria.
If you want to add alternate criteria in multiple fields then you will have to use different
rows for all the fields. Let us now add another alternate criterion where we can retrieve
information for employees whose last name is either Pollard or Manning or the job title
is Accounting Assistant.
Let us now run this query.
To solve this problem, we need to restructure our data and break it down into multiple
tables to eliminate some of those redundancy as shown in the following three tables.
Here, we have one table for Customers, the 2 nd one is for Orders and the 3rd one is for
Cookies.
The problem here is that just by splitting the data in multiple tables will not help to tell
how data from one table relates to data in another table. To connect data in multiple
tables, we have to add foreign keys to the Orders table.
Defining Relationships
A relationship works by matching data in key columns usually columns with the same
name in both the tables. In most cases, the relationship matches the primary key from one
table, which provides a unique identifier for each row, with an entry in the foreign key in
the other table. There are three types of relationships between tables. The type of
relationship that is created depends on how the related columns are defined.
Let us now look into the three types of relationships −
One-to-Many Relationships
A one-to-many relationship is the most common type of relationship. In this type of
relationship, a row in table A can have many matching rows in table B, but a row in table
B can have only one matching row in table A.
For example, the Customers and Orders tables have a one-to-many relationship: each
customer can place many orders, but each order comes from only one customer.
Many-to-Many Relationships
In a many-to-many relationship, a row in table A can have many matching rows in table
B, and vice versa.
You create such a relationship by defining a third table, called a junction table, whose
primary key consists of the foreign keys from both table A and table B.
For example, the Customers table and the Cookies table have a many-to-many
relationship that is defined by a one-to-many relationship from each of these tables to the
Orders table.
One-to-One Relationships
In a one-to-one relationship, a row in table A can have no more than one matching row in
table B, and vice versa. A one-to-one relationship is created if both the related columns
are primary keys or have unique constraints.
This type of relationship is not common because most information related in this way
would be all in one table. You might use a one-to-one relationship to −
Divide a table into many columns.
Isolate part of a table for security reasons.
Store data that is short-lived and could be easily deleted by simply deleting the table.
Store information that applies only to a subset of the main table.
Ms Access - Create Relationships
In this chapter, we will understand the need to create relationships between related tables.
One of the goals of good database design is to remove data redundancy.
To achieve that goal, you divide your data into many subject-based tables so that
each fact is represented only once.
To do this, all the common fields which are related to each other are placed in one
table.
To do this step correctly, you must first understand the relationship between your
tables, and then specify these relationships in your Access database.
Why Create Table Relationships?
MS Access uses table relationships to join tables when you need to use them in a database
object. There are several reasons why you should create table relationships before you
create other database objects, such as forms, queries, macros, and reports.
To work with records from more than one table, you often must create a query that
joins the tables.
The query works by matching the values in the primary key field of the first table
with a foreign key field in the second table.
When you design a form or report, MS Access uses the information it gathers from
the table relationships you have already defined to present you with informed
choices and to prepopulate property settings with appropriate default values.
When you design a database, you divide your information into tables, each of which
has a primary key and then add foreign keys to related tables that reference those
primary keys.
These foreign key-primary key pairings form the basis for table relationships and
multi-table queries.
Let us now add another table into your database and name it tblHRData using Table
Design as shown in the following screenshot.
Click on the Save icon as in the above screenshot.
Select tblEmployees and tblHRData and then click on the Add button to add them to our
view and then close the Show Table dialog box.
To create a relationship between these two tables, use the mouse, and click and hold
the EmployeeID field from tblEmployees and drag and drop that field on the field we
want to relate by hovering the mouse right over EmployeeID from tblHRData. When
you release your mouse button, Access will then open the following window −
Here, on the left-hand side of each and every record, you will see a little plus sign by
default. When you create a relationship, Access will automatically add a sub-datasheet to
that table.
Let us click on the plus sign and you will see the information that is related to this record
is on the tblHRData table.
Click on the Save icon and open tblHRData and you will see that the data we have
entered is already here.
Ms Access - One-To-Many Relationship
The vast majority of your relationships will more than likely be this one to many
relationships where one record from a table has the potential to be related to many records
in another table.
The process to create one-to-many relationship is exactly the same as for creating a one-
to-one relationship.
Let us first clear the layout by clicking on the Clear Layout option on the Design tab.
We will first add another table tblTasks as shown in the following screenshot.
Click on the Save icon and enter tblTasks as the table name and go to
the Relationship view.
We can run through the same process once again to relate these tables. Click and hold
ProjectID from tblProjects and drag that all the way over to the ProjectID from tblTasks.
Further, a relationships window pops up when you release the mouse.
Click the Create button. We now have a very simple relationship created.
Select the Author field and press the delete button and you will see the following
message.
Click Yes. We will now have to create a junction table. This junction table have two
foreign keys in it as shown in the following screenshot.
These foreign key fields will be the primary keys from the two tables that were linked
together — tblAuthers and tblProjects.
To create a composite key in Access, select both these fields and from the table tools
design tab, you can click directly on that primary key and that will mark not one but both
of these fields.
The combination of these two fields is the tables’ unique identifier. Let us now save this
table as tblAuthorJunction.
The last step in bringing the many-to-many relationships together is to go back to
that relationships view and create those relationships by clicking on Show Table.
Select the above three highlighted tables and click on the Add button and then close this
dialog box.
Click and drag the AuthorID field from tblAuthors and place it on top of
the tblAuthorJunction table AuthorID.
The relationship you’re creating is the one that Access will consider as a one-to-many
relationship. We will also enforce referential integrity. Let us now turn on Cascade
Update and click on the Create button as in the above screenshot.
Let us now hold the ProjectID, drag and drop it right on top
of ProjectID from tblAuthorJunction.
As a rule, you use the ANSI-89 wildcards when you run queries and find-and-
replace operations against Access databases such as *.mdb and *.accdb files.
You use the ANSI-92 wildcards when you run queries against Access projects — Access
files connected to Microsoft SQL Server databases. Access projects use the ANSI-92
standard because SQL Server uses that standard.
ANSI-89 Wildcard Characters
The following table lists out characters supported by ANSI-89 −
Characte Description Example
r
Example
Let us now look at a simple example of using these wildcard characters by opening the
query design.
Add the highlighted tables and close the Show Table dialog box.
Add the fields in the query grid which you want to see as a query result.
Run your query.
Let us again go to the query design and add prompt for project name.
Now run your query and let us assume that you don’t know the exact project name, but
you know that the project name contains the words “potion”. Click Ok.
The above step does not generate any result. That is because Access is looking for an
exact match in the project name field. It is looking for that project which has the
word potion in its name.
If you want it so that the users can enter wildcards to replace unknown characters, then
you need to adjust the criteria and include the operator like.
When you run the query, users can use wildcards to replace any number of characters.
Let us assume that you know that the word potion appears somewhere in the title but you
are not exactly sure where.
You can add an * to replace any number of characters before the word potion and then
add another * after the. Click Ok.
It is always good for the users to know the wildcards they can enter. But there are users
who may not know the wildcards they can and cannot enter. In that case, you can enter the
wildcards yourself.
In this situation, in-between the Like operator and our parameter prompt, we can add
those wildcards and now there's a very specific way we have to write this. After the
word like in quotation marks, enter the wildcard that we are using. In this case, we have
used “*” to replace any number of characters. We will now add this to the parameter. To
do so, we need ampersand (&) symbol and a space. We will now repeat this step and add
another ampersand (&) because we're joining that wildcard to whatever criteria is entered
in for that project name by the user and then “*” in quotes.
Let us now run our query again. Enter the word potion in the prompt without any
wildcards.
The query will now track those wildcards on either side of whatever is entered here. We
need to simply type potion and press enter.
We now get the results we were looking for and the results will be the same regardless of
what the users enter.
Let us say we want to find every project with the word “the” in the title. Then, you need
to just type the word and Enter or click Ok.
With this query, it becomes easier to search for projects with the word “the” in their
names. The 2nd level of results may also include the project names with the word “mother”
where “the” is part of the word.
Ms Access - Calculated Expression
In MS Access, an expression is like a formula in Excel. This consists of a number of
elements that can be used alone or in a combination to produce a result. Expressions can
include operators’, constants, functions and identifiers.
Expressions can be used to perform a variety of tasks from retrieving the value of a
control or supplying criteria to a query to creating calculated controls and fields or
defining a group level for report.
In this chapter, we will be focusing on creating a very specific kind of expression
called a calculated expression. We will create several calculated fields that will
calculate and display data that is not stored anywhere within the database itself but
calculated from separate fields that are stored.
We now have a new Access database that contains more data to calculate.
Example
Let us try an example to understand this. We will be retrieving some information from a
variety of tables — tblCustomers, tblOrders, tblOrdersDetails and tblBooks and
reviewing a variety of fields.
Let us now run the query and you will see the following results.
We want a very simple calculation for a subtotal which will take the quantity of the books
ordered and multiply that by the retail price of the book. It is a good idea to begin every
expression or any expression with a name to call that field. Let us call this one subtotal.
Let us say we want to calculate our sales tax. In the query grid we will do in the exact
same way we did before and this time we will call the field simply Tax and Let us
multiply Subtotal by nine percent tax rate.
Let us run your query again and you will see the new Tax field in the end.
Ms Access - Indexing
An index is a data structure, a special data structure designed to improve the speed of data
retrieval. If you often search a table or sort its records by a particular field, you can speed
up these operations by creating an index for the field. Microsoft Access uses indexes in a
table as you use an index in a book to find data.
In some instances, such as for a primary key, Access automatically creates an index
for you.
At other times, you might want to create an index yourself.
An index stores the location of records based on the field or fields that you choose to
index.
After Access obtains the location from the index, it can then retrieve the data by
Access creates additional secondary indexes depending on the names of your fields.
Go to the Object Designers and you will see a section labeled AutoIndex on
Import/Create and in the textbox you will see ID;key;code;num. By default, access
automatically adds a secondary index to fields that start or end with these names and that
goes for fields you have imported as well as ones you have manually created.
If you want to make any field indexed you can go to the Field tab.
Select any field that you want indexed and check the Indexed checkbox in Field
Validation section. You also have alternate options for creating or removing an index.
You can go back to the Design View.
You can adjust indexes by selecting any field. You can also see how they are indexed in
the field properties area below. Any field that has No selected next to indexed, means
there is no index for that given field. You can change that by clicking on the drop-down
menu and choosing the other two options — Yes (Duplicate OK) and Yes (No
duplicates).
The last option Yes (No Duplicates) means that Access will automatically prohibit
duplicate values in that field. Let us now create an index for our last name field.
Let us select LastName to index and say Yes (Duplicates OK). As we save, Access will
create that index. Another area where you can view and adjust your indexes for a table is
the tables design area in the Show/Hide group.
If you click on this Indexes button that will bring up a special view displaying all the
indexes created for this table.
We now have two indexes for tblEmployees —one that was created automatically based
on the primary key field and one that we just created for the LastName field. These are
the different ways to deal with indexes in Microsoft Access tables.
Ms Access - Grouping Data
In this chapter, we will be covering how to calculate on a group of records in Access. We
have created a field that calculates row by row or record by record to create a line total or
subtotal field, but what if we wanted to calculate down by a group of records rather than
by individual ones. We can do this by creating what's known as an Aggregate Query.
Aggregate Query
An aggregate query also known as a totals or summary query is a sum, mass or group
particulars. It can be a total or gross amount or a group or subset of records. Aggregate
queries can perform a number of operations. Here's a simple table listing some of the
ways to total on a group of records.
S.No Aggregate Functions & Description
1. Sum
Adds the field values
2. Avg
Average of the field values
3. Min
Lowest (minimum) field value
4. Max
Highest (maximum) field value
5. Count
Count of the values (records)
6. StDev
Standard deviation of the field values including date/time fields
7. Var
Variance of the field values including date/time
Let us open your database and go to the Query Design and include the following tables −
Close this dialog box and the following two fields will be displayed as shown in the query
grid in the following screenshot.
This is a simple query and we are displaying only two fields — book
title and quantity and when we run it we're seeing every single individual order in our
database.
Let us now run this query and you will see the following results.
This is why book titles are repeating. Separate orders have been placed for each of these
books here and they were ordered in different quantities. Let us assume we want to see a
summary of only that book title that has been listed only once. And then the sum of the
quantity listed beside it.
Let us now go to the Design View and in the Design tab, you will see a Sigma symbol.
This is your totals button.
Click the sigma symbol which will open another row underneath your field in the table
row and from here, you can specify how you are grouping this query.
We will now group by book title and also sum our quantity field.
If we click on group by area and further click on the drop-down menu, all the options
will be listed down. In this case, we will choose the option Sum and then run your query.
You can now see each individual book and also all the individual orders displayed beside
the book name.
Concatenation in Access
We learned the process of normalization, storing information in separate fields.
Sometimes you want to see or view data together like combining the first name and last
name fields as a single field. You can display that information together by creating a
calculated field that concatenates one or more strings. You can also add other characters
like a comma or period that you may want.
To concatenate in Access, there are two different operators you can use
the ampersand (&) and the plus (+) sign.
The ampersand will combine two strings into one whereas the plus sign will combine
two strings and propagate NULL values, for example, if one value is NULL the
entire expression evaluates to null.
Example
Let us take a simple example to understand the process of creating a new query using
query design. This is going to be a very simple query that is pulling information from our
customers’ table.
Let us now add tblCustomers table close that show table dialog box. We will try some
concatenation with some simple named fields.
Let us now add the first name and last name fields and run the query.
As you can see, the first name and the last name are separated into two different fields.
We need to display this information together.
Go back to the Design View and in the third field create a new field called full name.
Now, add the full name and type the expression that concatenates those two fields
together.
Let us run the query and you will see a new calculated field.
It can concatenate the information from these two fields together, but it doesn't exactly
appear the way we want it to. It runs all of that text together because it's performing the
way we have asked it to. We will now have to ask Access to add space in between the
information from these two fields.
Let us now go back to the Design View and add another section to this expression.
Add a Space inside quotes and another ampersand. This makes Access take the
information from that first name field; add it with a space and then add the information
from the last name field at the very end. Now, run the query again and you will see the
following results.
Ms Access - Joins
A database is a collection of tables of data that allow logical relationships to each other.
You use relationships to connect tables by fields that they have in common. A table can
be part of any number of relationships, but each relationship always has exactly two
tables. In a query, a relationship is represented by a Join.
What is Join
A join specifies how to combine records from two or more tables in a database.
Conceptually, a join is very similar to a table relationship. In fact, joins are to queries
what relationships are to tables.
The following are the two basic types of joins that we will be discussing in this chapter −
The inner join
The outer join
You can create a Right Outer Join that will include all the rows from the second table.
Let us now go to the Create tab and create a query from the Design View.
Select tblProjects and tblTasks and close the Show Table dialog box as in the following
screenshot.
Add the ProjectName field from tblProjects, and TaskTitle,
StartDate and DueDate from tblTasks table.
Access will display the left table name and the right table name in Join Properties dialog.
The left column name and the right column name and the first radio button is to only
include rows where the join fields from both tables are equal and that is the inner
join and that is what is selected by default when creating relationships, when creating
a join in the query, but, you can change it.
We have two other options as well; we can include all records from tblProjects, and
only those records from tblTasks where the joined fields are equal and this one is
Left Outer Join.
We have a third option, include all records from tblTasks and only those records
from tblProjects where the joined fields are equal and this one is Right Outer Join.
Those are the different types of joins you can create easily from the Design View. Let us
select the second option, which is Left Outer Join, and click Ok.
Let us now look into the other steps −
When you look at the relationship line, you will see a little arrow pointing
towards ProjectID in tblTasks. When you run this query, you will see the following
results.
As you can see that it is showing us every single project name, whether or not it has a
related task. You will also see a bunch of null fields. All of this will be blank because
there is no related information in tblTasks, where these fields come from. Let us now go
to the Design View again and double-click on the relationship line.
In the Join Properties dialog box, select the third option which is for the Right Outer Join
and click Ok.
Now look at our relationship line. You will see that a little arrow is now pointing
towards ProjectID in tblProjects. When you run this query you will see the following
results.
Self-Joins
Self-join is another type of Join. A Self-join relates matching fields from within the same
table. For example, look at the employee's table with a supervisor field, which references
the same kind of number stored in another field within the same table — the employee ID.
If we wanted to know who Kaitlin Rasmussen's supervisor is, we will have to take the
number stored in that supervisor field and look it up within the exact same table in that
employee ID field in order to know that Charity Hendricks is the supervisor.
This table is not the ideal structure for a relational database because it's not normalized.
If we have a situation where we want to create a query that just lists the employee names
alongside the names of their supervisors, there is no easy way we can query that unless we
create a Self-join.
To see a Self-join, create a table with the following fields and enter some data.
Here we want to create a list again with the first name of the employee and then the name
of the supervisor. Let us create a query from the query design view.
Now, add tblEmployees tables.
We have created another copy of the same table in this query view. Now, we need to
create Self-join. To do that, click on Supervisor in tblEmployees table and hold the
mouse button and drop it right on top of the EmployeeID in that copied table
— tblEmployees_1. Then, add the first name and last name from that copied table.
Let us now run your query and you will see the following results.
It displays the names of the employees along side the names of their supervisors. And,
this is how you create a Self-join in Microsoft Access.
Ms Access - Duplicates Query Wizard
In this tutorial, we have created a variety of select queries, mainly from the Design View.
But in Access, we can make use of some special query wizards to create a couple of
specific select queries. The first one is Find Duplicates Query wizard. The Find
Duplicates Query Wizard will create a query that locates records with duplicate field
values in a single table or query.
As we have discussed that relational databases are designed to avoid storing duplicate
information. But despite that design, sometimes users accidentally enter duplicate
information.
Example
In a customer's table, you can have the same customer accidentally added twice. In such
cases, the customer will have the same address, but different customer IDs, which can
create problems with reporting. In this situation, you can make use of the duplicates
query wizard to quickly locate possible duplicate entries.
Let us now open our Access database which contains tblAuthers table and go
the Create tab and, in the queries group, select query wizard.
If you see the following screenshot, you have four different wizards to choose from.
Select the find duplicates query wizard and click Ok.
The very first screen of the find duplicates query wizard will ask what table or what query
you want to search for possible duplicates. Let us say we want to check our author's table
to make sure that the same author hasn't accidentally been entered twice. So, select
tblAuthors and click Next.
The second screen in the wizard will ask what fields might contain duplicate
information.
Typically, you will not be using your primary key field, because, again, when you
designate a field in Access as a primary key, Access will not allow duplicates to be
entered.
We will look at any other field or a combination of fields.
We can search by the last name or the first name and the last name, or you can search by
their street address, or to be more specific with their telephone number or birthday.
Let us now search by the first name, the last name, and birthday and click Next.
The following screen in this wizard will ask for the fields we want to be displayed in our
query. For this, hit the double arrow, all of the fields will move over to the additional
query fields area, and will be added to our query results.
Let us now click Next. It will take us to the last screen in this query wizard.
In the following screen, enter how do you want to name your query.
By default, it's going to name it find duplicates for plus whatever the name of the
object that you're querying. In this case, tblAuthors, but you can give it any other name
too and click finish.
Here, Access has found a possible duplicate, and that's going to be author Jose Caline
which has same birthday, same address, same telephone number but different AuthorIDs.
This one has definitely been entered twice by accident. We have now added all of the
fields to our query, we could just go and delete the record. We also have to make sure that
we don't have any related records in another table.
Select any record and choose Delete as in the following dialog box.
Access gives you a prompt, “You are about to delete one record.” Click Yes if you want
to continue.
If you'd like to see how that wizard has created this query, go into the Design View and
see what all has been added to this query.
As you can see in the above screenshot, we have our fields and some specific criteria
underneath the first name field.
This is how this wizard is looking for that duplicate information. It is by far the easiest
method to find duplicates.
Ms Access - Unmatched Query Wizard
In Access, there is another very useful wizard and that is Find Unmatched Query
Wizard. The Find Unmatched Query Wizard creates a query that finds records or rows in
one table that have no related records in another table.
As we have already discussed how data joins together in queries, and how most queries
are looking for the matches between two or more tables.
This is the default join in Access, for example, if we design a query with two
tables, tblCustomers and tblOrders, and join those two tables by the CustomerIDs,
this query will return only the results that match. In other words, the customers who
have placed orders.
There are times when we don't want to see the matches, for instance, we may not
want to see any customer in our database — the customers who have not placed
orders as yet.
In this scenario, we will look out for those customers who have not placed an order. In the
first screen it's asking which table or query contains the records you want in the query
results.
We now want a list of customers from tblCustomers. Select that option and click Next.
In the following screen, you need to specify which table or query contains the related
records. In other words, what table are you using to compare with the first one. For this,
we need to find the ones that have not placed orders. We need to select the table that
contains information on all orders — tblOrders. Now, click Next.
In the following screen, you need to specify which piece of information is in both tables.
This will typically be some kind of primary key, foreign key, field, or relationship.
If you have an existing relationship in your database, Access will select and match
Let us now select all the available fields and click on the double-headed arrow. This
moves all the available fields over to the selected fields area. Now, click Next.
The last screen will allow you to choose a name for your query and click Finish.
©SAYANTAN BERA
Here we have one customer listed as that customer who has not placed an order with us
yet.
You can also see how that query was created. For this, you need to go back to the Design
View.
This wizard has created an Outer Join between tblCustomer and tblOrders and the Is
Null criteria is added to the CustID from tblORders. This is to exclude certain records. In
this case, it is the customers who have placed orders, or who have related information in
tblOrders.
Ms Access - Create Form
Forms in Access are like display cases in stores that make it easier to view or get the
items that you want. Since forms are objects through which you or other users can add,
edit, or display the data stored in your Access desktop database, the design of your form is
an important aspect. There's a lot you can do design-wise with forms in Microsoft Access.
You can create two basic types of forms −
Bound forms
Unbound forms
Bound Forms
Let us now understand what Bound Forms are −
Bound forms are connected to some underlying data source such as a table, query, or
SQL statement.
Bound forms are what people typically think of when they think of the purpose of a
form.
Forms are to be filled out or used to enter or edit data in a database.
Examples of bound forms will typically be what users use to enter, view or edit data
in a database.
Unbound Forms
Let us look into Unbound Forms −
These forms are not connected to an underlying record or data source.
Unbound forms could be dialog boxes, switch boards, or navigation forms.
In other words, unbound forms are typically used to navigate or interact with the
database at large, as opposed to the data itself.
Types of Bound Forms
There are many types of bound forms you can create in Access. Let us understand the
types −
Single Item Form
This is the most popular one and this is where the records are displayed — one record at a
time.
Multiple Item Form
This displays multiple records at a time from that bound data source.
Split Form
The form is divided into halves, either vertically or horizontally. One half displays a
single item or record, and the other half displays a list or provides a datasheet view of
multiple records from the underlying data source.
Creating Forms
There are a few methods you can use to create forms in Access. For this, open your
Database and go to the Create tab. In the Forms group, in the upper right-hand corner
you will see the Form Wizard button.
Click on that button to launch the Form Wizard.
On this first screen in the wizard, you can select fields that you want to display on your
form, and you can choose from fields from more than one table or a query.
Let us assume we want to simply have a quick form that we are going to use for data entry
for our employee information.
From Tables/Queries drop-down list, select tblEmployees table. Click on the double
arrow to move all the fields at once.
Let us just leave it with that one table, and click Next.
The following screen in the Form Wizard will ask for the layout that we would like for
our form. We have columnar, tabular, datasheet and justified layouts. We will choose
the columnar layout here and then click Next.
In the following screen, we need to give a title for our form. Let us call it frmEmployees.
Once you have given your form a title, you can open the form to see what that form looks
like, or you can begin entering information into your table. Or you can choose the option
to modify the form's design. Let us choose the first option to open the form to view or
enter information and click Finish.
Now, take a look at the following screenshot. This is what your form looks like. This is a
single item form, meaning one record is displayed at a time and further down you can see
the navigation buttons, which is telling us that this is displaying the record 1 of 9. If you
click on that button then, it will move to the next record.
If you want to jump to the very last record in that form or that table, you can use the
button right beside that right arrow, the arrow with a line after it, that's the last record
button. If you want to add new employee information, go to the end of this records and
then after 9 records you will see a blank form where you can begin entering out the new
employee's information.
This is one example of how you can create a form using the Form Wizard. Let us now
close this form and go to the Create tab. Now we will create a slightly more complicated
form using Wizard. Click the Form Wizard and this time, we will choose fields from a
couple of different tables.
In this Form Wizard, let us choose tblProjects for Tables/Queries, and select a few
Available Fields such as ProjectID, ProjectName, ProjectStart, and ProjectEnd. These
fields will now move to Selected Fields.
Now select tblTasks for Tables/Queries and send over the TaskID, ProjectID, TaskTitle,
StartDate, DueDate and PercentComplete. Click Next.
Here, we want to retrieve data from a couple of different objects. We can also choose
from options on how we want to arrange our form. If we want to create a flat form, we
can choose to arrange by tblTasks, which will create that single form, with all the fields
laid out in flat view as shown above.
However, if we want to create a hierarchical form based on that one-to-many relationship,
we can choose to arrange our data by tblProjects.
In the above window, we have the option to include a subform for tblTasks, or we can
make that a linked form. This linked form is where tblProjects will have a button that will
launch that second form filtered to the project that we have selected in that underlying
projects form. Let us now select the Form with subform(s), and then click Next.
In the following screen, you can choose a layout for your subform. The Datasheet View
gets selected by default. The Datasheet View is similar to Table View. Now, click Next.
In the following screen, you need to provide a name for your forms. Enter the name you
want and click Finish.
Access will give you a preview of what your form looks like. On top, you have the
controls on your main form, which is from our Projects table. As you go down, you will
see a subform. It's like a form within a form.
We will now look at the different aspects of making a form presentable and understand
how to edit and modify a form. Let us now open our Multiple Items form which lists out
all employees from tnlEmployees.
As you can see a list of employees, but doesn't really look like a very user friendly list.
Our controls are oversized. They are too big, spaced apart and do not provide a very
useful list view.
To edit the appearance of your controls on this form, you have two form views that you
can use. In the Home tab, click the View drop-down.
You have the Layout View or the Design View, and both of these views are used to edit
your form. The Form View opens up by default; this is the view you will use to interact
with or edit the underlying data source.
To edit the appearance of the form itself, we need to go to the Layout View first.
When you switch to the Layout View, you will see a series of contextual tabs appear.
At the top of Access, you will see an area marked Form Layout Tools with three tabs —
Design tab, an Arrange tab, and a Format tab and each of these tabs have different options
for formatting the look or appearance of the form.
When you take your mouse and click on any one of these controls, you will notice that
Access will highlight a given area of that form and all controls within that area are shaded
a light orange whereas the actual control that you select will be shaded darker than the
previous one or have a darker orange border around where you click.
Here you can resize your controls as you want by clicking and dragging your mouse to
resize the height or width or both of that one control.
On this particular form, when you resize any single control, you also change the size of
the rest of your controls on your form, this is because of how these controls are grouped.
Let us now adjust all the fields the way you want by using the click and drag function of
the mouse.
That is one quick way of editing the height and width of controls in your form from this
Layout View.
Themes
In Access, there are some basic ways to format your forms by using built-in themes,
colors, and font styles, customizing fill colors and shading alternate rows. Let us now
open frmEmployees.
The forms that Access creates are plain and simple. They have a blue bar on the top and a
white background.
If you want to see how else you can stylize these forms, you can go to the Design View or
Layout View and explore some of the options you have on the Design tab in the Themes
area.
If you click on the Themes' drop-down gallery, you have many pre-created themes to try
out from. Hovering your mouse over any one of them will give you a preview of changing
things like colors and font sizes and the actual font used. To apply a particular style,
simply click your mouse on it and you can see what that looks like.
If you like the theme but you want to change the colors, you can adjust the colors by
going back to the Themes group on the Design tab and choosing the color you like. You
can also create custom colors to match your company's colors.
Similarly, you also have a series of font styles to choose from. You can choose one from
the many that come prebuilt with the Office Suite or you can customize those fonts,
choosing a specific heading font, a body font and even creating a custom name for that
font group and saving.
Let us go back to frmEmployees. In this form, you will see that every alternate row is
shaded light gray.
The formatting option is referred to as Alternate Row Color and if you want to adjust
that in a multiple form, go to the Design View.
Select that detail section and then go to the Format tab and in background group you
should see an option for Alternate Row Color. You can change the colors for alternate
rows. To see what that looks like, simply go to the Form View or the Layout View.
If you don't want any shading at all, you can choose No Color as your Alternate Row
Color and that is more the traditional look from earlier versions of Access.
Ms Access - Navigation Form
Access includes a Navigation Control that makes it easy to switch between various forms
and reports in your database. A navigation form is simply a form that contains a
Navigation Control. Navigation forms are a great addition to any desktop database.
Microsoft Access offers several features for controlling how users navigate the
database.
We have already used navigation pane to navigate through all of the Access objects
we create, such as forms, queries, tables, etc.
If you want to create your own navigational structure and make it easier for the users
to find the specific objects that they really need, you can build navigation form,
which is a form that uses a navigation control so users can use or view forms and
reports right from within that main navigation form.
Example
Let us now take a simple example in which we will create the navigation form. For this,
go to the Create tab; in the Forms group, you will see this navigation drop-down menu.
In this menu, you will see different layouts for how to arrange your forms and reports that
you would like to embed on this navigation form.
There is one with horizontal tabs, one with vertical tabs — where all the tabs are
aligned to the left, a vertical tabs layout where all the tabs are aligned to the right.
There is a horizontal tabs layout that has two levels to it, so if you have a lot of
objects that you want to display across the top, you can make use of this.
You can have one where you have both horizontal tabs and vertical tabs, either
aligned to the left or to the right.
In the following example, we will be using Horizontal Tabs and Vertical Tabs. To create
that layout or that navigation form, simply click on it, and Access will create an unbound
form, with a navigation control on it.
To add objects to this navigation form, the easiest way to do is through your layout view,
by simply dragging and dropping objects to where you want them to appear.
Let us now drag frmProjects form from the navigation pane and drop it on the [Add
New] on the top.
Similarly, drag frmAuthers form from the navigation pane and drop it to the left of the
Add New Button.
Now, you will see that your other project buttons have disappeared from the left and that
is because they are attached to Project tab. All the buttons you view on the left are linked
to whatever you have selected up the top. Now with the Employee tab selected, let us drag
employees-related information to the left.
Now we have project information on one tab, employee information on the other.
Similarly, you can add more tabs as per your requirements. As you can see that the name
of the tabs is not appropriate, so let us start renaming some of these tabs to make them
more user-friendly. The easiest way is to double-click on any tab or any button on the left
and rename it as shown in the following screenshot.
HTML stands for Hyper Text Markup Language, which is the most widely used
language on Web to develop web pages. HTML was created by Berners-Lee in late 1991
but "HTML 2.0" was the first standard HTML specification which was published in 1995.
HTML 4.01 was a major version of HTML and it was published in late 1999. Though
HTML 4.01 version is widely used but currently we are having HTML-5 version which is
an extension to HTML 4.01, and this version was published in 2012.
Why to Learn HTML?
Originally, HTML was developed with the intent of defining the structure of documents
like headings, paragraphs, lists, and so forth to facilitate the sharing of scientific
information between researchers. Now, HTML is being widely used to format web pages
with the help of different tags available in HTML language.
HTML is a MUST for students and working professionals to become a great Software
Engineer specially when they are working in Web Development Domain. I will list down
some of the key advantages of learning HTML:
Create Web site - You can create a website or customize an existing web template if
you know HTML well.
Become a web designer - If you want to start a carrer as a professional web
designer, HTML and CSS designing is a must skill.
Understand web - If you want to optimize your website, to boost its speed and
performance, it is good to know HTML to yield best results.
Learn other languages - Once you understands the basic of HTML then other
related technologies like javascript, php, or angular are become easier to understand.
Hello World using HTML.
Just to give you a little excitement about HTML, I'm going to give you a small
conventional HTML Hello World program, You can try it using Demo link.
<!DOCTYPE html>
<html>
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Hello World!</p>
</body>
</html>
Applications of HTML
As mentioned before, HTML is one of the most widely used language over the web. I'm
going to list few of them here:
Web pages development - HTML is used to create pages which are rendered over
the web. Almost every page of web is having html tags in it to render its details in
browser.
Internet Navigation - HTML provides tags which are used to navigate from one
page to another and is heavily used in internet navigation.
Responsive UI - HTML pages now-a-days works well on all platform, mobile, tabs,
desktop or laptops owing to responsive design strategy.
Offline support HTML pages once loaded can be made available offline on the
machine without any need of internet.
Game development- HTML5 has native support for rich experience and is now
useful in gaming developent arena as well.
Audience
This HTML tutorial is designed for the aspiring Web Designers and Developers with a
need to understand the HTML in enough detail along with its simple overview, and
practical examples. This tutorial will give you enough ingredients to start with HTML
from where you can take yourself at higher level of expertise.
Prerequisites
Before proceeding with this tutorial you should have a basic working knowledge with
Windows or Linux operating system, additionally you must be familiar with −
Experience with any text editor like notepad, notepad++, or Edit plus etc.
How to create directories and files on your computer.
HTML stands for Hypertext Markup Language, and it is the most widely used language
to write Web Pages.
Hypertext refers to the way in which Web pages (HTML documents) are linked
together. Thus, the link available on a webpage is called Hypertext.
As its name suggests, HTML is a Markup Language which means you use HTML
to simply "mark-up" a text document with tags that tell a Web browser how to
structure it to display.
Originally, HTML was developed with the intent of defining the structure of documents
like headings, paragraphs, lists, and so forth to facilitate the sharing of scientific
information between researchers.
Now, HTML is being widely used to format web pages with the help of different tags
available in HTML language.
Basic HTML Document
In its simplest form, following is an example of an HTML document −
<!DOCTYPE html>
<html>
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
</body>
</html>
HTML Tags
As told earlier, HTML is a markup language and makes use of various tags to format the
content. These tags are enclosed within angle braces <Tag Name>. Except few tags, most
of the tags have their corresponding closing tags. For example, <html> has its closing
tag </html> and <body> tag has its closing tag </body> tag etc.
Above example of HTML document uses the following tags −
Sr.N Tag & Description
o
1 <!DOCTYPE...>
This tag defines the document type and HTML version.
2 <html>
This tag encloses the complete HTML document and mainly
comprises of document header which is represented by
<head>...</head> and document body which is represented by
<body>...</body> tags.
3 <head>
This tag represents the document's header which can keep other
HTML tags like <title>, <link> etc.
4 <title>
The <title> tag is used inside the <head> tag to mention the
document title.
5 <body>
This tag represents the document's body which keeps other
HTML tags like <h1>, <div>, <p> etc.
6 <h1>
This tag represents the heading.
7 <p>
This tag represents a paragraph.
To learn HTML, you will need to study various tags and understand how they behave,
while formatting a textual document. Learning HTML is simple as users have to learn the
usage of different tags in order to format the text or images to make a beautiful webpage.
World Wide Web Consortium (W3C) recommends to use lowercase tags starting from
HTML 4.
HTML Document Structure
A typical HTML document will have the following structure −
<html>
<head>
Document header related tags
</head>
<body>
Document body related tags
</body>
</html>
We will study all the header and body tags in subsequent chapters, but for now let's see
what is document declaration tag.
The <!DOCTYPE> Declaration
The <!DOCTYPE> declaration tag is used by the web browser to understand the version
of the HTML used in the document. Current version of HTML is 5 and it makes use of the
following declaration −
<!DOCTYPE html>
There are many other declaration types which can be used in HTML document depending
on what version of HTML is being used. We will see more details on this while
discussing <!DOCTYPE...> tag along with other HTML tags.
Heading Tags
Any document starts with a heading. You can use different sizes for your headings.
HTML also has six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>,
<h5>, and <h6>. While displaying any heading, browser adds one line before and one
line after that heading.
Example
<!DOCTYPE html>
<html>
<head>
<title>Heading Example</title>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
This will produce the following result −
Paragraph Tag
The <p> tag offers a way to structure your text into different paragraphs. Each paragraph
of text should go in between an opening <p> and a closing </p> tag as shown below in the
example −
Example
<!DOCTYPE html>
<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
This will produce the following result −
Line Break Tag
Whenever you use the <br /> element, anything following it starts from the next line.
This tag is an example of an empty element, where you do not need opening and closing
tags, as there is nothing to go in between them.
The <br /> tag has a space between the characters br and the forward slash. If you omit
this space, older browsers will have trouble rendering the line break, while if you miss the
forward slash character and just use <br> it is not valid in XHTML.
Example
<!DOCTYPE html>
<html>
<head>
<title>Line Break Example</title>
</head>
<body>
<p>Hello<br />
You delivered your assignment ontime.<br />
Thanks<br />
Mahnaz</p>
</body>
</html>
This will produce the following result −
Centering Content
You can use <center> tag to put any content in the center of the page or any table cell.
Example
<!DOCTYPE html>
<html>
<head>
<title>Centring Content Example</title>
</head>
<body>
<p>This text is not in the center.</p>
<center>
<p>This text is in the center.</p>
</center>
</body>
</html>
This will produce following result −
Horizontal Lines
Horizontal lines are used to visually break-up sections of a document. The <hr> tag
creates a line from the current position in the document to the right margin and breaks the
line accordingly.
For example, you may want to give a line between two paragraphs as in the given
example below −
Example
<!DOCTYPE html>
<html>
<head>
<title>Horizontal Line Example</title>
</head>
<body>
<p>This is paragraph one and should be on top</p>
<hr />
<p>This is paragraph two and should be at bottom</p>
</body>
</html>
This will produce the following result −
Again <hr /> tag is an example of the empty element, where you do not need opening
and closing tags, as there is nothing to go in between them.
The <hr /> element has a space between the characters hr and the forward slash. If you
omit this space, older browsers will have trouble rendering the horizontal line, while if
you miss the forward slash character and just use <hr> it is not valid in XHTML
Preserve Formatting
Sometimes, you want your text to follow the exact format of how it is written in the
HTML document. In these cases, you can use the preformatted tag <pre>.
Any text between the opening <pre> tag and the closing </pre> tag will preserve the
formatting of the source document.
Example
<!DOCTYPE html>
<html>
<head>
<title>Preserve Formatting Example</title>
</head>
<body>
<pre>
function testFunction( strText ){
alert (strText)
}
</pre>
</body>
</html>
This will produce the following result −
Try using the same code without keeping it inside <pre>...</pre> tags
Nonbreaking Spaces
Suppose you want to use the phrase "12 Angry Men." Here, you would not want a
browser to split the "12, Angry" and "Men" across two lines −
An example of this technique appears in the movie "12 Angry Men."
In cases, where you do not want the client browser to break text, you should use a
nonbreaking space entity instead of a normal space. For example, when coding
the "12 Angry Men" in a paragraph, you should use something similar to the following
code −
Example
<!DOCTYPE html>
<html>
<head>
<title>Nonbreaking Spaces Example</title>
</head>
<body>
<p>An example of this technique appears in the movie
"12 Angry Men."</p>
</body>
</html>
This will produce the following result −
An example of this technique appears in the movie "12 Angry Men."
An HTML element is defined by a starting tag. If the element contains other content, it
ends with a closing tag, where the element name is preceded by a forward slash as shown
below with few tags −
Start Tag Content End Tag
<br />
<!DOCTYPE html>
<html>
<head>
<title>Nested Elements Example</title>
</head>
<body>
<h1>This is <i>italic</i> heading</h1>
<p>This is <u>underlined</u> paragraph</p>
</body>
</html>
This will display the following result −
This is italic heading
<!DOCTYPE html>
<html>
<head>
<title>Bold Text Example</title>
</head>
<body>
<p>The following word uses a <b>bold</b> typeface.</p>
</body>
</html>
This will produce the following result −
Italic Text
Anything that appears within <i>...</i> element is displayed in italicized as shown below
−
Example
<!DOCTYPE html>
<html>
<head>
<title>Italic Text Example</title>
</head>
<body>
<p>The following word uses an <i>italicized</i> typeface.</p>
</body>
</html>
This will produce the following result −
Underlined Text
Anything that appears within <u>...</u> element, is displayed with underline as shown
below −
Example
<!DOCTYPE html>
<html>
<head>
<title>Underlined Text Example</title>
</head>
<body>
<p>The following word uses an <u>underlined</u> typeface.</p>
</body>
</html>
This will produce the following result −
Strike Text
Anything that appears within <strike>...</strike> element is displayed with
strikethrough, which is a thin line through the text as shown below −
Example
<!DOCTYPE html>
<html>
<head>
<title>Strike Text Example</title>
</head>
<body>
<p>The following word uses a <strike>strikethrough</strike> typeface.</p>
</body>
</html>
This will produce the following result −
Monospaced Font
The content of a <tt>...</tt> element is written in monospaced font. Most of the fonts are
known as variable-width fonts because different letters are of different widths (for
example, the letter 'm' is wider than the letter 'i'). In a monospaced font, however, each
letter has the same width.
Example
<!DOCTYPE html>
<html>
<head>
<title>Monospaced Font Example</title>
</head>
<body>
<p>The following word uses a <tt>monospaced</tt> typeface.</p>
</body>
</html>
This will produce the following result −
Superscript Text
The content of a <sup>...</sup> element is written in superscript; the font size used is the
same size as the characters surrounding it but is displayed half a character's height above
the other characters.
Example
<!DOCTYPE html>
<html>
<head>
<title>Superscript Text Example</title>
</head>
<body>
<p>The following word uses a <sup>superscript</sup> typeface.</p>
</body>
</html>
This will produce the following result −
Subscript Text
The content of a <sub>...</sub> element is written in subscript; the font size used is the
same as the characters surrounding it, but is displayed half a character's height beneath the
other characters.
Example
<!DOCTYPE html>
<html>
<head>
<title>Subscript Text Example</title>
</head>
<body>
<p>The following word uses a <sub>subscript</sub> typeface.</p>
</body>
</html>
This will produce the following result −
Inserted Text
Anything that appears within <ins>...</ins> element is displayed as inserted text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Inserted Text Example</title>
</head>
<body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
</body>
</html>
This will produce the following result −
Deleted Text
Anything that appears within <del>...</del> element, is displayed as deleted text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Deleted Text Example</title>
</head>
<body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
</body>
</html>
This will produce the following result −
Larger Text
The content of the <big>...</big> element is displayed one font size larger than the rest of
the text surrounding it as shown below −
Example
<!DOCTYPE html>
<html>
<head>
<title>Larger Text Example</title>
</head>
<body>
<p>The following word uses a <big>big</big> typeface.</p>
</body>
</html>
This will produce the following result −
Smaller Text
The content of the <small>...</small> element is displayed one font size smaller than the
rest of the text surrounding it as shown below −
Example
<!DOCTYPE html>
<html>
<head>
<title>Smaller Text Example</title>
</head>
<body>
<p>The following word uses a <small>small</small> typeface.</p>
</body>
</html>
This will produce the following result −
Grouping Content
The <div> and <span> elements allow you to group together several elements to create
sections or subsections of a page.
For example, you might want to put all of the footnotes on a page within a <div> element
to indicate that all of the elements within that <div> element relate to the footnotes. You
might then attach a style to this <div> element so that they appear using a special set of
style rules.
Example
<!DOCTYPE html>
<html>
<head>
<title>Div Tag Example</title>
</head>
<body>
<div id = "menu" align = "middle" >
<a href = "/index.htm">HOME</a> |
<a href = "/about/contact_us.htm">CONTACT</a> |
<a href = "/about/index.htm">ABOUT</a>
</div>
<!DOCTYPE html>
<html>
<head>
<title>Span Tag Example</title>
</head>
<body>
<p>This is the example of <span style = "color:green">span tag</span>
and the <span style = "color:red">div tag</span> alongwith CSS</p>
</body>
</html>
INTRODUCTION TO C PROGRAMMING
C programming is a general-purpose, procedural, imperative computer programming
language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to
develop the UNIX operating system. C is the most widely used computer language. It
keeps fluctuating at number one scale of popularity along with Java programming
language, which is also equally popular and most widely used among modern software
programmers.
Why to Learn C Programming?
C programming language is a MUST for students and working professionals to become
a great Software Engineer specially when they are working in Software Development
Domain. I will list down some of the key advantages of learning C Programming:
Easy to learn
Structured language
It produces efficient programs
It can handle low-level activities
It can be compiled on a variety of computer platforms
Facts about C
C was invented to write an operating system called UNIX.
C is a successor of B language which was introduced around the early 1970s.
The language was formalized in 1988 by the American National Standard Institute
(ANSI).
The UNIX OS was totally written in C.
Today C is the most widely used and popular System Programming Language.
Most of the state-of-the-art software have been implemented using C.
Hello World using C Programming.
Just to give you a little excitement about C programming, I'm going to give you a small
conventional C Programming Hello World program, You can try it using Demo link.
#include <stdio.h>
int main() {
/* my first program in C */
printf("Hello, World! \n");
return 0;
}
Applications of C Programming
C was initially used for system development work, particularly the programs that make-up
the operating system. C was adopted as a system development language because it
produces code that runs nearly as fast as the code written in assembly language. Some
examples of the use of C are -
Operating Systems
Language Compilers
Assemblers
Text Editors
Print Spoolers
Network Drivers
Modern Programs
Databases
Language Interpreters
Utilities
Audience
This tutorial is designed for software programmers with a need to understand the C
programming language starting from scratch. This C tutorial will give you enough
understanding on C programming language from where you can take yourself to higher
level of expertise.
Prerequisites
Before proceeding with this tutorial, you should have a basic understanding of Computer
Programming terminologies. A basic understanding of any of the programming languages
will help you in understanding the C programming concepts and move fast on the
learning track.
C is a general-purpose, high-level language that was originally developed by Dennis M.
Ritchie to develop the UNIX operating system at Bell Labs. C was originally first
implemented on the DEC PDP-11 computer in 1972.
In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available
description of C, now known as the K&R standard.
The UNIX operating system, the C compiler, and essentially all UNIX application
programs have been written in C. C has now become a widely used professional language
for various reasons −
Easy to learn
Structured language
It produces efficient programs
It can handle low-level activities
It can be compiled on a variety of computer platforms
Facts about C
C was invented to write an operating system called UNIX.
C is a successor of B language which was introduced around the early 1970s.
The language was formalized in 1988 by the American National Standard Institute
(ANSI).
The UNIX OS was totally written in C.
Today C is the most widely used and popular System Programming Language.
Most of the state-of-the-art software have been implemented using C.
Today's most popular Linux OS and RDBMS MySQL have been written in C.
Why use C?
C was initially used for system development work, particularly the programs that make-up
the operating system. C was adopted as a system development language because it
produces code that runs nearly as fast as the code written in assembly language. Some
examples of the use of C might be −
Operating Systems
Language Compilers
Assemblers
Text Editors
Print Spoolers
Network Drivers
Modern Programs
Databases
Language Interpreters
Utilities
C Programs
A C program can vary from 3 lines to millions of lines and it should be written into one or
more text files with extension ".c"; for example, hello.c. You can use "vi", "vim" or any
other text editor to write your C program into a file.
This tutorial assumes that you know how to edit a text file and how to write source code
inside a program file.
If you want to set up your environment for C programming language, you need the
following two software tools available on your computer, (a) Text Editor and (b) The C
Compiler.
Text Editor
This will be used to type your program. Examples of few a editors include Windows
Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi.
The name and version of text editors can vary on different operating systems. For
example, Notepad will be used on Windows, and vim or vi can be used on windows as
well as on Linux or UNIX.
The files you create with your editor are called the source files and they contain the
program source codes. The source files for C programs are typically named with the
extension ".c".
Before starting your programming, make sure you have one text editor in place and you
have enough experience to write a computer program, save it in a file, compile it and
finally execute it.
The C Compiler
The source code written in source file is the human readable source for your program. It
needs to be "compiled", into machine language so that your CPU can actually execute the
program as per the instructions given.
The compiler compiles the source codes into final executable programs. The most
frequently used and free available compiler is the GNU C/C++ compiler, otherwise you
can have compilers either from HP or Solaris if you have the respective operating
systems.
The following section explains how to install GNU C/C++ compiler on various OS. We
keep mentioning C/C++ together because GNU gcc compiler works for both C and C++
programming languages.
Installation on UNIX/Linux
If you are using Linux or UNIX, then check whether GCC is installed on your system by
entering the following command from the command line −
$ gcc -v
If you have GNU compiler installed on your machine, then it should print a message as
follows −
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr .......
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
If GCC is not installed, then you will have to install it yourself using the detailed
instructions available at https://gcc.gnu.org/install/
This tutorial has been written based on Linux and all the given examples have been
compiled on the Cent OS flavor of the Linux system.
Installation on Mac OS
If you use Mac OS X, the easiest way to obtain GCC is to download the Xcode
development environment from Apple's web site and follow the simple installation
instructions. Once you have Xcode setup, you will be able to use GNU compiler for C/C+
+.
Xcode is currently available at developer.apple.com/technologies/tools/.
Installation on Windows
To install GCC on Windows, you need to install MinGW. To install MinGW, go to the
MinGW homepage, www.mingw.org, and follow the link to the MinGW download page.
Download the latest version of the MinGW installation program, which should be named
MinGW-<version>.exe.
While installing Min GW, at a minimum, you must install gcc-core, gcc-g++, binutils, and
the MinGW runtime, but you may wish to install more.
Add the bin subdirectory of your MinGW installation to your PATH environment
variable, so that you can specify these tools on the command line by their simple names.
After the installation is complete, you will be able to run gcc, g++, ar, ranlib, dlltool, and
several other GNU tools from the Windows command line.
Before we study the basic building blocks of the C programming language, let us look at a
bare minimum C program structure so that we can take it as a reference in the upcoming
chapters.
Hello World Example
A C program basically consists of the following parts −
Preprocessor Commands
Functions
Variables
Comments
Let us look at a simple code that would print the words "Hello World" −
#include <stdio.h>
int main() {
/* my first program in C */
printf("Hello, World! \n");
return 0;
}
Let us take a look at the various parts of the above program −
The first line of the program #include <stdio.h> is a preprocessor command, which
tells a C compiler to include stdio.h file before going to actual compilation.
The next line int main() is the main function where the program execution begins.
The next line /*...*/ will be ignored by the compiler and it has been put to add
additional comments in the program. So such lines are called comments in the
program.
The next line printf(...) is another function available in C which causes the message
"Hello, World!" to be displayed on the screen.
The next line return 0; terminates the main() function and returns the value 0.
Compile and Execute C Program
Let us see how to save the source code in a file, and how to compile and run it. Following
are the simple steps −
Open a text editor and add the above-mentioned code.
Save the file as hello.c
Open a command prompt and go to the directory where you have saved the file.
Type gcc hello.c and press enter to compile your code.
If there are no errors in your code, the command prompt will take you to the next line
and would generate a.out executable file.
Now, type a.out to execute your program.
You will see the output "Hello World" printed on the screen.
$ gcc hello.c
$ ./a.out
Hello, World!
Make sure the gcc compiler is in your path and that you are running it in the directory
containing the source file hello.c.
You have seen the basic structure of a C program, so it will be easy to understand other
basic building blocks of the C programming language.
Tokens in C
A C program consists of various tokens and a token is either a keyword, an identifier, a
constant, a string literal, or a symbol. For example, the following C statement consists of
five tokens −
printf("Hello, World! \n");
The individual tokens are −
printf
(
"Hello, World! \n"
)
;
Semicolons
In a C program, the semicolon is a statement terminator. That is, each individual
statement must be ended with a semicolon. It indicates the end of one logical entity.
Given below are two different statements −
printf("Hello, World! \n");
return 0;
Comments
Comments are like helping text in your C program and they are ignored by the compiler.
They start with /* and terminate with the characters */ as shown below −
/* my first program in C */
You cannot have comments within comments and they do not occur within a string or
character literals.
Identifiers
A C identifier is a name used to identify a variable, function, or any other user-defined
item. An identifier starts with a letter A to Z, a to z, or an underscore '_' followed by zero
or more letters, underscores, and digits (0 to 9).
C does not allow punctuation characters such as @, $, and % within identifiers. C is
a case-sensitive programming language. Thus, Manpower and manpower are two
different identifiers in C. Here are some examples of acceptable identifiers −
mohd zara abc move_name a_123
myname50 _temp j a23b9 retVal
Keywords
The following list shows the reserved words in C. These reserved words may not be used
as constants or variables or any other identifier names.
auto else long switch
break enum register typedef
double
Whitespace in C
A line containing only whitespace, possibly with a comment, is known as a blank line,
and a C compiler totally ignores it.
Whitespace is the term used in C to describe blanks, tabs, newline characters and
comments. Whitespace separates one part of a statement from another and enables the
compiler to identify where one element in a statement, such as int, ends and the next
element begins. Therefore, in the following statement −
int age;
there must be at least one whitespace character (usually a space) between int and age for
the compiler to be able to distinguish them. On the other hand, in the following statement
−
fruit = apples + oranges; // get the total fruit
no whitespace characters are necessary between fruit and =, or between = and apples,
although you are free to include some if you wish to increase readability.
Data types in c refer to an extensive system used for declaring variables or functions of
different types. The type of a variable determines how much space it occupies in storage
and how the bit pattern stored is interpreted.
The types in C can be classified as follows −
Sr.No Types & Description
.
1 Basic Types
They are arithmetic types and are further classified into: (a)
integer types and (b) floating-point types.
2 Enumerated types
They are again arithmetic types and they are used to define
variables that can only assign certain discrete integer values
throughout the program.
4 Derived types
They include (a) Pointer types, (b) Array types, (c) Structure
types, (d) Union types and (e) Function types.
The array types and structure types are referred collectively as the aggregate types. The
type of a function specifies the type of the function's return value. We will see the basic
types in the following section, where as other types will be covered in the upcoming
chapters.
Integer Types
The following table provides the details of standard integer types with their storage sizes
and value ranges −
Type Storage size Value range
To get the exact size of a type or a variable on a particular platform, you can use
the sizeof operator. The expressions sizeof(type) yields the storage size of the object or
type in bytes. Given below is an example to get the size of various type on a machine
using different constant defined in limits.h header file −
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <float.h>
return 0;
}
When you compile and execute the above program, it produces the following result on
Linux −
CHAR_BIT : 8
CHAR_MAX : 127
CHAR_MIN : -128
INT_MAX : 2147483647
INT_MIN : -2147483648
LONG_MAX : 9223372036854775807
LONG_MIN : -9223372036854775808
SCHAR_MAX : 127
SCHAR_MIN : -128
SHRT_MAX : 32767
SHRT_MIN : -32768
UCHAR_MAX : 255
UINT_MAX : 4294967295
ULONG_MAX : 18446744073709551615
USHRT_MAX : 65535
Floating-Point Types
The following table provide the details of standard floating-point types with storage sizes
and value ranges and their precision −
Type Storage size Value range Precision
The header file float.h defines macros that allow you to use these values and other details
about the binary representation of real numbers in your programs. The following example
prints the storage space taken by a float type and its range values −
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <float.h>
int main(int argc, char** argv) {
return 0;
}
When you compile and execute the above program, it produces the following result on
Linux −
Storage size for float : 4
FLT_MAX : 3.40282e+38
FLT_MIN : 1.17549e-38
-FLT_MAX : -3.40282e+38
-FLT_MIN : -1.17549e-38
DBL_MAX : 1.79769e+308
DBL_MIN : 2.22507e-308
-DBL_MAX : -1.79769e+308
Precision value: 6
The void Type
The void type specifies that no value is available. It is used in three kinds of situations −
Sr.No Types & Description
.
3 Pointers to void
A pointer of type void * represents the address of an object, but
not its type. For example, a memory allocation function void
*malloc( size_t size ); returns a pointer to void which can be
casted to any data type.
A variable is nothing but a name given to a storage area that our programs can
manipulate. Each variable in C has a specific type, which determines the size and layout
of the variable's memory; the range of values that can be stored within that memory; and
the set of operations that can be applied to the variable.
The name of a variable can be composed of letters, digits, and the underscore character. It
must begin with either a letter or an underscore. Upper and lowercase letters are distinct
because C is case-sensitive. Based on the basic types explained in the previous chapter,
there will be the following basic variable types −
Sr.No. Type & Description
1 char
Typically a single octet(one byte). It is an integer type.
2 int
The most natural size of integer for the machine.
3 float
A single-precision floating point value.
4 double
A double-precision floating point value.
5 void
Represents the absence of type.
C programming language also allows to define various other types of variables, which we
will cover in subsequent chapters like Enumeration, Pointer, Array, Structure, Union, etc.
For this chapter, let us study only basic variable types.
Variable Definition in C
A variable definition tells the compiler where and how much storage to create for the
variable. A variable definition specifies a data type and contains a list of one or more
variables of that type as follows −
type variable_list;
Here, type must be a valid C data type including char, w_char, int, float, double, bool, or
any user-defined object; and variable_list may consist of one or more identifier names
separated by commas. Some valid declarations are shown here −
int i, j, k;
char c, ch;
float f, salary;
double d;
The line int i, j, k; declares and defines the variables i, j, and k; which instruct the
compiler to create variables named i, j and k of type int.
Variables can be initialized (assigned an initial value) in their declaration. The initializer
consists of an equal sign followed by a constant expression as follows −
type variable_name = value;
Some examples are −
extern int d = 3, f = 5; // declaration of d and f.
int d = 3, f = 5; // definition and initializing d and f.
byte z = 22; // definition and initializes z.
char x = 'x'; // the variable x has the value 'x'.
For definition without an initializer: variables with static storage duration are implicitly
initialized with NULL (all bytes have the value 0); the initial value of all other variables
are undefined.
Variable Declaration in C
A variable declaration provides assurance to the compiler that there exists a variable with
the given type and name so that the compiler can proceed for further compilation without
requiring the complete detail about the variable. A variable definition has its meaning at
the time of compilation only, the compiler needs actual variable definition at the time of
linking the program.
A variable declaration is useful when you are using multiple files and you define your
variable in one of the files which will be available at the time of linking of the program.
You will use the keyword extern to declare a variable at any place. Though you can
declare a variable multiple times in your C program, it can be defined only once in a file,
a function, or a block of code.
Example
Try the following example, where variables have been declared at the top, but they have
been defined and initialized inside the main function −
#include <stdio.h>
// Variable declaration:
extern int a, b;
extern int c;
extern float f;
int main () {
/* variable definition: */
int a, b;
int c;
float f;
/* actual initialization */
a = 10;
b = 20;
c = a + b;
printf("value of c : %d \n", c);
f = 70.0/3.0;
printf("value of f : %f \n", f);
return 0;
}
When the above code is compiled and executed, it produces the following result −
value of c : 30
value of f : 23.333334
The same concept applies on function declaration where you provide a function name at
the time of its declaration and its actual definition can be given anywhere else. For
example −
// function declaration
int func();
int main() {
// function call
int i = func();
}
// function definition
int func() {
return 0;
}
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Misc Operators
We will, in this chapter, look into the way each operator works.
Arithmetic Operators
The following table shows all the arithmetic operators supported by the C language.
Assume variable A holds 10 and variable B holds 20 then −
Show Examples
Operato Description Example
r
Relational Operators
The following table shows all the relational operators supported by C. Assume
variable A holds 10 and variable B holds 20 then −
Show Examples
Operato Description Example
r
Logical Operators
Following table shows all the logical operators supported by C language. Assume
variable A holds 1 and variable B holds 0, then −
Show Examples
Operato Description Example
r
Bitwise Operators
Bitwise operator works on bits and perform bit-by-bit operation. The truth tables for &, |,
and ^ is as follows −
p q p&q p|q p^q
0 0 0 0 0
0 1 0 1 1
1 1 1 1 0
1 0 0 1 1
Assignment Operators
The following table lists the assignment operators supported by the C language −
Show Examples
Operato Description Example
r
Operators Precedence in C
Operator precedence determines the grouping of terms in an expression and decides how
an expression is evaluated. Certain operators have higher precedence than others; for
example, the multiplication operator has a higher precedence than the addition operator.
For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has a higher
precedence than +, so it first gets multiplied with 3*2 and then adds into 7.
Here, operators with the highest precedence appear at the top of the table, those with the
lowest appear at the bottom. Within an expression, higher precedence operators will be
evaluated first.
Show Examples
Category Operator Associativity
Decision making structures require that the programmer specifies one or more conditions
to be evaluated or tested by the program, along with a statement or statements to be
executed if the condition is determined to be true, and optionally, other statements to be
executed if the condition is determined to be false.
Show below is the general form of a typical decision making structure found in most of
the programming languages −
C programming language assumes any non-zero and non-null values as true, and if it is
either zero or null, then it is assumed as false value.
C programming language provides the following types of decision making statements.
Sr.No Statement & Description
.
1 if statement
An if statement consists of a boolean expression followed by
one or more statements.
2 if...else statement
An if statement can be followed by an optional else
statement, which executes when the Boolean expression is
false.
3 nested if statements
You can use one if or else if statement inside another if or else
if statement(s).
4 switch statement
A switch statement allows a variable to be tested for equality
against a list of values.
The ? : Operator
We have covered conditional operator ? : in the previous chapter which can be used to
replace if...else statements. It has the following general form −
Exp1 ? Exp2 : Exp3;
Where Exp1, Exp2, and Exp3 are expressions. Notice the use and placement of the colon.
The value of a ? expression is determined like this −
Exp1 is evaluated. If it is true, then Exp2 is evaluated and becomes the value of the
entire ? expression.
If Exp1 is false, then Exp3 is evaluated and its value becomes the value of the
expression.
You may encounter situations, when a block of code needs to be executed several
number of times. In general, statements are executed sequentially: The first statement
in a function is executed first, followed by the second, and so on.
Programming languages provide various control structures that allow for more
complicated execution paths.
A loop statement allows us to execute a statement or group of statements multiple
times. Given below is the general form of a loop statement in most of the
programming languages −
1 while loop
2 for loop
Executes a sequence of statements multiple times and
abbreviates the code that manages the loop variable.
3 do...while loop
It is more like a while statement, except that it tests the
condition at the end of the loop body.
4 nested loops
You can use one or more loops inside any other while, for, or
do..while loop.
1 break statement
2 continue statement
Causes the loop to skip the remainder of its body and
immediately retest its condition prior to reiterating.
3 goto statement
Transfers control to the labeled statement.
Here, the key point to note is that a while loop might not execute at all. When the
condition is tested and the result is false, the loop body will be skipped and the first
statement after the while loop will be executed.
Example
#include <stdio.h>
int main () {
#include <stdio.h>
int main () {
int a;
/* for loop execution */
for( a = 10; a < 20; a = a + 1 ){
printf("value of a: %d\n", a);
}
return 0;
}
When the above code is compiled and executed, it produces the following result –
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
The do...while loop
Unlike for and while loops, which test the loop condition at the top of the loop,
the do...while loop in C programming checks its condition at the bottom of the loop.
A do...while loop is similar to a while loop, except the fact that it is guaranteed to execute
at least one time.
Syntax
The syntax of a do...while loop in C programming language is −
do {
statement(s);
} while( condition );
Notice that the conditional expression appears at the end of the loop, so the statement(s)
in the loop executes once before the condition is tested.
If the condition is true, the flow of control jumps back up to do, and the statement(s) in
the loop executes again. This process repeats until the given condition becomes false.
Flow Diagram
Example
#include <stdio.h>
int main () {
/* do loop execution */
do {
printf("value of a: %d\n", a);
a = a + 1;
}while( a < 20 );
return 0;
}
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
C programming allows to use one loop inside another loop. The following section shows a
few examples to illustrate the concept.
Syntax
The syntax for a nested for loop statement in C is as follows −
for ( init; condition; increment ) {
while(condition) {
statement(s);
}
statement(s);
}
The syntax for a nested do...while loop statement in C programming language is as
follows −
do {
statement(s);
do {
statement(s);
}while( condition );
}while( condition );
A final note on loop nesting is that you can put any type of loop inside any other type of
loop. For example, a 'for' loop can be inside a 'while' loop or vice versa.
Example
The following program uses a nested for loop to find the prime numbers from 2 to 100 −
#include <stdio.h>
int main () {
Example
#include <stdio.h>
int main () {
Example
#include <stdio.h>
int main () {
/* do loop execution */
do {
if( a == 15) {
/* skip the iteration */
a = a + 1;
continue;
}
printf("value of a: %d\n", a);
a++;
} while( a < 20 );
return 0;
}
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19
A goto statement in C programming provides an unconditional jump from the 'goto' to a
labeled statement in the same function.
NOTE − Use of goto statement is highly discouraged in any programming language
because it makes difficult to trace the control flow of a program, making the program hard
to understand and hard to modify. Any program that uses a goto can be rewritten to avoid
them.
Syntax
The syntax for a goto statement in C is as follows −
goto label;
..
.
label: statement;
Here label can be any plain text except C keyword and it can be set anywhere in the C
program above or below to goto statement.
Flow Diagram
Example
#include <stdio.h>
int main () {
/* do loop execution */
LOOP:do {
if( a == 15) {
/* skip the iteration */
a = a + 1;
goto LOOP;
}
printf("value of a: %d\n", a);
a++;
}while( a < 20 );
return 0;
}
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19
©SAYANTAN BERA