0% found this document useful (0 votes)
8 views366 pages

Overview of Computer Programming Languages

Huu

Uploaded by

abhayyadav63630
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views366 pages

Overview of Computer Programming Languages

Huu

Uploaded by

abhayyadav63630
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Unit 1 Part 2

Computer Languages

• Machine language
• Assembly language
• High-level language
Machine Language
• Only language of a computer understood by it
without using a translation program
• Normally written as strings of binary 1s and 0s
Advantage
• Can be executed very fast
Limitations
• Machine Dependent
• Difficult to program
• Error prone
• Difficult to modify
Assembly/Symbolic Language

• Programming language that overcomes the limitations


of machine language programming by:
• Using alphanumeric mnemonic codes instead of
numeric codes
• Allowing storage locations to be represented in form
of alphanumeric addresses instead of numeric
addresses e.g. representing memory locations 1000,
1001, and 1002 as FRST, SCND, and ANSR
respectively
Sample assembly language program for adding two numbers and storing theresult
Assembler

• Software that translates as assembly language


program into an equivalent machine language
program of a computer
Advantages and disadvantages of Assembly
Language Over Machine Language
• Easier to understand and use
• Easier to locate and correct errors
• Easier to modify
Demerits
• Machine dependent
• Knowledge of hardware required
• Machine level coding
High-Level Languages

• Machine independent
• Do not require programmers to know anything
about the internal structure of computer on
which high-level language programs will be
executed
• Deal with high-level coding, enabling the
programmers to write instructions using
English words and familiar mathematical
symbols and expressions
Compiler

• Translator program (software) that translates a


high level language program into its equivalent
machine language program
• Compiles a set of machine language
instructions for every program instruction in a
high-level language
Interpreter

• Interpreter is a high-level language translator


• Takes one statement of a high-level language
program, translates it into machine language
instructions
• Immediately executes the resulting machine
language instructions
• Compiler simply translates the entire source
program into an object program and is not
involved in its execution
Interpreter
Merits and demerits

• Machine independent
• Easier to learn and use
• Fewer errors during program development
• Lower program preparation cost
• Better documentation
• Easier to maintain

Demerits
Lower execution efficiency
Less flexibility to control the computer’s CPU, memory and registers
Pseudocode

• A program planning tool where program logic is


written in an ordinary natural language using a
structure that resembles computer instructions
• “ Pseudo” means imitation or false and “ Code” refers
to the instructions written in a programming language.
Hence, pseudocode is an imitation of actualcomputer
instructions
• Because it emphasizes the design of the program,
pseudocode is also called Program Design Language
(PDL)
Overview of C

• C is a programming language developed at AT & T’s


Bell Laboratories of USA in 1972.
• It was designed and written by Dennis Ritchie.
• C is a structured programming language
• C supports functions that enables easy maintainability
of code, by breaking large file into smaller modules
• Comments in C provides easy readability
• C is a powerful language
Program structure
A sample C Program

#include<stdio.h>
int main( )
{

}
Preprocessor Statements:

• These statements begin with # symbol. They are


called preprocessor directives. These statements
direct the C preprocessor to include header files and
also symbolic constants in to C program.
• Some of the preprocessor statements are :
#include: for the standard input/output functions
• #define PI 3.141592 symbolic constant
Header files
• The files that are specified in the include section is
called as header file.
• These are precompiled files that has some functions
defined in them.
• We can call those functions in our program by
supplying parameters.
• Header file is given an extension .h
• C Source file is given an extension .c
Main function
• This is the entry point of a program
• When a file is executed, the start point is the main
function
• From main function the flow goes as per the
programmers choice.
• There may or may not be other functions written by
user in a program
• Main function is compulsory for any c program
Writing the first program
#include<stdio.h>
int main()
{
printf(“Hello world”);
getch();
return 0;
}

• This program prints Hello on the screen when weexecute


it
• getch() method pauses the Output Console until a key is
pressed.
The C Character Set

A character denotes any alphabet, digit or special symbol used to


represent information.
Constants, Variables and Keywords
The alphabets,
numbers and special symbols when properly combined
form constants, variables and keywords. A constant isan entity that
doesn’t change whereas a variable is an entity thatmay change.
There are two ways to define constant in C programming.
•const keyword #include<stdio.h>
•#define preprocessor int main(){
const float PI=3.14;
PI=4.5;
#include<stdio.h> printf("The value of PI is: %f",PI)
int main(){ ;
const float PI=3.14; return 0;

printf("The value of PI is: %f", PI);}


return 0; } If you try to change the value ofPI, it
will render compile time error.
The #define preprocessor is also used to
define constant.
The #define preprocessor directive is usedto
define constant or micro substitution. It can use
any basic data type.
Syntax: #define token value

#include <stdio.h>
#define PI 3.14
void main()
{
printf("%f",PI);
}
Constants
C Variables
An entity that may vary during program execution is called a variable.
Variable names are names given to locations in memory.

Declaration: int age;


Initialization: int age=24;
C Keywords

Keywords are the words whose meaning has already been explained to the C
compiler (or in a broad sense to the computer). The keywords cannot be used
as variable names because if we do so we are trying to assign a new
meaning to the keyword, which is not allowed by the computer.

nt x, y; ch

, y; char c; float f;

Return type and value of printf function


printf is a library function of stdio.h, it is used to display messages as
well as values on the standard output device (monitor). printf
returns an integer value, which is the total number of printed
characters.
new line character ( "\n")

#include <stdio.h>
void main()
{ int res;
res = printf("Hello\n");
printf("Total printed characters are: %d\n",res); }
Output
Hello
Total printed characters are: 5
Return type and value of scanf function
scanf is a library function of stdio.h, it is used to take inputfrom
the standard input device (keyboard). scanf returns an integer value,
which is the total number of inputs.

#include <stdio.h>
void main()
{ int x,y;
int res;
printf("Enter two number: ");
res=scanf("%d%d", &x,&y);
printf("Total inputs are: %d\n",res); }
#include <stdio.h>
int main()
{ printf("%d", printf("welcome to programming class"));
return 0;
}
Data Type Range Bytes Forma
t
signed char -128 to + 127 1 %c
unsigned char 0 to 255 1 %c
short signed int -32768 to +32767 2 %d
short unsigned int 0 to 65535 2 %u
signed int -32768 to +32767 2 %d
unsigned int 0 to 65535 2 %u
long signed int -2147483648 to 4 %ld
+2147483647
long unsigned int 0 to 4294967295 4 %lu
float -3.4e38 to 4 %f
+3.4e38
double -1.7e308 to 8 %lf
+1.7e308
long double -1.7e4932 to 10 %Lf
+1.7e4932
Note: The sizes and ranges of int, short and long are compiler dependent. Sizes in this figure are
for 16-bit compiler.
By default char (signed char) int is (signed int)

I byte = 8 bits either 0 or 1


In case of signed one bit unsinged 2n-1
is reserved for sign
+/- 28-1 = 256-1=255
-2n-1 to 2n-1 -1 So range is 0 to 255 for
-27 to 27-1
= -128 to 127
unsinged cha
Unsinged integer
If int takes 2 bytes then 2 bytes = 16 bits

Formula is 2n-1
216-1 = 65536-1=65535
Range is 0 to 65535

singed
0 to 65535 integer
-2n-1 to 2n-1 -1
-215 to 215 -1
-32768 to +32767
Identifiers
• Definition: Names used to identify variables, functions, arrays, etc.
• Rules:
o Must begin with a letter or underscore.

o Can contain letters, digits, and underscores.

o Case-sensitive (Variable and variable are different).


Operators and Expressions

An operator specifies an operation to be performedthat


yields a value. The variables, constants can bejoined by
various operators to form an expression.

An operand is a data item on which an operatoracts.


Some operators require two operands, while others act
upon only one operand. C includes alarge number of
operators that fall under several different categories,
which are as follows
Expression

Expression is a combination of operators, constants, variables


and function calls. The expression can be arithmetic, logical or
relational

x+y //arithmetic operation


a = b+c //uses two operators ( =') and ( + )
a>b //relational expression
a== b //logical expression
func(a, b) //function call
•Arithmetic operators
•Assignment operators .
•Increment and Decrement operators
•Relational operators.
•Logical operators
•Conditional operator
• Comma operator
• sizeof operator
• Bitwise operators
•Other operators
Binary Arithmetic Operators
a= 17, b=4
Increment And Decrement Operators

C has two useful operators increment ( ++ ) and decrement( - - ).


These are unary operators because they operate on a single
operand. The increment operator ( ++ ) incrementsthe value of the
variable by 1 and decrement operator ( - - )decrements the value of
the variable by 1.

++x is equivalent to x = x + 1

--x is equivalent to x = x-I

These operators are of two types


•Prefix increment / decrement - operator is written beforethe
operand (e.g. ++x or - -x )

Postfix increment / decrement - operator is written after the


operand (e.g. x++ or x - - )
Prefix Increment / Decrement
Here first the value of variable is incremented / decremented then the
new value is used in the operation .

X=3 (x whose value is 3.)

The statement y = ++x; means first increment the value of x by 1, then


assign the value of x to y .

equivalent to these two statements (x = x+1; y = x; )

Hence now value of x is 4 and value of y is 4.

The statement y = - -x ;
means first decrement the value of x by 1 then assign the value of x to y
This statement is equivalent to these two's statements
x = x -1 ; y= x;

Hence now value of x is 3 and value of y is 3.


Postfix Increment / Decrement
Here first the value of variable is used in the operation and then
increment/decrement is perform.

Let us take a variable whose value is 3.

The statement y = x++; means first the value of x is assigned to y and then
x is incremented.

statement is equivalent to these two statements y = x; x = x+1;


Output :

x is 4 and value of y is 3.

y = x- -; means first the value of x is assigned to y and then x is decremented.

This statement is equivalent to these two statements


y = x;
x = x-I;
Output is x is 3 and value of y is 4.
a++ + b (a=4, b=3)

Post Increment/decrement in the context of equation - First use the value inthe
equation and then increment the value

Pre increment/Decrement in context of equation -


First increment the value and then use in the equation after completion of the
equation
Relational Operators
Relational operators are used to compare values of two expressions depending on their
relations. An expression that contains relational operators is called relational
expression. If the relation is true "then the value of relational expression is 1 and if the
relation is false then the value of expression is 0
a=9, b=5
Logical Or Boolean Operators
The expression that combines two or more expressions is termed as a
logical expression. For combining these expressions we use logical
operators. These operatorsreturn 0 for false and 1 for true. C has three
logical operators.
AND ( &&) Operation (This operator gives the net result true if
both the conditions are true, otherwise the result is false. )

a = 10, b = 5, c = 0

nonzero
values are
regarded as
true and
zero value is
regarded as
false
OR ( II) Operator

This operator gives the net result false, if both the conditions havethe
value false, otherwise the result is true.

a = 10, b = 5, c =0

Consider the logical expression(a >= b) I I (b > 15)This


gives result true because one condition is true
Not ( ! ) Operator

This is a unary operator and it negates the value of the condition. If the value of
the condition is false then it gives the result true. If the value of the condition is
true then it gives the result false.

a = 10, b = 5, c = 0

! ( a = = 10 )

The value of the condition (a= =10) is true.


NOT operator negates the value of the condition. Hence the result is false.
Assignment Operator

x=8

y=5

s = x+y-2 /* Value of expression x+y-2 is assigned tos*/

y=x /* Value of x is assigned to y*/


Operator Description Example
= Simple assignment operator. Assigns values from right C = A + B will assign the value
side operands to left side operand of A + B to C
+= Add AND assignment operator. It adds the right
C += A is equivalent to C = C +
operand to the left operand and assign the result to the
A
left operand.
-= Subtract AND assignment operator. It subtracts the
right operand from the left operand and assigns the C -= A is equivalent to C = C - A
result to the left operand.
*= Multiply AND assignment operator. It multiplies the
C *= A is equivalent to C = C *
right operand with the left operand and assigns the
A
result to the left operand.
/= Divide AND assignment operator. It divides the left
operand with the right operand and assigns the result C / A is equivalent to C = C / A
to the left operand.
%= Modulus AND assignment operator. It takes modulus
C %= A is equivalent to C = C
using two operands and assigns the result to the left
%A
operand.
<<= Left shift AND assignment operator. C <<= 2 is same as C = C << 2

>>= Right shift AND assignment operator. C >>= 2 is same as C = C >> 2

&= Bitwise AND assignment operator. C &= 2 is same as C = C & 2


^= Bitwise exclusive OR and assignment operator. C ^= 2 is same as C = C ^ 2
|= Bitwise inclusive OR and assignment operator. C |= 2 is same as C = C | 2
Conditional Operator

Conditional operator is a ternary operator ( ? and : )


which requires three expressions as operands. This
written as

Test Expression ? expression1 : expression2

a < b ? printf("a is smaller") : printf("b is smaller");

max = a > b ? a : b;
Precedence And Associatively of operators

• Precedence: The order in which operators are evaluated in an


expression.

Consider the following expression

2+3*5

If addition is performed before multiplication then resultwill


be 25

and if multiplication is performed before addition thenthe


result will be 17.
• Associativity: The direction in which an expression is evaluated
when two operators have the same precedence.

When an expression contains two operators of equal priority the tie


between them is settled using the associativity of the operators.
Associativity can be of two types—Left to Right or Right to Left.
x = a+b < c

+ operator has higher precedence than < and =, and < has more
precedence than =, so first a+b will be evaluated, then < operator will
be evaluated, and atlast the whole value will be assigned to x.

If a = 2,b = 6, c = 9 then final value of x will bex *= a+ b


(+)operator has higher precedence than *=, so a+b will
be evaluated before compound assignment. This isinterpreted as x =
x*(a+b) and not as x = x*a+b.
x = 5, a = 2, b = 6
Ans=40;
x = a<=b II b==c

Here order of evaluation of operators will be

<=, = =, II,=. If initial values area = 2, b = 3,

c = 4,

then final value of x will 'be 1.

.
What if Two operators are of same precedence

For example-5

+ 16 / 2 * 4

Here / and * have higher precedence than + operator, so theywill be


evaluated before addition. But / and * have sameprecedence, so
which one of them will be evaluated first still remains a problem. If /
is evaluated before *, then the result is37 otherwise the result is 7.

Similarly consider this expression


20 - 7 - 5 - 2 -1
Here we have four subtraction operators, which of course have the
same precedence level. If we decide to evaluate from left to right
then answer will be 5, and if we evaluatefrom right to left the
answer will be 17.
To solve these types of problems, an associativity property is assigned to
each operator. Associativity of the operators within same group is same.
All the operators either associate from left to right or from rightto left

5 + 16 / 2 *4 since / and * operators associate from left to right


will be evaluated before * and the correct result 37.

20 - 7 - 5 - 2 -1 The subtraction operator associates from left to


right
so the value of this expression is 5

The assignment operator associates from right to left. Suppose we


have a multiple assignment expression like this x=y=z=5

initially the integer value 5 is assigned to variable z and then value


of expression z = 5 is assigned variable y. The value of expression
z = 5 is 5, so 5 is assigned to variable y and now the value of
expression y =z = 5 becomes 5.

Now value of this expression is assigned to x and the value of


hole
expression x = y = z = 5 becomes 5.
Format Specifiers
• Definition: Used in printf() and scanf() functions to specify the type of
data.
• Common Specifiers:
o %d: Integer.

o %f: Floating-point number.

o %c: Character.

o %s: String.
Thankyou…
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Unit -1
(Introduction to computer)
What is a Computer?
A computer is an electronic device that processes data according to instructions
provided by software programs. It takes input (data), processes it using a
central processing unit (CPU), stores information, and produces output
(results) to perform various tasks.
Types of Computers
There are various types of computers that are used today based on the need of
user. Some of the types are:
 Desktop: Desktops are mainly used for regular use and they have separate
components mounted together like the monitor, keyboard, mouse, CPU etc.
Since the system is primarily kept on a desk for better usability it is called
a desktop.

Laptop: Laptops are a portable version of desktops, with all the components
integrated into a single unit thus providing mobility to the system. They are
great for on-the-go work and come with built-in webcams, Bluetooth and Wi-
Fi.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Servers: Servers are special types of computers that are used to manage
network resources. They provide services to other systems and computers.
Some of the primary tasks of servers include creating databases, hosting and
providing support to other applications.

 Tablets: Tablets are even more portable than laptops. They are smaller than
laptops but are larger than smartphones. They come with touchscreens
which makes them perfect for browsing the web, consuming content and
personal communications.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Other devices: Other devices include smartphones, game consoles, Smart


TVs etc.

How does the Software Work with Hardware?


When you give input (e.g., typing a letter on a keyboard), the hardware
(keyboard) sends this input to the software. The software then converts the
input into a machine-readable language (binary) that the CPU can process. The
output (e.g., the letter ‘A’) is then displayed on the screen as a result of this
process.

Example Process:
1. You press the Shift key and the A key on your keyboard.
2. The software translates this into machine code and tells the CPU that the
letter ‘A’ should be displayed.
3. The CPU processes the input, and the monitor shows the letter 'A'.

Characteristics of Computer:

 Speed: Computers can perform tasks at incredible speeds. They can process
millions of instructions per second, helping complete tasks quickly that
would take humans much longer.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Accuracy: Computers are very accurate. When used correctly, they can
perform calculations and tasks with minimal errors, as long as the input is
correct.
 Automation: Once programmed, a computer can perform tasks
automatically without human intervention. This makes repetitive tasks
much easier and faster.
 Storage: Computers can store large amounts of data in various forms like
files, documents, and images. They have the ability to quickly retrieve and
use this information when needed.
 Versatility: A computer can perform a wide variety of tasks, from basic
calculations to running complex programs. It can be used for everything
from gaming to scientific research.
 Diligence: Unlike humans, computers do not get tired or bored. They can
work continuously for hours, days, or even longer without losing efficiency
or making mistakes.
 Connectivity: Computers can connect to the internet and other computers,
allowing people to communicate, share information, and access resources
from anywhere in the world.
 Consistency: A computer follows instructions exactly as given. As long as
the instructions are correct, the computer will always produce the same
result, making it reliable.
 High Storage Capacity: Computers can store vast amounts of data, much
more than the human brain can handle. This makes them ideal for
managing large volumes of information.

 Control: Computers are controlled by software, which allows users to tell


the computer what to do and how to do it. Software programs help manage
all tasks efficiently.

Advantages of Computer
 Multitasking: Multitasking is one of the main advantages of computers. A
person can do multiple tasks, and multiple operations at the same time, and
calculate numerical problems within a few seconds. The computer can
perform millions or trillions of work in one second.
 Speed: Now the computer isn’t just a calculating device. Now a day’s
computer has a vital role in human life. One of the most advantages of
computers is their incredible speed, which helps human to finish their task
in a few seconds.
 Cost-Effective Storage: Centralized databases make it possible for the user
to store data without incurring high costs through the use of computers.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

This also goes along with decreased requirements for physical storage
configurations.
 Accuracy: Another advantage with use of computers is that they are precise
in executing computations and in the handling of programs. This is because
most of the time, errors are provoked by improper entries inserted by the
user and not the computer.
 Data Security: It is possible to use security measures with the help of which
computers are protected and do not allow malicious programs and other
similar threats to access the materials.
 Increased Productivity: The fast execution of tasks a computer avails helps
a user increase the throughput since more tasks are completed within a
short span of time.
 Remote Access and Collaboration: Computers enable remote work and
collaboration through cloud services and internet connectivity, promoting
flexibility.
 Enhanced Communication: Computers facilitate instant communication
via email, video calls, and messaging, breaking down geographical barriers.
 Access to Information: Computers provide quick access to vast amounts
of information through the internet, aiding research and learning.
 Entertainment and Creativity: Computers offer various entertainment
options and tools for creative work, including gaming, media consumption,
and digital content creation.

Disadvantages of Computer
 Virus and Hacking Attacks: A virus may be a worm and hacking is just
unauthorized access over a computer for a few illicit purposes. Viruses can
go to another system from email attachments, viewing an infected website
advertisement, through removable devices like USBs, etc.

 Online Cyber Crimes: Online cyber-crime means computers and networks


may have been utilized in order to commit a crime. Cyberstalking and fraud
are the points that come under online cyber crimes.
 Reduction in Employed Opportunity: Mainly past generation hasn't used
the pc or they need the knowledge of computers they faced an enormous
problem when computers came into the field.
 High Cost: Computers are expensive. Even the foremost affordable
computers are still very expensive for the typical person in South Africa.
Since computers empower people.
 Distractions/Disruptions: If you've got ever spent hours browsing the web
or watching videos on YouTube, then you recognize how distracting
computers can be! Because of their high entertainment value.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Health Problems: Prolonged use of computers can lead to various health


Hazards. Too much sitting near the screen results in eye strain and drying
up of the eyes. Also, prolonged sitting leads to neck and back problems.
 Social Isolation: Excessive use of computers, especially for online activities
like gaming or social media, can result in social isolation. People may spend
less time interacting face-to-face, which can affect personal relationships
and communication skills.
 Environmental Impact: The production and disposal of computers
contribute to e-waste, which poses a significant environmental threat.
Recycling and responsible disposal are necessary to mitigate environmental
harm.

Basic Terms Related to Computers :

 Vacuum Tube: Vacuum tubes have the functionality of controlling the flow
of electrons in a vacuum. Generally, it is used in switches, amplifiers, radio,
televisions, etc.
 Transistor: A transistor helps in controlling the flow of electricity in devices,
it works as an amplifier or a switch.
 Integrated Circuit (IC): Integrated circuits are silicon chips that contain
their circuit elements like transistors, resistors, etc.
 Microprocessors: Microprocessors are the components that contain the
CPU and its circuits and are present in the Integrated Circuit.
 Central Processing Unit (CPU): The CPU is called the brain of the
computer. CPU performs processing and operations work.
 Magnetic Drum: Magnetic Drum is like a cylinder that stores data and
cylinder.
 Magnetic Core: Magnetic cores are used to store information. These are
arrays of small rings.
 Machine Language: The binary language that a computer accepts; also
known as a low-level programming language.
 Memory: Used to store data, information, and programs.
 Artificial Intelligence: Deals with creating intelligent machines and
behaviours.

Generations of Computers:

The modern computer took its shape with the arrival of your time. It was around
the 16th century when the evolution of the computer started. The initial
computer faced many changes, obviously for the better. It continuously
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

improved itself in terms of speed, accuracy, size, and price to urge the form of
the fashionable day computer.
Phases of Computer Generations
The evolution of computers is divided into five generations:

Generations of Evolving
Computers Time-Period Hardware

First Generation 1940s - 1950s Vacuum Tube Based

Second Generation 1950s - 1960s Transistor Based

Third Generation 1960s - 1970s Integrated Circuit Based

Fourth Generation 1970s - Present Microprocessor Based

Artificial Intelligence
Fifth Generation Present - Future
Based

Before computers, we used calculators, spreadsheets, and computer algebra


systems, mathematicians and inventors searched for solutions to ease the
burden of calculation.
Below are the 8 Mechanical Calculators before modern computers were
invented.
1. Abacus (ca. 2700 BC)
2. Pascal’s Calculator (1652)
3. Stepped Reckoner (1694)
4. Arithmometer (1820)
5. Comptometer (1887) and Comptograph (1889)
6. The Difference Engine (1822)
7. Analytical Engine (1834)
8. The Millionaire (1893)
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

First Generation Computers


The technology behind the primary generation of computers was a fragile glass
device, which was called a vacuum tube. These computers were very heavy and
really large. These weren't very reliable, and programming on them was a
tedious task as they used a low-level programming language and had no OS.
First-generation computers were used for calculation, storage, and control
purposes. They were too bulky and large; they needed a full room and
consumed a lot of electricity. Punch cards were used to improve the information
for external storage. Magnetic card used. Machine and assembly language is
developed.

Used vacuum tubes; big and slow.

Examples of some main first-generation computers are mentioned below.

 ENIAC: Electronic Numerical Integrator and Computer, built by J. Presper


Eckert and John V. Mauchly was a general-purpose computer. It had been
cumbersome, and large, and contained 18,000 vacuum tubes.
 EDVAC: Electronic Discrete Variable Automatic Computer was designed by
von Neumann. It could store data also as instruction and thus the speed
was enhanced.
 UNIVAC: Universal Automatic Computer was developed in 1952 by Eckert
and Mauchly.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Vacuum Tube

Characteristics of First-Generation Computers

Characteristics Components

Main electronic component Vacuum tube.

Programming language Machine language.

Main memory Magnetic tapes and magnetic drums.

Input/output devices Paper tape and punched cards.

Very slow and very large (often


Speed and size
taking up an entire room).

IBM 650, IBM 701, ENIAC, UNIVAC


Examples of first generation
1, etc.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Second Generation Computers:


Second-generation computers used the technology of transistors rather than
bulky vacuum tubes. Another feature was the core storage. A transistor may
be a device composed of semiconductor material that amplifies a sign or opens
or closes a circuit.

Transistors were invented in Bell Labs. The use of transistors made it possible
to perform powerfully and with due speed. It reduced the dimensions and price
and thankfully the warmth too, which was generated by vacuum tubes. Central
Processing Unit (CPU), memory, programming language, and input, and output
units also came into the force within the second generation.

The programming language was shifted from high level to programming


language and made programming comparatively a simple task for
programmers. Languages used for programming during this era were FORTRAN
(1956), ALGOL (1958), and COBOL (1959).

Transistor
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Characteristics of Second-Generation Computers


Characteristics Components

Main electronic component Transistor.

Machine language and assembly


Programming language
language.

Magnetic core and magnetic


Memory
tape/disk.

Input/output devices Magnetic tape and punched cards.

Smaller in size, they had low power


consumption and generated less
Power and size
heat (in comparison with the first-
generation computers).

PDP-8, IBM1400 series, IBM 7090


Examples of the second generation and 7094, UNIVAC 1107, CDC 3600,
etc.

Third Generation Computers :


During the third generation, technology envisaged a shift from huge transistors
to integrated circuits, also referred to as ICs. Here, a variety of transistors were
placed on silicon chips, called semiconductors. The most important feature of
this era’s computers was speed and reliability. IC was made from silicon, also
called silicon chips.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

The computer programs was designed to make the machine work. Operating
system was a program designed to handle a machine completely. Because of
the operating system machine could execute multiple jobs simultaneously.
Integrated circuits were used to replace many transistors used in the second
generation.
A single IC has many transistors, registers, and capacitors built on one thin
slice of silicon. The value size was reduced, and memory space and dealing
efficiency were increased during this generation. Programming was now wiped
out Higher level languages like BASIC (Beginners All-purpose Symbolic
Instruction Code). Minicomputers found their shape during this era.

Characteristics of Third-Generation Computers


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Characteristics Components

Main electronic component Integrated circuits (ICs).

Programming language High-level language.

Large magnetic core, magnetic


Memory
tape/disk.

Magnetic tape, monitor, keyboard,


Input/output devices
printer, etc.

IBM 360, IBM 370, PDP-11, NCR


Examples of third-generation
395, B6500, UNIVAC 1108, etc.

Fourth Generation Computers

In 1971 First microprocessors were used, the large-scale of integration LSI


circuits built on one chip called microprocessors. The advantage of this
technology is that one microprocessor can contain all the circuits required to
perform arithmetic, logic, and control functions on one chip. LSI placed
thousands of transistors onto a single chip.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

The computers using microchips were called microcomputers. This generation


provided even smaller-sized computers with larger capacities. That's not
enough, then Very Large Scale Integrated (VLSI) circuits replaced LSI circuits.
The Intel 4004 chip, developed in 1971, located all the components of the pc
from the central processing unit and memory to input/ output controls on one
chip and allowed the dimensions to reduce drastically. VLSI placed several
hundred thousand transistors on a single silicon chip. This silicon chip is
known as the microprocessor.

Technologies like multiprocessing, multiprogramming, time-sharing, operating


speed, and virtual memory made it a more user-friendly and customary device.
The concept of private computers and computer networks came into being
within the fourth generation.

Characteristics of Fourth-Generation Computers


Characteristics Components

Large-scale integration (VLSI) and


the microprocessor (VLSI has
Main electronic component
thousands of transistors on a single
microchip).
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Characteristics Components

semiconductor memory (such


Memory
as RAM, ROM etc.).

pointing devices, optical scanning,


Input/output devices
keyboard, monitor, printer, etc.

IBM PC, STAR 1000, APPLE II, Apple


Examples of the fourth generation
Macintosh, Alter 8800, etc.

Fifth Generation Computers


The technology behind the fifth generation of computers is AI. It allows
computers to behave like humans. It is often seen in programs like voice
recognition, the area of medicine, and entertainment. Within the field of game
playing also it has also shown remarkable performance where computers are
capable of beating human competitors.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

The speed is the highest, the size is the smallest and the area of use has
remarkably increased within the fifth generation computers. Though not a
hundred per cent AI has been achieved to date, keeping in sight the present
developments, it is often said that this dream also will become a reality very
soon.
To summarize the features of varied generations of computers, it is often said
that a big improvement has been seen so far because of the speed and accuracy
of functioning care, but if we mention the dimensions, it's been small over the
years. The value is additionally diminishing and reliability is increasing.

Characteristics of Fifth-Generation Computers


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Characteristics Components

Based on artificial intelligence, uses


the Ultra Large-Scale Integration
(ULSI) technology and parallel
processing method (ULSI has
Main electronic component millions of transistors on a single
microchip and the Parallel
processing method use two or more
microprocessors to run tasks
simultaneously).

Understand natural language


Language
(human language).

Size Portable and small in size.

Trackpad (or touchpad),


touchscreen, pen, speech input
Input/output device (recognize voice/speech), light
scanner, printer, keyboard, monitor,
mouse, etc.

Desktops, laptops, tablets,


An example of the fifth generation
smartphones,

Block diagram of computer /Components of a Computer:

The functional components of a digital computer include the Input Unit,


which takes in data; the CPU, which processes data with its Control Unit
(CU), Arithmetic Logic Unit (ALU), and Registers; the Memory Unit, which
stores data temporarily (RAM) or permanently (HDD/SSD); the Output Unit,
which displays results; and the Bus System, which connects and transfers
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

data between components. These parts work together to execute tasks and
provide results.

The functional components of a computer are the key parts that work
together to process and manage data. These include the Input Unit for
receiving data, the CPU for processing it, the Memory Unit for storing
information, the Output Unit for displaying results, and the Bus System that
connects all parts. These components help the computer perform tasks
efficiently.
1. Input Unit
 Purpose: Captures data and instructions from users or external sources.
 Function: Converts user input into binary signals that the computer can
process.
 Common Devices (2025):
o Keyboard, Mouse, Touchscreens
o Scanners, Sensors, Stylus pens
o Voice Assistants (e.g., Siri, Alexa)
o Biometric devices (face/fingerprint recognition)
o Iot-based inputs from smart devices
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

2. Central Processing Unit (CPU) – The Brain of the Computer


The CPU executes instructions and controls all internal operations. In 2025,
CPUs will often have multiple cores and threads to handle parallel processing
efficiently.
Components of CPU:
a. Arithmetic Logic Unit (ALU)
 Performs arithmetic operations (add, subtract, multiply, divide).
 Handles logical operations (comparison, decision-making).
 Supports AI/ML tasks using built-in vector/matrix operations (in modern
CPUs).
b. Control Unit (CU)
 Directs the operations of all computer parts.
 Decodes instructions and coordinates data flow.
 Sends control signals to memory and I/O devices.
c. Registers
 High-speed memory locations within the CPU.
 Temporarily store instructions, addresses, and intermediate data.
 Examples: Accumulator, Instruction Register, Program Counter, Address
Register.
 Modern CPUs include 64-bit or even 128-bit registers for faster processing.

3. Memory / Storage Unit


The memory unit holds data and instructions before, during, and after
processing.
a. Primary Memory (Main Memory):
 RAM (Random Access Memory): Temporarily stores data during execution.
o Types in 2025: DDR5, LPDDR5X, and emerging MRAM.
 ROM (Read-Only Memory): Stores boot-up instructions and firmware.
 Cache Memory: Ultra-fast memory between CPU and RAM (L1, L2, L3
levels).
b. Secondary Storage:
 Used for long-term data storage.
 Examples: SSDs (NVMe drives), HDDs, flash drives, and cloud storage.
 Modern Trend: Use of Cloud Integration and hybrid storage models.

4. Output Unit
 Purpose: Converts processed data (binary) into a form user can understand.
 Examples:
o Visual: Monitors (LED, OLED, 4K/8K displays)
o Print: Printers (Inkjet, Laser, 3D Printers)
o Audio: Speakers, Headphones
o Haptic: Vibration feedback devices
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Emerging Tech: AR/VR headsets, voice-based output, Braille displays for


accessibility

Types of Computer
There are two bases on which we can define the types of computers. We will
discuss the type of computers on the basis of size and data handling
capabilities. We will discuss each type of computer in detail. Let’s see first what
are the types of computers.
 Super Computer
 Mainframe computer
 Mini Computer
 Workstation Computer
 Personal Computer (PC)
 Server Computer
 Analog Computer
 Digital Computer
 Hybrid Computer
 Tablets and Smartphone

Supercomputer

When we talk about speed, then the first name that comes to mind when
thinking of computers is supercomputers. They are the biggest and fastest
computers (in terms of speed of processing data). Supercomputers are designed
such that they can process a huge amount of data, like processing trillions of
instructions or data just in a second. This is because of the thousands of
interconnected processors in supercomputers. It is basically used in scientific
and engineering applications such as weather forecasting, scientific
simulations, and nuclear energy research. It was first developed by Roger Cray
in 1976.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Characteristics of Supercomputers
 Supercomputers are the computers that are the fastest and they are also
very expensive.
 It can calculate up to ten trillion individual calculations per second, this is
also the reason which makes it even faster.
 It is used in the stock market or big organizations for managing the online
currency world such as Bitcoin etc.
 It is used in scientific research areas for analyzing data obtained from
exploring the solar system, satellites, etc.

Mainframe computer
Mainframe computers are designed in such a way that they can support
hundreds or thousands of users at the same time. It also supports multiple
programs simultaneously. So, they can execute different processes
simultaneously. All these features make the mainframe computer ideal for big
organizations like banking, telecom sectors, etc., which process a high volume
of data in general.
Characteristics of Mainframe Computers
 It is also an expensive or costly computer.
 It has high storage capacity and great performance.
 It can process a huge amount of data (like data involved in the banking
sector) very quickly.
 It runs smoothly for a long time and has a long life.

Minicomputer
Minicomputer is a medium size multiprocessing computer. In this type of
computer, there are two or more processors, and it supports 4 to 200 users at
one time. Minicomputer is similar to Microcontroller. Minicomputers are used
in places like institutes or departments for different work like billing,
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

accounting, inventory management, etc. It is smaller than a mainframe


computer but larger in comparison to the microcomputer.
Characteristics of Minicomputer
 Its weight is low.
 Because of its low weight, it is easy to carry anywhere.
 less expensive than a mainframe computer.
 It is fast.

Workstation Computer
A workstation computer is designed for technical or scientific applications. It
consists of a fast microprocessor, with a large amount of RAM and a high-speed
graphic adapter. It is a single-user computer. It is generally used to perform a
specific task with great accuracy.
Characteristics of Workstation Computer
 It is expensive or high in cost.
 They are exclusively made for complex work purposes.
 It provides large storage capacity, better graphics, and a more powerful CPU
when compared to a PC.
 It is also used to handle animation, data analysis, CAD, audio and video
creation, and editing.

Personal Computer (PC)


Personal Computers is also known as a microcomputer. It is basically a general-
purpose computer designed for individual use. It consists of a microprocessor
as a central processing unit(CPU), memory, input unit, and output unit. This
kind of computer is suitable for personal work such as making an assignment,
watching a movie, or at the office for office work, etc. For example, Laptops and
desktop computers.

Characteristics of Personal Computer (PC)


 In this limited number of software can be used.
 It is the smallest in size.
 It is designed for personal use.
 It is easy to use.
Server Computer
Server Computers are computers that are combined data and programs.
Electronic data and applications are stored and shared in the server computer.
The working of a server computer is that it does not solve a bigger problem like
a supercomputer but it solves many smaller similar ones. Examples of server
computer are like Wikipedia, as when users put a request for any page, it finds
what the user is looking for and sends it to the user.
Characteristics:
 Handles data and applications for multiple clients or users.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Centralized management of resources (e.g., databases, websites).


 Designed to run 24/7 without interruption.
 More powerful than a typical PC and optimized for networking and data
management.
Examples:
 Web servers (e.g., Apache HTTP Server)
 Database servers (e.g., SQL Server, Oracle)

Based on Data-Handling Capabilites

Analog Computer
Analog Computers are particularly designed to process analog data.
Continuous data that changes continuously and cannot have discrete values
are called analog data. So, an analog computer is used where we don't need
exact values or need approximate values such as speed, temperature, pressure,
etc. It can directly accept the data from the measuring device without first
converting it into numbers and codes. It measures the continuous changes in
physical quantity. It gives output as a reading on a dial or scale. For example
speedometer, mercury thermometer, etc.
Characteristics:
 Handles continuous data.
 Real-time data processing without needing to convert it into digital form.
 Used in applications where approximate values are sufficient.
Examples:
 Speedometer (for measuring vehicle speed)
 Thermometers (mercury thermometer)

Digital Computer
Digital computers are designed in such a way that they can easily perform
calculations and logical operations at high speed. It takes raw data as input
and processes it with programs stored in its memory to produce the final
output. It only understands the binary input 0 and 1, so the raw input data is
converted to 0 and 1 by the computer and then it is processed by the computer
to produce the result or final output. All modern computers, like laptops,
desktops including smartphones are digital computers.
Characteristics:
 Processes data in the form of binary digits (0s and 1s).
 Handles precise, accurate data and complex operations, including
calculations, logical operations, and storage.
 Fast data processing and capable of running various applications from
entertainment to business management.
Examples:
 Laptops
 Desktops
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Smartphones

Hybrid Computer
As the name suggests hybrid, which means made by combining two different
things. Similarly, the hybrid computer is a combination of both analog and
digital computers. Hybrid computers are fast like analog computers and have
memory and accuracy like digital computers. So, it has the ability to process
both continuous and discrete data. For working when it accepts analog signals
as input then it converts them into digital form before processing the input
data. So, it is widely used in specialized applications where both analog and
digital data are required to be processed. A processor which is used in petrol
pumps that converts the measurements of fuel flow into quantity and price is
an example of a hybrid computer.
Characteristics:
 Can handle both analog and digital data.
 Real-time processing with high accuracy.
 Often used in applications where both types of data are needed.
Examples:
 Petrol pump processors that convert fuel flow measurements into digital
format (quantity and price).
 Medical equipment like ECG (Electrocardiogram) machines

Tablet and Smartphones


Tablets and Smartphones are the types of computers that are pocket friendly
and easy to carry is these are handy. This is one of the best use of modern
technology. These devices have better hardware capabilities, extensive

Quantum Computing and Neuromorphic Computing Comparing Future Technologies

The integration of quantum computing and neuromorphic computing has the


potential to revolutionize various industries, including healthcare, finance, and
transportation. Quantum computers can simulate complex molecular
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

interactions. This capability leads to breakthroughs in medicine. Neuromorphic


computing can enable the development of more efficient algorithms for tasks
such as image recognition and natural language processing.

What Is Quantum Computing

Quantum computing is a revolutionary technology that utilizes the principles


of quantum mechanics to perform calculations exponentially faster than
classical computers. At its core, quantum computing relies on the manipulation
of quantum bits or qubits, which can exist in multiple states simultaneously,
allowing for parallel processing of vast amounts of data (Nielsen & Chuang,
2010). This property enables quantum computers to tackle complex problems
that are currently unsolvable with traditional computers.

The fundamental building block of a quantum computer is the qubit, which is


typically implemented using a two-level quantum system such as a
superconducting circuit or an ion trap (DiVincenzo, 2000). Qubits are incredibly
sensitive to their environment and require sophisticated control systems to
maintain their fragile quantum states. Quantum gates, the quantum equivalent
of logic gates in classical computing, are used to manipulate qubits and perform
operations on them.

Quantum Bits And Qubits

Quantum bits, also known as qubits, are the fundamental units of quantum
information in quantum computing. Unlike classical bits, which can exist in only
two states (0 or 1), qubits can exist in multiple states simultaneously due to the
principles of superposition and entanglement. This property allows a single
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

qubit to process multiple possibilities simultaneously, making it a powerful tool


for certain types of computations.

The concept of qubits was first introduced by physicists Peter Shor and Andrew
Steane in the 1990s as a way to describe the quantum states of particles such
as electrons or photons. Since then, researchers have developed various methods
for creating and manipulating qubits using different physical systems, including
superconducting circuits, trapped ions, and optical lattices.

Neuromorphic Computing Basics

Neuromorphic computing is a paradigm that seeks to develop computer chips


that mimic the structure and function of biological brains (Mead, 1990). This
approach is based on the idea that the brain’s neural networks are highly
efficient in terms of power consumption and computational capabilities, and that
by emulating these networks, computers can be made more efficient and
adaptable. Neuromorphic computing involves the use of artificial neural
networks, which are composed of interconnected nodes or “neurons” that
process and transmit information.

The basic components of neuromorphic computing systems include neurons,


synapses, and dendrites (Indiveri & Liu, 2015). Neurons are the fundamental
computing units, which receive and integrate inputs from other neurons through
synapses. Synapses are the connections between neurons, which can be
modified based on experience, allowing the network to learn and adapt.
Dendrites are the branching extensions of neurons that receive input signals
from other neurons.

Neuromorphic computing systems can be implemented using a variety of


technologies, including analog circuits (Mead, 1990), digital circuits (Indiveri &
Liu, 2015), and memristor-based circuits (Strukov et al., 2008). Analog circuits
are often used to implement neuromorphic systems because they can efficiently
mimic the continuous-time dynamics of biological neurons. Digital circuits, on
the other hand, offer greater flexibility and scalability, but may require more
power and computational resources.

One of the key advantages of neuromorphic computing is its potential for low-
power consumption (Mead, 1990). Biological brains are highly efficient in terms
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

of power consumption, with estimates suggesting that they operate at a power


density of around 20 watts per kilogram (Koch, 1999). Neuromorphic computers
aim to achieve similar levels of efficiency by using analog circuits and adaptive
algorithms that minimize energy expenditure.

Computer Memory
Memory is the electronic storage space where a computer keeps the
instructions and data it needs to access quickly. It's the place where
information is stored for immediate use. Memory is an important component of
a computer, as without it, the system wouldn’t operate correctly. The
computer’s operating system (OS), hardware, and software all rely on memory
to function properly.
Computer memory functions similarly to the human brain, storing data,
information, and instructions. It acts as a storage unit or device where data to
be processed and the instructions necessary for processing are kept. Both input
and output data can be stored in memory.
How Computer Memory Communicates With the CPU ?
Computer memory communicates with the CPU through a structured
system of electronic pathways and controllers, enabling the CPU to fetch and
store data rapidly and efficiently. Here’s a detailed breakdown:
 System Bus Structure:
The main channel for communication between the CPU and memory is
the system bus, which is a collection of three types of buses:
o Data Bus: Transfers the actual data between CPU and memory.
o Address Bus: Carries the memory address that specifies where
data should be read from or written to.
o Control Bus: Sends signals that coordinate and control the
activity, such as indicating read or write operations.
 Memory Controller:
Communication is orchestrated by a memory controller, which manages the
flow of data and ensures that signals between the CPU and memory are
synchronized. In older systems, this controller was located on the
motherboard; in modern computers, it’s typically integrated into the CPU
for greater speed and efficiency

Communication Process:
1. When the CPU needs to access data or instructions in memory, it places the
address of the required memory location on the address bus.
2. The CPU sends a control signal (read or write command) on the control bus.
3. If reading, the memory controller retrieves the data from the specified
address and sends it back to the CPU via the data bus. If writing, the CPU
sends data over the data bus to be stored at the designated memory location.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

4. This process is repeated billions of times per second during computing


operations, forming the backbone of the fetch-decode-execute cycle used to
run programs

Types of Computer Memory


In general, computer memory is divided into three types:
 Primary memory
 Secondary memory
 Cache memory
Now we discuss each type of memory one by one in detail:
1. Primary Memory
It is also known as the main memory of the computer system. It is used to store
data and programs, or instructions during computer operations. It uses
semiconductor technology and hence is commonly called semiconductor
memory. Primary memory is of two types:

RAM (Random Access Memory):


It is a volatile memory. Volatile memory stores information based on the power
supply. If the power supply fails/ interrupted/stopped, all the data and
information on this memory will be lost. RAM is used for booting up or starting
the computer. It temporarily stores programs/data which has to be executed
by the processor. RAM is of two types:

 S RAM (Static RAM):S RAM uses transistors and the circuits of this memory
are capable of retaining their state as long as the power is applied. This
memory consists of the number of flip flops with each flip flop storing 1 bit.
It has less access time and hence, it is faster.
 D RAM (Dynamic RAM):D RAM uses capacitors and transistors and stores
the data as a charge on the capacitors. They contain thousands of memory
cells. It needs refreshing of charge on capacitor after a few milliseconds. This
memory is slower than S RAM.

ROM (Read Only Memory):


It is a non-volatile memory. Non-volatile memory stores information even when
there is a power supply failed/ interrupted/stopped. ROM is used to store
information that is used to operate the system. As its name refers to read-only
memory, we can only read the programs and data that are stored on it. It
contains some electronic fuses that can be programmed for a piece of specific
information. The information is stored in the ROM in binary format. It is also
known as permanent memory. ROM is of four types:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 MROM(Masked ROM): Hard-wired devices with a pre-programmed


collection of data or instructions were the first ROMs. Masked ROMs are a
type of low-cost ROM that works in this way.
 PROM (Programmable Read Only Memory): This read-only memory is
modifiable once by the user. The user purchases a blank PROM and uses
a PROM program to put the required contents into the PROM. Its content
can't be erased once written.
 EPROM (Erasable Programmable Read Only Memory):EPROM is an
extension to PROM where you can erase the content of ROM by exposing it
to Ultraviolet rays for nearly 40 minutes.
 EEPROM (Electrically Erasable Programmable Read Only Memory): Here
the written contents can be erased electrically. You can delete and
reprogram EEPROM up to 10,000 times. Erasing and programming take
very little time, i.e., nearly 4 -10 ms(milliseconds). Any area in an EEPROM
can be wiped and programmed selectively.

2. Secondary Memory
It is also known as auxiliary memory and backup memory. It is a non-volatile
memory and used to store a large amount of data or information. The data or
information stored in secondary memory is permanent, and it is slower than
primary memory. A CPU cannot access secondary memory directly. The
data/information from the auxiliary memory is first transferred to the main
memory, and then the CPU can access it.

Characteristics of Secondary Memory


 It is a slow memory but reusable.
 It is a reliable and non-volatile memory.
 It is cheaper than primary memory.
 The storage capacity of secondary memory is large.
 A computer system can run without secondary memory.
 In secondary memory, data is stored permanently even when the power is
off.

Types of Secondary Memory

1. Magnetic Tapes: Magnetic tape is a long, narrow strip of plastic film with a
thin, magnetic coating on it that is used for magnetic recording. Bits are
recorded on tape as magnetic patches called RECORDS that run along many
tracks. Typically, 7 or 9 bits are recorded concurrently. Each track has one
read/write head, which allows data to be recorded and read as a sequence of
characters. It can be stopped, started moving forward or backwards or
rewound.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

2. Magnetic Disks: A magnetic disk is a circular metal or a plastic plate and


these plates are coated with magnetic material. The disc is used on both sides.
Bits are stored in magnetized surfaces in locations called tracks that run in
concentric rings. Sectors are typically used to break tracks into pieces.

Hard discs are discs that are permanently attached and cannot be removed by
a single user.

3. Optical Disks: It's a laser-based storage medium that can be


written to and read. It is reasonably priced and has a long
lifespan. The optical disc can be taken out of the computer
by occasional users.

Types of Optical Disks


CD - ROM
 It's called a compact disk. Only read from memory.
 Information is written to the disc by using a controlled laser beam to burn
pits on the disc surface.
 It has a highly reflecting surface, which is usually aluminium.
 The diameter of the disc is 5.25 inches.
 16000 tracks per inch is the track density.
 The capacity of a CD-ROM is 600 MB, with each sector storing 2048 bytes
of data.
 The data transfer rate is about 4800KB/sec. & the new access time is
around 80 milliseconds.

WORM-(WRITE ONCE READ MANY)


 A user can only write data once.
 The information is written on the disc using a laser beam.
 It is possible to read the written data as many times as desired.
 They keep lasting records of information but access time is high.
 It is possible to rewrite updated or new data to another part of the disc.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Data that has already been written cannot be changed.


 Usual size - 5.25 inch or 3.5 inch diameter.
 The usual capacity of a 5.25-inch disk is 650 MB,5.2GB etc.

DVDs
The term "DVD" stands for "Digital Versatile/Video Disc," and there are two
sorts of DVDs:

 DVDR (writable)
 DVDRW (Re-Writable)
 DVD-ROMS (Digital Versatile Discs): These are read-only memory (ROM)
discs that can be used in a variety of ways. When compared to CD-ROMs,
they can store a lot more data. It has a thick polycarbonate plastic layer that
serves as a foundation for the other layers. It's an optical memory that can
read and write data.
 DVD-R: DVD-R is a writable optical disc that can be used just once. It's a
DVD that can be recorded. It's a lot like WORM. DVD-ROMs have capacities
ranging from 4.7 to 17 GB. The capacity of 3.5-inch disk is 1.3 GB.

3. Cache Memory
Cache Memory is a type of high-speed semiconductor memory that can help
the CPU run faster. Between the CPU and the main memory, it serves as a
buffer. It is used to store the data and programs that the CPU uses the most
frequently.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Advantages of Cache Memory


 It is faster than the main memory.
 When compared to the main memory, it takes less time to access it.
 It keeps the programs that can be run in a short amount of time.
 It stores data for temporary use.

Disadvantages of Cache Memory


 Because of the semiconductors used, it is very expensive.
 The size of the cache (amount of data it can store) is usually small.

What is Flash Drive?


A flash drive, also known as a USB drive, is a portable storage device Introduced
in the early 2000s offering a compact and durable solution for data storage
using the technology of NAND flash memory. it relies on NAND flash memory
for organizing data into pages and blocks and is connected via a USB interface
to provide plug-and-play functionality they arrive With diverse storage
capacities and advancements like USB 3.0 and 3.1 standards, they have
become essential for secure and efficient data management in everyday tasks.
Key Features and Functionality

Flash Drive the little wonder of modern data storage is praised and preferred
because of its three abilities simplicity, portability, and durability. this little
wonder has become an integral part of our technological life. providing us with
a convenient and efficient way of storing and transporting data. let's have a
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

look at the key features that make them stand out and become so special in
everyone's life.
 Compact Design and Portability: The flash drive The Little
Wonder mainly consists of a small, lightweight circuit board that is covered
with a protective shell with a USB connecter at one end due to this compact
design Flash drives are incredibly portable, making them fit in pocket or are
made attractive and used as a key chain or easily can have a place in Bag
their compact size has been the reason they are preferred.
 Plug-and-Play Functionality: The plug-and-play functionality of Flash
Drive is the hallmark, it builds the trust of users toward the flash drive as
the user need not to perform installation or append additional drivers they
just can easily connect their flash drive to the USB port of their computer.
this easy functionality helps flash drives to become universally compatible
with many devices such as desktops, computers, and even some advanced
smart TVs.
 don't contain any Moving Parts: Flash Drives Work on Nand flash memory
chips so does not contain any moving parts that will cause problems or
errors the traditional hard drives work on spinning disks to read and write
data at this point flash drives lead because they do not contain any moving
part. this absence of moving parts not only enhances durability but also
helps in faster access to data.
 NAND Flash Memory Technology: Flash Drives use NAND flash
memory technology for storing data this is a nonvolatile memory which
means it retains data even if power is removed, also NAND flash memory
technology is renowned for its speed and reliability, which provides quick
access to stored data. this efficiency of technology has played an important
role in the end and adoption of Flash Drive for personal or professional use.
 Robust and Durable: flash drives are built to withstand the roughness of
daily use by having an absence of delicate moving parts, and also have a
protective case which makes them more robust and durable than traditional
storage devices, this functionality ensures that flash drives retain the data
even in up's and down's of everyday life and does not compromise with the
integrity of the data stored.

Storage Capacities and Advancements

The evolution of Flash Drives is the mirror image of the superfast pace of
technological progress, particularly in fields related to Data storage or usage.
from humble and quiet beginnings with some megabyte storage, flash drives
have witnessed remarkable transformations, growing as powerhouse devices
which is capable of storing terabytes of data.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

What is Pen Drive?


A pen drive also known as a USB flash drive, is a data storage device that
includes flash memory with an integrated USB interface. A typical USB drive is
removable, rewritable, and smaller than an optical disc, and usually weighs
less than 30 g. A pen drive is a small yet powerful device that can help you
transfer files between devices easily and quickly. It has revolutionized how we
store and transfer data.
In this article, we will discuss what is pen drive, its history, how it works,
various types of pen drives, benefits, real-life applications, and common uses
of pen drives. We will also discuss what is the difference between a pen drive
and a flash drive.

History of Pen Drives


Early Storage Devices: Before pen drives came into the market, data storage
was a hard task. Devices such as floppy disks, CDs and even bulky external
hard drives were used which had limited storage capacity and were prone to
damage and data loss.
Development of USB Technology: The mid-1990s saw the birth of USB
(Universal Serial Bus) technology, which was a major game-changer. USB
connections became a common feature on computers, enabling faster and more
reliable data transfer.
Introduction of First Pen Drive: IBM introduced the first pen drive in 2000,
with a modest 8 MB storage capacity. This was groundbreaking at the time,
providing a portable and efficient method of data transport. Pen drive storage
capacity and capabilities grew parallels with technological advancement.

How Does a Pen Drive Work?


 Basic Components: A USB drive consists of a USB connector, a flash
memory chip, and a circuit board all enclosed in a protective casing. The
USB connector enables the pen drive to connect with different devices, while
the flash memory chip holds the data.
 Mechanism For Storing Data: Information is saved in the flash memory
chip by means of electrical charges. This technique enables fast information
access and retrieval, making pen drives highly effective.
 Process of Transferring Data: When you insert a USB flash drive into a
USB port, it interacts with the operating system of your computer, enabling
you to easily move files by dragging and dropping them. The easy-to-use
nature of this process is a major factor driving the widespread use of pen
drives.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Types of Pen Drives

There are mainly 4 types of pen drives:


Type of Pen
Drive Description Use Cases

Feature a standard USB-A General use, transferring


Standard
connector. Compatible with files between computers and
USB Drives
most computers and laptops. laptops.

Designed for smartphones


On-the-go use, transferring
Micro USB and tablets. Equipped with a
files between smartphones,
Drives micro USB or USB-C
tablets, and computers.
connector.

Come with dual connectors, Ideal for users who


OTG (On-
compatible with standard frequently switch between
The-Go)
USB-A ports and micro USB devices like computers,
Drives
or USB-C ports. smartphones, and tablets.

Suitable for users who


Feature built-in encryption
Secure USB prioritize data security and
and password protection for
Drives need to store sensitive
enhanced data security.
information securely.

Advantages of Using Pen Drives


 Portability: Mobility is one of the key benefits of pen drives. They are
compact enough to be stored in your pocket, allowing you to bring a
significant quantity of data wherever you go.
 User-Friendly: Pen drives are user-friendly. Simply insert them into your
device, and you're all set to transfer files or store data. There is no
requirement for extra software or complex setup procedures.
 Versatility: Pen drives can be used for transferring files between computers,
backing up important documents, or creating a bootable device for system
recovery, demonstrating their high level of versatility.

Use of Cloud storage and AI auto-backup tools (Google Drive, OneDrive with
Copilot)
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Cloud storage platforms like OneDrive and Google Drive provide automatic
backup and synchronization, while AI tools such as Microsoft Copilot in
OneDrive offer advanced file management capabilities, including summarizing,
comparing, and extracting information from documents. Users can store files
securely, access them across devices, and collaborate in real-time. Copilot,
available in OneDrive for Microsoft 365 subscribers, helps users quickly
understand and process information within their stored files, enhancing
productivity and streamlining workflows by reducing manual effort.

Cloud Storage & Automatic Backup Features

 Automated Backup:
Services like OneDrive automatically back up important files from your PC,
including Desktop, Documents, and Pictures folders, to the cloud.
 Cross-Device Access:
Files stored in the cloud are accessible from any device through web or mobile
apps, allowing you to view and edit them anywhere.
 Version History:
Cloud storage typically includes a version history feature, enabling you to easily
restore previous versions of your files.
 Mobile Scans:
Mobile apps allow you to scan and store documents, receipts, and other
physical items directly into your cloud storage.
 Space Optimization:
Cloud storage helps free up space on your local devices by allowing you to
access files on demand without storing them all locally.

AI Tools (e.g., Copilot in OneDrive)

 File Summarization:
Copilot can instantly summarize lengthy documents, highlighting key points
and providing quick overviews without you having to open the file.
 Document Comparison:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

The AI can compare multiple files, quickly identifying differences and common
details between them.
 Information Extraction & Insights:
Copilot can extract relevant information from your documents, generating
insights and answers to your questions about the files.
 Streamlined Workflow:
These AI features reduce the preparatory work involved in file management,
allowing users to spend more time on their actual tasks and projects.
 Integration with Microsoft 365:
Copilot is integrated into the Microsoft 365 ecosystem, working with files stored
in OneDrive and accessible via the OneDrive website.

How to Use

1. 1. Set up your Cloud Storage:


Sign in to your account (e.g., Microsoft account for OneDrive, Google account
for Google Drive).
2. 2. Enable PC Folder Backup:
In your cloud storage settings, configure the automatic backup for important
folders on your computer.
3. 3. Install Mobile Apps:
Download the mobile apps for your respective cloud storage provider (OneDrive
or Google Drive) to back up your phone's camera roll and scan documents.
4. 4. Use AI Features:
If using OneDrive with Microsoft 365, access Copilot through the OneDrive
website or within compatible apps to summarize, compare, and get insights
from your files
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Unit -2nd
(Input & Output Devices)

Input Devices:-
Input devices are important parts of a computer that help us communicate with
the system.
 These devices let us send data or commands to the computer, allowing it to
process information and perform tasks.
 Whether it's typing on a keyboard or clicking a mouse, these devices enable
us to interact with the computer and accomplish tasks.

How Does an Input Device Work?


An input device converts user actions or physical movements into signals that
the computer can understand and process.
 Signal Conversion: Input devices convert physical actions (e.g., pressing a
key, moving a mouse) into electrical signals that the computer can
understand.
 Data Transmission: These electrical signals are transmitted to the
computer’s processor, typically via USB, Bluetooth, or wireless connections.
 Processing by the CPU: Once the signals reach the processor, the data is
interpreted and processed by the computer to carry out the desired task
(e.g., typing a letter, moving a cursor).
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 User Interaction: The user interacts with the input device (keyboard,
mouse, etc.), and the device sends corresponding data to the computer
based on user input.
 Feedback to the User: In some cases, input devices provide feedback (e.g.,
vibration in a game controller or sound from a keyboard key press) to
confirm the input was registered.

Different Types of Input Devices


There are Various types of Input Devices and in the below section you will
explore all types of input devices.

Keyboard
Keyboard is the most common and commonly used input device. It allow users
to input text and commands. Keyboard contains various keys for entering
letters, numbers, and characters. Although there are some additional keys for
completing various activities.

Types of Keys on the Keyboard


 Numeric Keys: These keys are used to enter numeric data and move the
cursor. It is typically made up of 17 keys.
 Keyboard Shortcuts: These keys include the letter keys (A-Z) and the
number keys (09).
 Control Keys: The pointer and the screen are controlled by these keys. It
comes with four directional arrow keys. Control keys include Home, End,
Insert, Alternate(Alt), Delete, Control(Ctrl), and Escape.
 Special Keys: Enter, Shift, Caps Lock, NumLk, Tab, and Print Screen are
some of the special function keys on the keyboard.
 Function Keys: The 12 keys from F1 to F12 are on the topmost row of the
keyboard.

Types of Keyboard
Generally, there are three types of keyboard and they are:

 QWERTY Keyboard: It is the most common type of keyboard layout used in


computers and typewriters. It is named after the first six letters in the top
row of the keyboard (Q, W, E, R, T, Y).
 AZERTY Keyboard: This keyboard layout commonly used in French-
speaking countries, named after the first six letters in the top row (A, Z, E,
R, T, Y).
 DVORAK Keyboard: This keyboard layout designed by Dr. August Dvorak
and William Dealey in the 1930s to improve typing efficiency. Unlike the
QWERTY keyboard, this keyboard arranged to make typing faster and less
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

tiring by putting common letters like A, E, I, O, U, and others under the


strongest fingers.

Mouse
The mouse is the most commonly used pointing device. It’s a small, handheld
device that you move on a flat surface to control a cursor or pointer on the
screen. By clicking buttons or scrolling a wheel on the mouse, you can select
items, open files, drag objects, or navigate programs. Mouse was invented in
1963 by Douglas C. Engelbart.
Different Types of Mouse
 Trackball Mouse: A mouse with a ball on top that you roll with your fingers
to move the cursor. The mouse stays still, making it good for small spaces.
 Mechanical Mouse: An older mouse with a rubber ball inside that rolls on
a surface to move the cursor. It uses moving parts to track motion.
 Optical Mouse: A mouse that uses a light sensor (LED or laser) to detect
movement on a surface, providing smoother and more accurate cursor
control.
 Wireless Mouse: A mouse that connects to the computer without a cable,
using batteries and wireless signals (like Bluetooth or USB receiver) for
freedom of movement.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Joystick
A pointing device used to move the cursor around the screen is the joystick.
Both the bottom and top ends of the stick have a spherical ball affixed to them.
A socket contains the lower spherical ball. You can adjust the joystick in all
directions. Trackballs became quite popular in laptops and PCs since they fit
neatly inside the case and take up less room when in use. They are more precise
and long-lasting than a mouse, which is why they are still utilised. It was
invented by [Link].

Types pf Joysticks
 Analog Joystick: A joystick that tilts in any direction for smooth, variable
control, used in gaming controllers for precise movements.
 Digital Joystick: A joystick that moves in fixed directions (e.g., up, down,
left, right), giving simple on/off signals, used in old arcade games.
 Flight Joystick: A joystick for flight simulation games or aircraft, with a
stick, throttle, and buttons for realistic flying control.
 Paddle Joystick: A simple joystick with limited movement, often rotating or
sliding, used in early games like Pong for basic control.
 Handheld Joystick: A small joystick on portable controllers or devices, used
for quick movements in video games or drones.
 Industrial Joystick: A strong joystick for controlling machines like cranes
or robots, designed for precise and durable industrial use.

MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Light Pen
A light pen is a pointing device that has the appearance of a pen. It can be used
to draw on the monitor screen or to pick a menu item. In a small tube, a
photocell and an optical system are housed. The photocell sensor element
determines the screen location and sends a signal to the CPU when the tip of a
light pen is moved across a monitor screen while the pen button is pressed.
Types of Light Pen
 Corded Light Pen: A pen-shaped device with a wire connecting to the
computer, used to point or draw on CRT screens without needing a battery.
 Battery Light Pen: A wireless light pen powered by a battery, used for
drawing or selecting on digital screens, offering portability.
 Design Light Pen: A light pen for artists to sketch or create digital art and
3D designs with high precision on screens.
 LED Light Pen: A light pen with a bright LED tip for clear visibility, used for
pointing, writing, or drawing on digital displays.
 Optical Digital Pen: A modern pen with a camera or laser to capture
coordinates, works on tablets or special paper, often wireless.
 Active Pen (Smart Pen): An advanced light pen with features like pressure
sensitivity, used for precise digital drawing or design on modern devices.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Scanner
A scanner is a type of input device that works in the same way as a photocopier.
It's used when there's data on paper that needs to be transferred to the
computer's hard disc for further processing. The scanner collects images from the
source and translates them into a digital version that can be saved on the hard
disk. These graphics can be changed before they are printed.

Types of Scanner
 Flatbed Scanner: A scanner with a flat glass surface where you place
documents or photos to scan. It creates digital images and is common for
home or office use.
 Handheld Scanner: A small, portable scanner you move by hand over a
document or object to scan. It’s useful for quick scans but less accurate.
 Sheetfed Scanner: A scanner that pulls in sheets of paper one by one to
scan, often used in offices for scanning multiple pages quickly.
 Drum Scanner: A high-quality scanner that uses a rotating drum to scan
images or documents, providing very detailed and accurate results, often
used for professional printing.
 Photo Scanner: A scanner designed specifically for scanning photos,
offering high resolution to capture fine details and colors for digital photo
storage.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Barcode Reader
A bar code reader is a device that reads bar-coded data (data that is represented
by light and dark lines). To label things, number books, and so on, bar-coded
data is often utilized. It could be a standalone scanner or a component of one.
A barcode reader is a device that reads barcodes and extracts data from them.
The code bar is used to read the barcode printed on any goods. By impacting
light beams on barcode lines, a barcode reader identifies existing data in
barcodes.
Types of Barcode Reader

 Pen-Type Barcode Reader (Wand Scanner): A pen-shaped device you swipe


over a barcode to read it with a light sensor, simple but needs steady hands.
 Laser Barcode Reader: Uses a laser beam to read barcodes quickly and
accurately, often handheld or fixed, used in stores.
 CCD Barcode Reader (LED Scanner): Uses LED lights to read barcodes up
close, durable and reliable, used in retail or libraries.
 Camera-Based Barcode Reader (2D Imager): Uses a camera to read 1D or
2D barcodes like QR codes, versatile for phones or scanners.
 Omnidirectional Barcode Reader: Reads barcodes from any angle with
multiple lasers, very fast, used in busy stores.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Web Camera
A webcam is an input device since it records a video image of the scene in front
of it. It can either be incorporated inside the computer (for example, a laptop)
or connected via USB. A webcam is a small digital video camera that is
connected to a computer. Because it can capture pictures and record video, it's
also known as a web camera.

Types of Webcam
 USB Webcam: A webcam that connects to a computer with a USB cable,
used for video calls or online classes, affordable and easy to set up.
 Wireless Webcam: A webcam that works without cables, using Wi-Fi or
Bluetooth, allowing movement but may need batteries or charging.
 Built-in Webcam: A webcam built into devices like laptops or monitors,
convenient for video calls but often fixed and lower quality.
 HD Webcam: A webcam that records in high-definition (720p or 1080p) for
clear, sharp video, great for streaming or professional video calls.
 4K Webcam: A webcam that captures ultra-high-definition (4K) video for
very detailed images, used for professional streaming or video production.
 PTZ Webcam: A webcam that can pan, tilt, and zoom, controlled remotely,
used for flexible video capture in meetings or surveillance.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Graphic Tablets
A graphics tablet, also known as a digitizing tablet, is a computer input device
that allows users to draw and graphics by hand, much like they would with a
pencil and paper. A graphics tablet is a flat surface on which the user can draw
a picture with the help of an attached stylus, which is a pen-like drawing device.

Types of Graphic Tablets


 Pen Tablet (Non-Display Graphic Tablet): A flat tablet where you draw with
a stylus, and the image shows on a computer screen, affordable for digital
drawing.

 Display Tablet (Pen Display Tablet): A tablet with a screen where you draw
directly, seeing the image under the stylus, precise but costly.

 Portable Graphic Tablet: A lightweight, often wireless tablet, easy to carry


for drawing anywhere, connects via Bluetooth or cable.

 Smart Graphic Tablet: A tablet with advanced features like touch gestures
and apps, can work as a standalone computer for drawing or other tasks.

 Passive Graphic Tablet: A tablet using a battery-free stylus, detected by the


tablet’s surface, making the pen light and easy to use.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Touchscreen
A touchscreen is a type of input device that allows users to interact with a
digital display by directly touching the screen's surface. It enables the user to
perform various actions, such as selecting options, typing on a virtual
keyboard, drawing, or manipulating objects, by physically touching the screen.

Types of Touchscreen

 Resistive Touchscreen: A screen with two layers that detect touch when
pressed together, works with fingers or stylus, used in older devices like
ATMs.
 Capacitive Touchscreen: A screen that senses touch through the body’s
electrical charge, very sensitive with clear displays, used in smartphones
and tablets.

 Infrared Touchscreen: A screen that uses infrared light beams to detect


touch, works without pressure, used in large displays like interactive
whiteboards.

 Surface Acoustic Wave (SAW) Touchscreen: A screen that uses sound


waves to detect touch, clear and durable but sensitive to dirt, used in kiosks.

 Optical Touchscreen: A screen that uses cameras or sensors to track


touch, supports multi-touch and works on large displays, used in digital
signage.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Voice and Gesture


The evolution of user interfaces (UI) has been remarkable, shifting from graphical
user interfaces (GUIs) reliant on clicks and taps to a new paradigm of voice and
gesture-based interactions. This future-forward design is driven by
advancements in artificial intelligence (AI), natural language processing (NLP),
and motion-sensing technologies. Voice and gesture interfaces promise hands-
free, intuitive experiences that feel natural and immersive.

In this blog, we’ll explore the potential of these interaction modes, the
challenges designers face, and strategies for crafting effective voice and gesture-
driven UIs.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Why Voice and Gesture UIs Are the Future


1. Natural Interaction
Voice and gesture interfaces align with human instincts. Speaking and
gesturing are innate, requiring little to no learning curve compared to
traditional interfaces.
2. Accessibility
These interfaces provide opportunities for users with physical disabilities or
limitations, offering alternative ways to interact with technology.
3. Immersive Experiences
For environments like virtual reality (VR) and augmented reality (AR), gestures
and voice commands create seamless, hands-free engagement.
4. Ubiquitous Devices
From smartphones to smartwatches, home assistants, and cars, devices
capable of recognizing voice and gestures are becoming ubiquitous, paving the
way for consistent cross-device experiences.
Designing for Voice UIs
Voice user interfaces (VUIs) enable users to interact with devices using speech.
Examples include Siri, Alexa, and Google Assistant.
Key Principles for Voice UI Design
1. Conversational Design
Design interactions to mimic natural conversations, including turn-taking and
context awareness.
Use NLP to understand nuances, such as tone, synonyms, and phrasing.
2. Clarity and Simplicity
Provide clear instructions and prompts to guide users.
Avoid jargon or complex commands; opt for simple, actionable language.
Example: Instead of “Initiate playback of playlist named Relaxation,” use “Play
my relaxation playlist.”
3. Feedback and Confirmation
Offer immediate audio or visual feedback to confirm commands.
Use auditory cues, like tones or spoken acknowledgments, to keep users
informed of system status.
Example: Alexa’s light ring or audible confirmation after setting a timer.
4. Context Awareness
Mobile design VUIs to recognize user context, such as location, past interactions,
and time of day.
Contextual intelligence ensures more personalized and relevant responses.
5. Error Handling
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Provide graceful fallback options when commands are unclear or not


recognized.
Suggest alternatives or ask clarifying questions instead of displaying a generic
error.
Example: “I didn’t catch that. Did you mean to call Rao?”
Designing for Gesture UIs
Gesture-based UIs use physical movements or touchless gestures for
interaction. These interfaces are prevalent in AR/VR systems, gaming consoles
like Xbox Kinect, and even smartphones with motion sensors.
Key Principles for Gesture UI Design
1. Intuitive Gestures
Base gestures on familiar human actions. For example, a swipe to scroll or a
pinch to zoom are universally understood.
Avoid overcomplicating with arbitrary or hard-to-remember gestures.
2. Real-Time Feedback
Provide immediate visual or haptic feedback to validate gesture recognition.
Feedback reassures users that their actions are recognized and executed.
3. Consistency
Standardize gestures across applications to reduce cognitive load.
A swipe gesture, for instance, should behave similarly across apps and devices.
4. Minimal Effort
Design gestures that require minimal physical effort to reduce fatigue.
For example, limit prolonged or repetitive arm motions for gesture-controlled
systems.
5. Adaptability
Allow customizable gestures for diverse user preferences.
Enable users to calibrate sensitivity based on their comfort and physical
capabilities.
Challenges in Designing Voice and Gesture Interfaces
1. Ambiguity in Input
Voice commands and gestures can be ambiguous or misinterpreted, leading to
frustration. For example, accents, background noise, or subtle hand
movements might not be recognized correctly.
2. Lack of Visual Cues
Unlike GUIs, voice and gesture interfaces often lack visible options, which can
make them feel less discoverable and harder for new users to navigate.
3. Over-Reliance on AI
The success of voice and gesture UIs depends heavily on AI capabilities. Errors
in speech recognition or gesture tracking can break the user experience.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

4. Accessibility Gaps
While voice and gesture interfaces are more accessible to some users, they may
exclude others. For instance:
Voice commands may not be suitable for noisy environments.
Gesture controls might be challenging for users with limited mobility.
5. Privacy Concerns
Always-on devices capable of recognizing voice or gestures raise concerns about
data security and user privacy.

Virtual assistant:
A virtual assistant (VA) is a software agent that can perform a range of tasks
or services for a user based on user input such as commands or questions,
including verbal ones. Such technologies often incorporate chatbot capabilities
to streamline task execution. The interaction may be via text, graphical
interface, or voice - as some virtual assistants are able to interpret human
speech and respond via synthesized voices.
In many cases, users can ask their virtual assistants questions, control home
automation devices and media playback, and manage other basic tasks such
as email, to-do lists, and calendars - all with verbal commands. In recent years,
prominent virtual assistants for direct consumer use have included Apple
Siri, Amazon Alexa, Google Assistant (Gemini), Microsoft copilot and Samsung
Bixby.[2] Also, companies in various industries often incorporate some kind of
virtual assistant technology into their customer service or support.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Into the 2020s, the emergence of artificial intelligence based chatbots, such
as ChatGPT, has brought increased capability and interest to the field of virtual
assistant products and services.

Virtual assistants may be integrated into many types of platforms or, like
Amazon Alexa, across several of them:
Into devices like smart speakers such as Amazon Echo, Google Home and Apple
HomePod
In instant messaging applications on both smartphones and via the Web, e.g. M
(virtual assistant) on both Facebook and Facebook Messenger apps or via the
Web
Built into a mobile operating system (OS), as are Apple's Siri on iOS devices
and BlackBerry Assistant on BlackBerry 10 devices, or into a desktop OS such
as Cortana on Microsoft Windows OS
Built into a smartphone independent of the OS, as is Bixby on the Samsung
Galaxy S8 and Note 8.
Within instant messaging platforms, assistants from specific organizations,
such as Aeromexico's Aerobot on Facebook Messenger or WeChat Secretary.
Within mobile apps from specific companies and other organizations, such as
Dom from Domino's Pizza
In appliances, cars, and wearable technology such as the Ai Pin
Previous generations of virtual assistants often worked on websites, such
as Alaska Airlines' Ask Jenn, or on interactive voice response (IVR) systems
such as American Airlines' IVR by Nuance.

Google Assistant
The privacy policy of Google Assistant states that it does not store the audio data
without the user's permission, but may store the conversation transcripts to
personalize its experience. Personalization can be turned off in settings. If a user
wants Google Assistant to store audio data, they can go to Voice & Audio Activity
(VAA) and turn on this feature. Audio files are sent to the cloud and used by
Google to improve the performance of Google Assistant, but only if the VAA
feature is turned on.

Amazon Alexa
The privacy policy of Amazon's virtual assistant, Alexa, states that it only listens
to conversations when its wake word (like Alexa, Amazon, Echo) is used. It starts
recording the conversation after the call of a wake word, and stops recording
after 8 seconds of silence. It sends the recorded conversation to the cloud. It is
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

possible to delete the recording from the cloud by visiting 'Alexa Privacy' in
'Alexa'.

Apple's Siri
Apple states that it does not record audio to improve Siri. Instead, it claims to
use transcripts. Transcript data is only sent if it is deemed important for
analysis. Users can opt out anytime if they don't want Siri to send the transcripts
in the cloud.

Cortana
Cortana is a voice-only virtual assistant with singular authentication. This voice-
activated device accesses user data to perform common tasks like checking
weather or making calls, raising privacy concerns due to the lack of secondary
authentication.

Output Devices: An output device is a hardware device that is used to show


the processed results to the user in the form of text, audio, video, visuals on a
computer screen or a printed hard copy on paper. The output devices are mainly
categorized as audio output devices, visual output devices, audio-video output
devices, and print-based output devices. Different output devices can be
connected to computer systems to retrieve the output, based on the type of
output and requirements.
Following are some of the important output devices used in a computer.
1. Monitors
2. Graphic Plotter
3. Printer
4. Speakers
5. Headphones
6. Projector
7. GPS

Monitors
Monitors also known as Visual Display Unit (VDU), is an output device of a
computer. It is the most popular output device which looks like a TV screen
and shows the output in the form of text, audio, video and images. Overall, it
produces output with visual effects to connect the user with the system. Images
data form tiny dots, called pixels that are arranged in a rectangular form. The
sharpness of the image depends upon the number of pixels.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

There are two kinds of viewing screens used for monitors.


I. Cathode-Ray Tube (CRT)
II. Flat-Panel Display

Cathode-Ray Tube (CRT) Monitor


The CRT display is made up of small picture elements called pixels. The smaller
the pixels, the better the image clarity or resolution. It takes more than one
illuminated pixel to form a whole character, such as the letter e in the word
help.

A finite number of characters can be displayed on a screen at once. The screen


can be divided into a series of character boxes - a 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.

Components of Cathode-Ray Tube (CRT) Monitor


The key components of a CRT Monitor are as follows −
I. Electron Guns − Produces beams of electrons to display images
II. Phosphorescent Screen − Once electrons hit on phosphor-coated screen,
it glows and makes visibility
III. Circuit Board − Provides connectivity for external circuitry
IV. Deflection Yoke − It deflects the electron beam in precise patterns

Advantages
I. Produces output with visual effects.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

II. It has good resolutions which ensure proper visibility of image-related


outputs.
III. No motion blur due to instant response time.
IV. It can display multiple resolutions without scaling artefacts.
V. It has high refresh rates which reduces flicker and eye strain.

Disadvantages
I. Large in Size
II. Carries high weight
III. A lot of power consumption
IV. Produces heat

Flat-Panel Display Monitor


The flat-panel display refers to a class of video devices that have reduced
volume, weight and power requirements 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 computers, and
graphics displays.

The flat-panel display is divided into two categories −


Emissive Displays − Emissive displays are devices that convert electrical energy
into light. For example, plasma panels and LED (Light-Emitting Diodes).
Non-Emissive Displays − Non-emissive displays use optical effects to convert
sunlight or light from some other source into graphics patterns. For example,
LCD (Liquid-Crystal Device).

Components of Flat-Panel Display Monitor


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

The key components of a Flat-Panel Display Monitor are as follows −


I. Liquid Crystal Display (LCD) − It is positioned between two layers of glass
or plastic and modulates light to create images.
II. Light Emitting Diode (LED) − it emits light and improves color and
contrast.
III. Plasma Display Panel (PDP) − It contains small cells with phosphor
coated to emit light.
IV. Quantum Dot Display − It contains quantum dots to enhance color
accuracy.

Advantages
Some of the key advantages of Flat-Panel Display Monitor are as follows −
I. Smaller in size makes it easy to mount and transport.
II. It consumes less power.
III. It has higher resolutions which makes good picture quality.
IV. It makes users comfortable to get connected for a longer period and
reduces eye strain.
V. Available in different sizes.

Disadvantages
I. Expensive as compared to CRT monitors.
II. Its resolution is not up to mark as compared to CRT.
III. It is a soft covering which may damage and be difficult to clean.

Graphic Plotter
A plotter, which is a type of printer, receives instructions from a computer to
produce line drawings on paper using one or more automated pens. In contrast
to a standard printer, a plotter can create uninterrupted point-to-point lines
directly from vector graphic files or commands. Computer graphics and
engineering applications employ graphic plotters to create high-quality,
accurate, and detailed drawings or plots on paper or other media. It draws
continuous lines accurately and is suited for vector drawings, unlike a standard
printer.
Key features of graphic plotters are as −
Vector Graphics − Vector graphics allow graphic plotters to create lines and
shapes precisely using continuous points instead of dots like raster printers.

Pen or Pen-Like Tool − A pen or similar instrument is drawn on paper for


graphic plotters. The pen may move X and Y on a moveable arm to draw
complicated shapes.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Applications − Graphic plotters are employed in engineering, architecture,


cartography, and textile design. They were popular for technical drawings and
diagrams before digital.

A vector graphics plotter outputs accurate and detailed drawings. They are
still used in sectors and applications that need accuracy and high-quality
output, even if digital printing has made them less widespread.

Components of Graphic Plotters

The key components of a Graphic Plotter are as follows −


Plotter Head − A plotter head contains multiple pens of different colors to draw
images.
Plotting Surface − It is used to hold and feed paper.
Microcontroller − Controls the plotting process and interprets commands.
Interfaces − It provides interfaces to connect USB, Ethernet, or wireless
connections.
Memory − A device used to Store plotting instructions to process temporarily.

Types of plotters

 Pen Plotters − It uses vector graphics and line drawings.


 Drum plotters − A drum plotter is a device that uses a rotating drum to
draw on paper. The drum revolves to create one direction of the plot, while
the pens move to create the other direction.
 Flatbed plotters − Flatbed plotters are used to draw on paper placed on
a flat surface.
 Electrostatic plotters − This printer draws on negatively charged paper
with positively charged toner.
 Inkjet plotters − The printer uses vector graphic technology to control the
movement of the pen plotters, which in turn drop ink beads of different
colors onto the drawing surface.

Advantages
Some of the key advantages of Graphic Plotters are as follows −
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 High Resolution − It has good resolution which opens it for CAD


drawings.
 Colour Representation − It automatically sets colour matching in designs.
 Large Screen Size − It provides appropriate space to view large drawings.
 Software Compatibility − It is compatible with CAD software, graphic
design, and related tools.
 Preview Functionality − A user can preview plots on the monitor to reduce
errors and enhance accuracy.
 Editing Tools − Multiple editing tools are available for graphics before
plotting.
Printers
A printer is an output device, which is used to print processed data on paper.
It is one of the most popular output devices. The information that is printed is
commonly referred to as hard copy because it physically exists and is a more
enduring form of output than what is displayed on a VDU. Printers play a
crucial role in generating hard copies of digital documents and images and are
available in different types tailored to specific purposes and settings. They cater
to diverse user requirements, offering features such as top-notch photo
printing, speedy document output, and the ability to create three-dimensional
objects, making them suitable for home, office, or industrial use.

Types of Printer
Different types of Printers are categorized in the following image

Impact Printers
Impact printers print the characters by striking them on the ribbon, which is
then pressed on the paper.

Characteristics of Impact Printers are the following −


 Very low consumable costs
 Very noisy
 Useful for bulk printing due to low cost
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 There is physical contact with the paper to produce an image

Types of Impact Printers

Generally, Impact printers are of two types −


 Character printers
 Line printers

Character Printers
Character printers are the printers which print one character at a time. A
printer that holds individual characters until it is ready to print them. Instead
of printing one line at a time, a character printer prints one character at a time.
Nowadays, these printers are not commonly used due to speed limitations and
their ability to only print text.

Types of Character Printers


 Dot Matrix Printer(DMP)
 Daisy Wheel

Dot Matrix Printer


In the market, one of the most popular printers is Dot Matrix Printer. These
printers are popular because of their ease of printing and economical price.
Each character printed is in the form of a pattern of dots and the head consists
of a Matrix of Pins of size (5*7, 7*9, 9*7 or 9*9) which come out to form a
character which is why it is called Dot Matrix Printer.

Advantages
 Inexpensive
 Durable
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Widely Used
 Able to print on multi-part forms
 Low Operating Costs
 Reliable
 Other language characters can be printed

Disadvantages
 Slow Speed
 Poor Quality

Daisy Wheel
A daisy wheel printer is an impact printer that utilizes a spinning disk, known
as the "daisy wheel," which contains pre-formed characters embossed on its
"petals." During printing, the printer picks the appropriate petal, impacts it
against an ink ribbon, and then onto the paper to generate high-quality text.
The 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. In the 1970s and 1980s, daisy
wheel printers were commonly utilized for word processing before the
introduction of laser and inkjet printers.

Advantages
 It produces High-Quality Text so more suitable for professional
documents
 More reliable than DMP
 Better quality
 Fonts of character can be easily changed
 Durable so it has a long lifespan
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Each character is pre-formed which shows its consistent print quality

Disadvantages
 Slower than DMP
 Limited to Text
 Noisy
 More expensive than DMP
 Changes in fonts or styles need physical changes on the daisy wheel.

Line Printers:

Line printers are the printers which print one line at a time. Line printers are
specialized impact printers which are specifically designed to get high-speed,
high-volume printing, primarily for text. These are still useful in certain
applications where speed and durability are critical. Their capacity to print a
complete line of text at once distinguishes them from other impact printers,
making them excellent for applications requiring quick and consistent
document creation.

Types of Line Printer


 Drum Printer
 Chain Printer

Drum Printer:-

This printer is like a drum in shape hence it is called a drum printer. The
surface of the drum is divided into several tracks. Total tracks are equal to the
size of the paper, i.e. for a paper width of 132 characters, the drum will have
132 tracks. A character set is embossed on the track. Different character sets
available in the market are 48 character sets, 64 and 96 characters set. One
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

rotation of drum prints one line. Drum printers are fast and can print 300 to
2000 lines per minute.

Advantages
 Very high speed
 Low cost
 Durable so they can run a long life
 Able to handle large print volumes
 Provides good printing quality

Disadvantages
 Very expensive
 Characters fonts cannot be changed

Chain Printer: -
A chain printer is a high-speed line printer with a revolving chain mechanism
that prints characters on paper. Chain printers were widely used in large data
centers and business settings where high-volume printing was required. They
are well-known for their ability to handle huge print jobs quickly and efficiently.
In this printer, a chain of character sets is used; hence it is called a Chain
Printer. A standard character set may have 48, 64, or 96 characters.

Advantages
 Character fonts can easily be changed
 Able to print hundreds to thousands of lines per minute
 Durable
 Different languages can be used with the same printer
 Cost-effective for printing large quantities of text.

Disadvantages
 Noisy
 Limited Graphics
 Limited with fixed fonts and styles

Non-impact Printers: -
Non-impact printers print the characters without using the ribbon. These
printers print a complete page at a time, thus they are also called Page Printers.

These printers are of two types −


 Laser Printers
 Inkjet Printers

MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Characteristics of Non-Impact Printers


 Faster than impact printers
 They are not noisy
 High quality
 Supports many fonts and different character sizes

Laser Printers
These are non-impact page printers. They use laser lights to produce the dots
needed to form the characters to be printed on a page.

Advantages
 Very high speed
 Very high-quality output
 Good graphics quality
 Supports many fonts and different character sizes

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.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

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

Speakers

Speakers are standard output devices that are used to hear sound clearly from
a measurable distance. These are connected to the computer through sound
connectors directly while others can be linked to any sound system. The
primary purpose of speakers is to deliver audio output and enable users to
listen to the resulting sound.

Components of a Speakers
Some of the key components of speakers are as follows −
Magnet − It is an essential component fixed to speakers to create a magnetic
field.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Diaphragm (Cone) − It is made with paper, plastic and metal; it is used to create
sound waves.

Voice Coil − The diaphragm is connected to a voice coil of wire, which is placed
in the magnetic field of the magnet.

Suspension − This contains the spider and the surround. The spider keeps the
voice coil centred in the magnetic gap and the surround links the diaphragm
to the speaker frame and allows it to move freely.

How does the speaker work?

Speakers are electromagnetic waves that transform electromagnetic waves into


sound waves. The computer supplies audio input to the speakers. This input
may be analogue or digital. The voice coil generates an alternating magnetic
field when the audio signal passes through it. This magnetic field then interacts
with the stable magnetic field of the permanent magnet. Analogue speakers
merely amplify electromagnetic signals to generate sound waves. Sound waves
are analogue signals. Thus, digital speakers must convert the digital input to
an analogue signal before producing a sound wave that can be transmitted as
an output.
A speaker uses vocal commands to control a software programme. A computer
speaker is hardware that connects to a computer system and produces sound.
The computer's sound card contains the signal utilized to generate sound from
a computer speaker.

Types of speakers:

Some common types of speakers are as follows –

Electrostatic speaker − An electrostatic speaker contains an electrically


charged diaphragm which is positioned between two conductive plates. The
electrical signal causes the diaphragm to move, which generates sound.

Piezoelectric Speakers − These speakers use materials that change their


shape when an electric field is applied and then create sound waves.

Planar Magnetic Speakers − These speakers are similar to dynamic speakers,


except they have a small, flat diaphragm and a voice coil that moves within a
magnetic field.

Subwoofers − Subwoofers produce very low-frequency sound, ranging from 20


to 200 Hz. The subwoofer is a speaker that can be oriented in any direction.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

These are specifically designed to produce low-frequency sounds (bass).


Usually, they are used in Home theatre systems and car audio systems.

Dynamic speaker − Dynamic speakers are often equipped with one or more
woofer drivers. These have one or more tweeter drivers and are known for
producing low-frequency sound.

Bluetooth speakers − It’s a wireless speaker which is portable. A Bluetooth


speaker produces high-quality audio.

Horn Speakers − These speakers produce horns to amplify sound; generally


used by drivers.

Headphones-

Headphones are small-sized speakers which are specifically designed to fit into
the ear cups of headphones or earbuds. These speakers operate on the same
principles as larger speakers but are tailored for listening at close range and
for personal audio enjoyment.

Advantages

Some of the key advantages of headphone speakers are as follows −


 Produces better sound quality for personal use
 Users hear ambient sounds
 Relatively inexpensive
 Widely available
 Excellent for reproducing high frequencies
 Compact size
 Lower power requirements
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Projector: -

A projector is an output device powered by light is known as a projector. It


effectively displays processed results generated by a computer device and is
used to showcase images on a projection screen. Projectors can display large
amounts of visual content for professional presentations and home
entertainment.

Types of projector
Some common types of projectors are as follows –

Cathode Ray Tube − It is a video projector which employs CRT to produce


pictures. A lens is used to focus and enlarge the output to show on the screen
.
Liquid Crystal Display − LCD projectors use liquid crystals to display images,
data, or videos. LCD projector is extensively used in business seminars,
presentations, and meetings. These are more popular than other projectors as
they have superb color reproduction and lower manufacturing costs.

Digital Light Processing − DLP projectors are used for front and back
projection. A Three-chip DLP projector can output over 35 trillion colors, and
display visuals more realistic and lifelike than one-chip models. It is used in
companies and classrooms as a front projector and in TV as a rear projector.

Advantages
Some key advantages of projectors are as follows −
 Effective visual projection − A projector displays visuals effectively on
screen which bounds the audience.
 Portability − A user can carry it comfortably.
 Connectivity − It can easily connect in offices, seminar halls, or rooms.
 Applications − It is most widely used in businesses, education, and
meetings to showcase their presentations.
 Entertainment − Most widely used to watch movies and play games.
 Resolution and Brightness − Used for events, advertising, and digital
signage.

GPS
GPS, which stands for "Global Positioning System," is a radio-based satellite
navigation system and is comprised of a network of different satellites called a
constellation. The Global Positioning System (GPS) can determine a precise
position using radio waves. The user transmits a radio signal to the satellites,
which collect data such as time, location, speed, and other variables and
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

transfer it to the computer for processing. Users can use this information to
make decisions.
Advantages of GPS
Some key advantages of GPS are as follows −
Accuracy − The accuracy of the location data is important, especially for
applications such as aviation and marine navigation. Higher precision is
essential in these applications. The accuracy of the location data is of great
importance thus greater precision is essential for uses such as aviation and
marine navigation.
Display Quality − The screen's resolution and readability are crucial,
particularly when using outdoor devices in bright sunlight.
Map Coverage and Updates − Maps for various areas and how easy it is to
update them.
Durability − Water, dust, and shock resistance are crucial for GPS devices used
outdoors and in marine environments.
Additional Features − Features such as planning routes, receiving real-time
traffic updates, tracking fitness, and offering specialized marine and aviation
functions.

Scanning Devices:

What is scanning Devices-

A scanning device converts physical information, such as images, text, or


objects, into a digital format that a computer can process, store, and
manipulate. These peripheral input devices work by using light sources and
sensors to capture content and translate it into digital data, often as a file on a
computer system. Examples include flatbed scanners for documents, barcode
readers for product identification, and magnetic ink character recognition (MICR)
readers used by banks.

How Scanning Devices Work

1. Light Source:

A light source, such as an LED or lamp, illuminates the physical document,


image, or object.

2. Sensor:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

A photosensitive sensor, like a Charge-Coupled Device (CCD) or Contact Image


Sensor (CIS), captures the light reflected from the item.

3. Digitization:

The sensor converts the captured light patterns into electronic signals and then
into binary codes (1s and 0s).

4. Data Conversion:
These binary codes represent the pixels of the image or the characters on the
document, and they are then stored as a digital file on a computer.

What is The Meaning of Optical Scanners?

Optical scanners are input devices that convert digital signals using images, text,
codes, or objects into two-dimensional (2D) digital files, and then send this
information to computers and fax machines. Among them, the most popular
optical scanner device is the flatbed scanning device. Optical scanners can be
used in many fields, such as fingerprint recording and other fields.
An optical scanner is a device that can convert images and text into digital data.
It can save and analyze documents, images and other information based on the
principles of light and sensors. From barcodes to fingerprints, it plays a very
important role in all walks of life. effect.
Definition of Optical Scanners

An optical scanner is a charge-coupled machine composed of photosensitive


receptors, which we call CCD for short. Among them, the CCD capacitor can
respond to 70% of the incident light, and our commonly used photographic film
can only respond to 2%, so the utilization rate is very high.

But one thing is that optical scanners have no way to distinguish digital text
and graphics, so the scanned content is output in the form of pictures, and the
output text information cannot be edited or modified. However, most modern
optical scanners use standard optical character recognition (OCR) systems,
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

which can convert handwritten, entered text or printed text images into
American Information Interchange Standard code characters.

Optical scanners often include proprietary software for consistent imaging.


They connect to computing devices using external input/output (I/O) channels
such as Universal Serial Bus (USB), Small Computer System Interface (SCSI),
FireWire, and wireless adapters.

Advantages of Optical Scanners

 The mobility of the device can be measured


 CAD models can be built based on scanned data
 Scanned data can be exported into various forms
 Can measure the gloss and transparent objects after surface treatment

Optical Mark Reader (OMR) is the technology of electronically extracting data


from marked fields such as checkboxes or bubbles from pre-printed forms.
OMR technology scans a printed form and reads from predefined positions. It
records the data where marks are made on the form. This is widely used for
processing the large number of hand-filled forms which have to be processed
quickly and with great accuracy.

Optical Character Reader (OCR) is used to convert different types of


documents such as scanned paper documents, PDF files or images captured
by a digital camera into machine-encoded text. It is widely used as a form of
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

data entry from printed paper data records into electronic editable text which
can be easily searched, stored etc.

Below is a table of differentiation between Optical Mark Reader (OMR) and


Optical Character Reader (OCR):

S.
OMR OCR
No.

It stands for Optical Character


It stands for Optical Mark Reader
1. Reader or Optical Character
or Optical Mark Recognition.
Recognition.

It is used in scanning and


It is used to process data from
2. converting different types of
printed forms.
documents.

It is hard to implement as
3. It is easy to implement.
compared to OMR.

It provides more accuracy as


4. Its accuracy level is good.
compared to OCR.

5. Storing documents is not possible. It allows storing documents.

It was first used in 1857 in It was first used in 1914 to help


6.
telegraphs. blind people in reading.

Its application is in surveys, Its application is in google books,


7. answer sheets, questionnaires and bank statements, business
ballots. documents etc.

8. It required timing tracks. It does not require timing tracks.

It is useful in grading, calculating The visually impaired people find


9. marks, etc. It is the rapid method it useful. The text to speech can
of data entry. be used by them.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

It does not require an advanced An advanced recognition engine


10. level recognition engine when is needed for OCR compared to
compared to OCR. OMR.

MICR: What Is a Magnetic Ink Character Recognition Line?

DEFINITION
A magnetic ink character recognition (MICR) line is the unique series of
characters printed on a check that indicates the bank routing number, account
number, and check number, enabling automated processing and preventing
fraud.

What Is a Magnetic Ink Character Recognition (MICR) Line?

Magnetic ink character recognition (MICR) is a technology that banks use to


identify and process checks. The MICR line is the string of characters that
appears at the bottom left of the check, consisting of the bank routing number,
the customer's account number, and the check number.

It is called a magnetic ink character recognition line in reference to its anti-fraud


printing technology, originally developed in the 1950s. The numbers of the MICR
are printed using magnetic ink and unique fonts that make it harder to forge
checks.

Understanding the Functionality of MICR Lines


MICR lets computers quickly read and record information from printed
documents like checks. In this case, that information is a check
number, routing number, and account number.

The American Bankers Association (ABA) developed the system in the late
1950s, and the American National Standards Institute later recognized it as an
industry standard.12

The MICR number, often mistaken for the account number, is printed with
magnetic ink just above the check's bottom. The magnetic ink allows a computer
to read the characters even if they have been covered with signatures,
cancellation marks, bank stamps, or other marks.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

The Role of MICR Scanners in Check Processing

Every check sent is processed by a clearinghouse, bank, or both. They validate


the check and finalize the transaction, deducting the correct amount from one
account and crediting it to another. A single check may be processed several
times at different banks and Federal Reserve Centers.

Part of that process is reading the identifying information on the check. The
MICR line mechanized that process. A scanner, or reader-sorter computerized
machine, processes the information magnetically printed on the checks,
including the routing number, account number, and check number.

During clearing, checks may be scanned several times at high speeds. According
to Troy Group, a producer of MICR-adapted printers and related products, a
single reading takes less than 1/1000ths of a second.

Expanding Applications of MICR Technology

While magnetic ink character recognition was first used to print information on
checks, the technology has been adapted to other applications.

A variety of financial documents in the United States are encoded with MICR
technology. Credit card invoices, direct mail, coupons used for rebates, and
negotiable orders of withdrawal (NOWs) may also use the technology.5

Advantages of MICR: Streamlining and Security

One of the benefits of the magnetic ink character recognition line is its ability to
facilitate the use of a routing number to process checks and deduct the payment
amounts. A routing number or routing transit number is a nine-digit numerical
code that banking and other financial institutions use to clear funds and
process checks.

The routing number identifies the bank branch that holds the account from
which funds are to be drawn. Wire transfers and direct deposits often rely on
routing numbers as well.

Detecting Fraud
Combating fraud is a constant battle in the financial services industry. The
definition of fraud is an intentionally deceptive action that is designed to provide
the perpetrator with an unlawful gain. A range of fraud types exists,
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

including tax fraud, credit card fraud, wire fraud, securities fraud, and bankruptcy
fraud.

The magnetic ink character recognition line makes some forms of financial fraud
harder by using tamper-proof magnetic ink and unique fonts. Thus, MICR
makes it difficult to alter checks.

Check altering generally entails changing the payee's name, the amount of the
check, or both. Section 3-407 of the Uniform Commercial Code (UCC), a set of
business laws regulating financial contracts, breaks down the term
alteration even further, with nine articles dealing with separate aspects of
banking and loans.6

For instance, a fraudster may attempt to cash a photocopied check through a


teller at a bank branch. The photocopied MICR line immediately alerts the teller
that the check is fake.

What is a digitizer?

A digitizer, also known as a graphics tablet or drawing tablet, is a device that


allows you to input drawings, sketches, and handwritten notes into a computer.
It consists of a flat surface and a stylus or pen-like instrument that you use to
draw or write on the surface. The device captures the movements and pressure
applied by the stylus and translates them into digital data that can be
interpreted by the computer.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

How does a digitizer work?


A digitizer uses a combination of technologies to accurately capture and convert
your pen strokes into digital information. The surface of the digitizer is pressure-
sensitive and registers the movements and pressure levels applied by the stylus.
As you draw or write on the surface, the digitizer's sensors detect these
movements and send the corresponding data to the computer. The computer
then processes this data and translates it into visual elements on the screen.

What are the advantages of using a digitizer?

Using a digitizer offers several advantages over traditional input methods like a
mouse or keyboard. Firstly, it provides a more natural and intuitive way to create
digital drawings or write digitally. The pressure sensitivity of a digitizer allows
you to vary the thickness and intensity of your strokes, mimicking the experience
of using traditional art tools. Additionally, digitizers often come with features like
tilt detection, allowing for more precise and expressive drawing techniques.

Who uses digitizers?


Digitizers are widely used by various professionals and enthusiasts who work in
fields such as graphic design, digital art, animation, architecture, industrial
design, and photo editing. Artists and illustrators, for instance, find digitizers
invaluable for creating digital artwork, while architects and designers use them
to sketch and annotate designs. They are also useful for taking handwritten
notes in digital format, making them popular among students and professionals.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

What are the different types of digitizers?


There are several types of digitizers available in the market, each with its own
features and advantages. The most common types include:

 Pen-based Digitizers: These digitizers feature a stylus or pen that directly


interacts with the surface, capturing the movements and pressure applied.
 Touch-based Digitizers: These digitizers let you interact with the surface using
your fingers or a stylus, like touchscreens on smartphones and tablets.
 Display-based Digitizers: These digitizers have an integrated display, allowing
you to directly draw or write on the screen itself, eliminating the need for a
separate surface.
 Optical Digitizers: These digitizers use optical sensors to track the movement
of a special pen or stylus. They are known for their high accuracy and precision.
 Electromagnetic Digitizers: These digitizers use electromagnetic fields to track
the position and movements of a special pen or stylus. They are often more
sensitive and accurate than other types.

What software can I use with a digitizer?

A digitizer can be used with a wide range of software applications, depending on


your needs and preferences. Many artists and designers prefer to use
professional graphic design software such as Adobe Photoshop, Illustrator, or
CorelDRAW, as these applications offer advanced drawing and editing
capabilities. However, there are also free and open-source software options
available, like GNU image manipulation program (GIMP) and Inkscape, which
provide powerful tools for digital drawing and image editing.

Are there any maintenance tips for digitizer?


To ensure the longevity and optimal performance of your digitizer, here are a few
maintenance tips to keep in mind:
 Keep the surface clean: Regularly clean the surface of your digitizer using a
soft, lint-free cloth to remove any dust or debris. Avoid using abrasive cleaners
or solvents that could damage the surface.
 Protect the stylus: When not in use, store the stylus in a safe and secure place
to prevent damage. Avoid dropping or applying excessive force to the stylus, as
it can affect its functionality.
 Calibrate regularly: Some digitizers may require calibration to maintain
accuracy. Follow the manual instructions to calibrate your digitizer periodically,
ensuring precise tracking and pen sensitivity.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Update drivers and software: Keep your digitizer's drivers and software up to
date by regularly checking for updates on the website. Updated drivers often
include bug fixes and improved compatibility with the latest operating systems.
 Use a screen protector: If you're using a display-based digitizer, consider using
a screen protector to prevent scratches or damage to the display surface. Make
sure to choose a protector specifically designed for your digitizer model.

What is the electronic card reader?


A card reader is a device that allows you to read information from various types
of cards, such as credit cards, debit cards, identification (ID) cards, and memory
cards. It can be connected to a computer or a mobile device to transfer data or
perform specific functions.

How does a card reader work?


A card reader works by using a combination of hardware and software
components. The hardware part consists of a slot or interface where you insert
the card, and sensors or magnetic heads that read the data stored on the card.
The software part processes the data and makes it accessible for further use.

What types of cards can a card reader read?


A card reader can read a wide range of cards, including credit cards, debit cards,
smart cards, identification (ID) cards, subscriber identity module (SIM) cards,
memory cards (such as secure digital (SD) cards and microSD cards), and even
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

certain types of security access cards. The compatibility of a card reader depends
on its design and specifications.

What is a Smart Card Reader?


A smart card reader is a device that accesses data stored on smart cards. Smart
cards are plastic cards with embedded computer chips that securely hold
personal information or access codes. Smart card readers either require
inserting the card (contact) or simply bringing the card near the reader
(contactless) to read the data on the chip.

What are Smart Cards?


Smart cards look like regular plastic cards but have special technology inside.
This technology allows them to store information securely. Some smart cards
use tiny computer chips, while others use magnetic strips. These chips or
magnetic strips can hold data that a smart card reader can access and read.
Smart card readers are devices designed specifically to interact with and extract
information from these specialized smart cards.

How Do Smart Cards Work?


Smart cards have a tiny computer chip embedded in them. This chip can
securely store data like personal information or access codes. To access this
data, you need a smart card reader. The reader connects to the chip either by
inserting the smart card into it (contact reader) or by holding the card near the
reader (contactless reader). Once connected, the reader can retrieve the
encrypted data stored on the chip's memory in a secure way. The chip makes
smart cards more secure than regular magnetic stripe cards.

Different Types of Smart Card Readers

 Contact Smart Card Readers

These readers require you to physically insert the smart card into a slot or
opening on the device. Once inserted, the reader can directly connect to the
small metal connectors on the smart card's chip. This allows the reader to
communicate and exchange data with the chip.

 Contactless Smart Card Readers

With these readers, you don't need to insert the smart card. Instead, you simply
hold or wave the card near the reader. The reader uses radio frequency (RF)
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

technology to wirelessly connect and transfer data to and from the chip on the
smart card without any physical contact.
Uses of Smart Card Readers

1. Personal Identification: Smart cards can store personal information and


identification details. Readers allow secure access to this data for verifying
identities when entering buildings, logging into computer systems, or
confirming authorization for various services.

2. Financial Transactions: Many debit and credit cards now use smart card
technology. Readers enable secure financial transactions by reading the
account data stored on the chip and validating the card's authenticity.

3. Access Control: Smart card readers are widely used for controlling access
to restricted areas like offices, data centers, or secure facilities. The card's chip
stores access credentials that readers can validate before granting or denying
entry.

4. Healthcare: Patient information, medical records, and insurance details can


be safely stored on smart cards. Readers allow healthcare providers to quickly
and securely access this data when needed.

5. Transportation: Smart cards are commonly used for transit passes and
ticketing systems. Readers validate the card's data, deduct fares, and allow
access to buses, trains, or other transportation services.

6. Government Services: Various government-issued documents like national


IDs, driver's licenses, and social security cards are increasingly using smart
card technology. Readers enable secure identification and access to related
government services.

Advantages of Smart Card and Smart Card Readers

1. Better Security: Smart cards provide more protection than regular cards.
They use special coding and verification methods that make them safer for
users. Smart cards have a tiny computer that can count and requires a secret
code from the user, adding an extra layer of security not found in magnetic
cards.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

2. Flexible Usage: Smart card readers can adapt and work with different
machines and programs. By connecting through a standard USB port, these
readers can interact with various software on a computer.

3. Larger Storage, Harder to Modify: Regular magnetic stripe cards can only
store around 150 units of data. Smart cards, however, can safely hold between
1,000 to 256,000 units of information. Once data is stored on a smart card, it
becomes extremely difficult to change or delete without proper access.

Disadvantages of Smart Card & Smart Card Readers

1. Higher Price: The advanced security features of smart cards make them
costlier than regular cards. The technology used in smart cards is very
sophisticated, providing top-level protection, which increases the overall
expense.

2. Gradual Adoption: Smart card readers are not yet widely used or popular.
This technology is still in the process of being adopted by more people and
businesses. However, over time, smart card readers are expected to become
more common and gain more popularity compared to traditional card readers.

3. Compatibility Challenges: While smart card readers offer flexibility by


using standard USB connections, ensuring full compatibility across different
operating systems, software, and hardware can sometimes be a challenge.
Manufacturers need to continuously update and test their smart card readers
to maintain seamless integration with evolving technologies.

Digital camera

A digital camera, also called a digicam, is a camera that captures photographs


in digital memory. Most cameras produced since the turn of the 21st century are
digital,[2] largely replacing those that capture images on photographic film or film
stock. Digital cameras are now widely incorporated into mobile devices
like smartphones with the same or more capabilities and features of dedicated
cameras. High-end, high-definition dedicated cameras are still commonly used
by professionals and those who desire to take higher-quality photographs.
Digital and digital movie cameras share an optical system, typically using
a lens with a variable diaphragm to focus light onto an image pickup device. The
diaphragm and shutter admit a controlled amount of light to the image, just as
with film, but the image pickup device is electronic rather than chemical.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Image sensors:

The two major types of digital image sensors are CCD and CMOS. A CCD
sensor has one amplifier for all the pixels, while each pixel in a CMOS active-
pixel sensor has its own amplifier. Compared to CCDs, CMOS sensors use less
power. Cameras with a small sensor use a back-side-illuminated CMOS (BSI-
CMOS) sensor. The image processing capabilities of the camera determine the
outcome of the final image quality much more than the sensor type.

Sensor resolution

The resolution of a digital camera is often limited by the image sensor that
turns light into discrete signals. The brighter the image at a given point on the
sensor, the larger the value that is read for that pixel. Depending on the
physical structure of the sensor, a color filter array may be used, which
requires demosicing to recreate a full-color image. The number of pixels in the
sensor determines the camera's "pixel count". In a typical sensor, the pixel
count is the product of the number of rows and the number of columns. For
example, a 1,000 by 1,000-pixel sensor would have 1,000,000 pixels, or
1 megapixel.

Resolution options
Firmware’s' resolution selector allows the user to optionally lower the resolution
to reduce the file size per picture and extend lossless digital zooming. The
bottom resolution option is typically 640×480 pixels (0.3 megapixels).
A lower resolution extends the number of remaining photos in free space,
postponing the exhaustion of space storage, which is of use where no further
data storage device is available and for captures of lower significance, where
the benefit from less space storage consumption outweighs the disadvantage
from reduced detail.

Image sharpness
An image's sharpness is presented through the crisp detail, defined lines, and
its depicted contrast. Sharpness is a factor of multiple systems throughout the
DSLR camera by its ISO, resolution, lens, and the lens settings, the
environment of the image, and its post-processing. Images have a possibility of
being too sharp, but they can never be too in focus.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Digital cameras offer advantages like instant photo review and sharing, cost
savings by eliminating film and developing costs, higher capacity storage through
memory cards, enhanced control with manual settings and interchangeable
lenses, and increased photographic flexibility through features like autofocus
and low-light capability.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Unit -3rd
(Windows & MS office)

Introduction to MS Windows:

Microsoft Windows is an operating system developed by Microsoft Corporation,


widely used on both personal and business computers. Microsoft Windows was
first introduced in 1985 and is a GUI-based operating system that has had many
versions over the years.

What is Windows Operating System?

Windows Operating System is a widely used operating system that manages


hardware and software resources while providing services for computer
programs. The latest version of Microsoft's widely used Operating System is
Windows 11.

History and Development of Microsoft and Windows

1975 - 1981

Microsoft's journey started in 1975 when Bill Gates and Paul Allen teamed up.
They co-developed Xenix (a version of Unix) and worked on a BASIC interpreter
for the Altair 8800. The company was incorporated in 1981.

1981 - 1985

Microsoft gained recognition in the technology sector with the introduction of


MS-DOS, a text-based, command-line OS. DOS was primarily based on licensed
intellectual property, QDOS. During that time, GUI-based systems like Xerox's
Alto, released in 1979, and Apple's LISA and Macintosh systems, which followed
later, were emerging. Enthusiasts of MS-DOS referred to these systems as
WIMPs, meaning "windows, icons, mouse, and pull-down menus (or pointers)."

1985 - 1994

However, Gates recognized the potential of GUI-based systems and initiated a


project called Interface Manager. He believed that a GUI could reach a broader
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

audience at a lower cost than the $9,000 LISA. The rest of Microsoft supported
this idea, and in a somewhat ironic turn, the project team chose "Windows" as
the name for the new OS. Microsoft announced the upcoming release of Windows
1.0, the first version of Windows, in 1983.

The company used some elements it licensed from Apple for portions of its
interface. Windows 1.0 was released in 1985. In 1988, Apple sued Microsoft and
Hewlett-Packard for $5.5 billion, claiming that the companies used certain GUI
elements without authorization. In 1992, a federal court ruled that Microsoft and
Hewlett-Packard did not exceed the 1985 agreement. Apple appealed, but the
decision was upheld in 1994.

Windows faces competition from Apple's macOS and the open-source Linux OS
developed by Linus Torvalds. While Linux is free and widely available, and
macOS is praised for its stability and user experience, Microsoft Windows
continues to dominate the market. As of this writing, over 1.3 billion devices run
Windows 10, with ongoing updates to support advances in hardware.

Versions of the Windows Operating System

Windows 1.0 (Released: November 20, 1985)


 Introduced the graphical user interface (GUI)
 Limited multitasking
 Simple graphics for its time

Windows 2.0 (Released: December 9, 1987)


 Allowed applications to overlap
 Introduced MS Word and Excel
 Supported 16-bit GUI

Windows 3.0 (Released: May 22, 1990)


 Improved multitasking
 First version to receive widespread critical acclaim
 Enhanced memory management

Windows 95 (Released: August 15, 1995)


 Combined MS-DOS with Windows
 Introduced the Start menu and Taskbar
 Pioneered plug-and-play functionality

Windows 98 (Released: May 15, 1998)


 Improved upon Windows 95 with better support for USB devices
 Enhanced the GUI and memory management
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Windows 2000 (Released: February 17, 2000)


 Focused on security and reliability
 Released in four editions: Server, Professional, Advanced Server, and Datacenter
Server

Windows XP (Released: October 25, 2001)


 Offered fast start-up and better hardware support
 Introduced the "Windows XP" look
 Widely praised for its stability

Windows Vista (Released: January 30, 2007)


 Revamped the GUI
 Introduced the Aero glass interface
 Advanced security features

Windows 7 (Released: October 22, 2009)


 Redesigned taskbar and user interface
 Enhanced performance
 Libraries added to file management

Windows 8 (Released: October 26, 2012)


 Optimized for touch-based devices
 Integrated with cloud services

Windows 10 (Released: July 29, 2015)


 Addressed issues from Windows 8
 Introduced virtual desktops
 Improved security and user interface

Windows 11 (Released: October 5, 2021)


 Redesigned taskbar and start menu
 Removed live tiles, replaced with a widgets dashboard
 Enhanced security features and improved interface design
 Requires a 64-bit processor, excluding support for 32-bit systems
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Applications in Windows

Many kinds of applications are available at the Windows store and we can easily
access them and download them for our personal or professional usage.

Below is the list of some applications available on Windows –

 Web Browsers − Software used to access and view websites, such as Google
Chrome or Mozilla Firefox.
 Adobe Photoshop − A powerful image editing software used for creating and
manipulating images.
 Adobe Reader − A program used to view and print PDF files.
 Messenger − A messaging application that allows users to chat and share media
online.
 Media Players − Software used to play audio and video files, such as VLC or
Windows Media Player.
 Games − Interactive software designed for entertainment and leisure.

 Audio/ Video Chatting Apps − Apps like Skype or Zoom for real-time voice and
video communication.
 Maps & Calendar − Applications used for navigation and managing schedules
and appointments.

Important Commands for Windows


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Computers run over a set of commands, which with the advancement of


Operating Systems can be entered through various hardware devices. Below are
a few important MS-DOS Windows commands for reference -

Command Description

cd Change directory

help Help with a command

cls Clear window

notepad Windows Notepad text editor

dir Display list of contents of current directory

type Displays content of a text file

assoc Display/modify file extensions

attrib Displays/changes file attributes

call Calls one batch program file from another

color Set text and background color

comp Compares the contents of two files

copy Copy one or more files to another location

date Displays date

del Delete multiple files


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

edit Run MS-DOS text editor

exit Close MS-DOS window

find Search for a text string in a file

move Move one or more files to another location

Advantages of Windows operating system:

 Backing for all equipment - As windows OS is utilized by 95% of clients so


the majority of the equipment merchants make drivers for windows.

 Convenience - All forms of Microsoft Windows have something regular in it


which makes it clients simple to move starting with one form then onto the
next. Windows 7 clients have no trouble in moving to Windows 10 in light of
the fact that a large portion of the highlights of Windows 10 is equivalent to
Windows 7. The UI of windows is additionally simple to use than UNIX and
MAC.
 Programming support - Windows stage is most appropriate for game and
programming engineers. Windows have a huge number crowd so designers
want to make utilities, games, and programming for windows OS. Linux
clients can't make windows applications so it is smarter to utilize windows
for creating applications.

 Fitting and play highlight - Most equipment can be distinguished naturally


by attachment and play include. You don't have to physically introduce the
equipment however it is prepared to utilize when connected for example
webcam, console, mouse, cell phone, and so forth.
 Work area and contact screen - Windows 10 is made for both touch screen
gadgets and PCs. The UI of Windows 10 is made so that it turns out better
for a windows gadget.

Disadvantages of Windows operating system:

 Infection assaults - Windows have a high measure of programmer assaults.


The programmers can without much of a stretch break windows security.
So windows clients are reliant on the enemy of infection programming and
need to pay month to month charges to organizations to ensure their
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

information. Additionally, windows clients need to refresh OS to stay up with


the latest security patches.
 The majority of the product is paid - Most windows programs are paid for
example games, designs programming (Photoshop), download chief (IDM)
and other famous programming are paid. You need to purchase these
products or pay a month-to-month charge to utilize them.
 Rebooting a framework - If your framework turns out to be delayed in
execution then you need to reboot it. On the off chance that you load
numerous projects simultaneously, at that point your framework eases back
down and hangs up. The lone answer for this is to reboot.

 Excessive cost - Linux OS is open source and is allowed to use for


everybody except windows OS has a paid permit and you can't utilize
windows OS lawfully free. The expense of purchasing a duplicate of windows
OS is high too. You likewise need to purchase other Microsoft programming
for example MS Office to accomplish a standard office deal with the PC.

 High PC assets - If you are introducing windows OS then your PC ought to


have a high smash limit, a great deal of hard drive space, and great designs
card. This is a result of highlights that are utilized in windows. In the event
that you need to introduce illustrations programming for example Photoshop
then 16 GB of smash is suggested.

 Specialized help - Windows uphold isn't useful for most clients. Just some
enormous associations can get great help from the windows group. Basic
clients need to look for gatherings to get their concerns settled.

Control Panel: - Control panels include the virtual control panel, the remote
control panel, and the physical control panel. You can use these control panels
to perform almost all of the same functions. The remote control panel and virtual
control panel provide a way to perform control panel functions from a PC.

Types of control panels


 Physical control panel- The physical control panel is your initial interface with
the system. You can use the physical control panel to perform functions, such
as performing an initial program load (IPL) and turning on and turning off the
system. Control panel functions range in complexity from functions that display
status (such as IPL speed) to low-level service functions that only service
representatives can access.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Remote control panel- The remote control panel provides a way to use control
panel functions through a PC. The graphical user interface of the remote control
panel looks similar to the physical control panel.
 Virtual control panel- With the virtual control panel, you can use control panel
functions through a PC.

What is Control Panel?

The control panel, as the name suggests is a crucial tool for controlling various
settings and features of the Windows operating system. It provides a user-
friendly interface for maintaining the system's performance, security, and
usability.

Definition in detail: A Control panel is a centralized interface that allows users


to manage various functions of computer software, hardware, etc. These
functions include Adding and removing software and hardware, system
updates, security updates, network and internet, user accounts, clock,
language, date and time, display, Programs and features, Windows Defender,
etc. It can modify the uses of default apps and settings of mouse, keyboard,
sound, etc. The control panel is available in almost every version of Microsoft
Windows including Windows 2000, Windows XP, Windows Vista, Windows 7,
8, 10, 11, and 12, etc.

How to Access the Control Panel?


The process of getting access to the control panel is different in different
versions of Windows. The processes are discussed below:
For Windows 7
 Click on the start button
 Then click on the control panel

For Windows 8 or 8.1


 Right click on the start menu to display the app bar
 Select all apps and scroll right to the windows apps section
 select control panel

For Windows 10
 Go to the Search box on the taskbar
 Type control panel
 Then select Control panel from the result
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

For Windows 11
 To open control panel in Windows 11, we'll follow the similar process as
Windows 10.

Windows Accessories:

Microsoft Windows Accessories are a group of programs and utilities that can
be included with Microsoft Windows but are not essential. Generally, these
accessories give Windows users additional features such as the ability to create
a drawing in Microsoft Paint. With Windows 11, Microsoft has renamed the
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Windows Accessories folder to Windows Tools, but the area still contains many
of the same programs.

Window Accessories Group is a very important part of the window; very


important tools are available inside Window Accessories, which we can use
according to our need. Inside the Window Accessories Group, a list of many
facilities is displayed so that we can do Simple Type. Can apply some special
characters, can calculate Mathematics, and can manage the performance of your
computer, although there are many tools inside the Window Accessories Group,
but some important tools are as follows.
 Character Map
 Calculator
 Notepad
 word pad
 Remote Desktop Connection
 Paint
 Math input panel
 snipping tool
 disk clean up
 disk defragment

Character Map: -

There is such a facility in Character Map Window Accessories, using which we


can know which key or key combination has been determined in which font. It
contains all those keys/fonts which are not given on the keyboard. With whose
help we can make our text even better.
Steps for Open Character Map
 Start button→ All program→ Window accessories→ Character Map
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Steps for insert character


 In the Font box, click the font you want to use.
 Click the special character that you want to insert, click Select, and then
click Copy.
 In your document, position the insertion point where you want the special
character to appear.
 On the Edit menu, click Paste. You can also copy characters by dragging
them from Character Map directly into an open document.

Calculator- We use this tool available in Window Accessories to do arithmetic and


scientific calculations. To run the calculator, a normal calculator is displayed on the
screen, which we run with the help of a mouse so that we can do Mathematical Sums
very easily. This is an important tool of our Windows

Start button→ All program→ Window accessories→ calculator


Snipping Tool

Snipping tool is also an important tool of Window Accessories, with the help of
this we can take Screen short (SS) of any object of the screen, with the help of
this tool we can take Screen short in the same way as we take in our phone.

Start button→ All program→ Window accessories→ snipping tool


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Disk Cleanup

Disk cleanup is one of the most important tools of window accessories, with the
help of this we can clean many things like junk files, cookies from our PC, due
to this the performance of our computer becomes faster.

Start button→ All program→ Window accessories→ System tool→ disk cleanup

Disk Defragment

Disk defragment is a tool of window accessories, it is used to arrange the saved


file or folder in the hard disk, it is used to eliminate the free space on the disk
drive and organize the file & folder.

Start Button→ All Program→ Window Accessories→ System Tool→ Defragment


What is Taskbar?
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

The taskbar is the bar at the bottom of the screen. The taskbar has one button
for each window on the desktop. When multiple programs are running, the
button for each program is created in the toolbar. Users can navigate between
these programs by simply clicking the program's button. The Taskbar should
be assessed based on the following criteria, and additional factors should also
be taken into consideration for its evaluation.

Taskbar
Components of the Taskbar
 Start button: The Start button is present at the bottom-left corner of the
taskbar. When we click on the Start button the Start menu appears. The
Start menu displays a list of options to perform various tasks on the
computer. We can start a program, search for a program, shut down the
computer, etc. Using the Start button.
 Search box: The search box helps us to easily find anything on the
computer or the internet.
 Task View: To the right of the Search bar is the Task View button. It helps
the user to view windows that are opened. The user can easily switch
between open windows, or close them.
 Pinned programs and File Explorer: To the right of Task View there is File
Explorer and few pinned programs. File Explorer provides users a shortcut
way to view the contents present in the computer.
 Notification area: This area is located at the bottom-right corner of the
taskbar. Notification area displays time and date.
 Show desktop button: Show desktop button is located to the right end of
the notification area.

Customizing the Taskbar


 Change the position of Taskbar: You can change the position of the
taskbar by simply clicking on an empty space and dragging it to the
preferred location.
 Hide Taskbar: To automatically hide the taskbar in desktop mode, you can
click on the toggle switch to turn it on.
 Small taskbar buttons: select "Taskbar settings," and then look for the
option to show small taskbar buttons. Click on the toggle switch to turn it
on.
 Resize the Taskbar: After disabling the "Lock the taskbar" feature, you can
simply drag the taskbar to resize it.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

My Computer: My Computer is a Microsoft Windows feature first found


in Windows 95 and included with all later versions that lets you explore and
manage the contents of your computer's drives. The image shows examples of
the My Computer icon in Microsoft Windows XP, Vista and Windows 7, and the
"This PC" icon in Windows 8 and in Windows 10. Although the name has
changed, "This PC" still has the same functionality as "My Computer."

How to open My Computer?

In all Windows versions, you can use the keyboard to open My Computer without
using the mouse. Pressing the keyboard shortcut Windows key+E opens My
Computer (File Explorer). Your computer's drives and any installed devices are
listed under the "This PC" section on the left.

1. Get to the Windows desktop and open Start menu, or navigate to the Start
Screen if you are using Windows 8.

2. In Windows 8, Windows 10, and Windows 11, select This PC from the
Window's File Explorer.

3. In Windows Vista and Windows 7, select Computer from the Start menu.

In earlier versions of Windows, after clicking Start, select My Computer. Or,


on the desktop, double-click the My Computer icon.

Noted- In Windows Vista and Windows 7, My Computer is called "Computer" and


is accessed through the Start menu, as shown below.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Noted -In Windows 8, Windows 8.1, Windows 10, and Windows 11, My Computer
is called "This PC" and is accessed through the Start menu.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

How to use My Computer?

Once My Computer (This PC) is open, all available drives on your computer are
displayed. The primary location of all your files is the Local Disk (C:), which is
the default hard drive that stores all files. Double-click this drive icon to open it
and view its contents.

Finding files in My Computer

Most files you create or want to find are in your My Documents folder. If you are
having trouble finding where a file is stored, you can also use the Windows find
feature.

Recycle Bin:- The Recycle Bin is a place where items deleted in Windows are
temporarily stored until they are permanently deleted. It has enabled users to
recover deleted files in Windows operating systems since Windows 95. Until the
user completely deletes the data, they remain on the hard drive all deleted files
or folders are placed in the Recycle Bin.

What is a Recycle Bin?

The Recycle Bin is a default folder on the computer's operating system. It serves
as a temporary storage area for files and folders that have been erased from the
computer, whether accidentally or intentionally. When you delete an item from
your computer, it goes into the Recycle Bin rather than being permanently
deleted. This enables users to restore wrongly deleted files without utilizing
data recovery software.

Features of Recycle Bin


 Recovery: When you delete a file you have an option for recovery because
of recycling otherwise it would have deleted permanently and cannot be
recovered. They can be restored directly to their original place by a single
click. Because of this, people can delete unnecessary files without worrying.
 Customization: We can easily customize the features of the recycle bin by
going by right-mouse clicking on the recycle bin icon and then clicking on
recycle bin properties. It provides us the option of using a recycle bin or
permanently deleting files. We can also decide the maximum size of the
recycle bin per each disk as shown in the image.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Auto delete: When the recycle bin has reached the defined size or your hard
disk is running low on space then the files start being removed from the
recycle bin. This stops the recycle bin from getting filled or stops the hard
drive from getting slow because of the recycle bin.
 Restore All Items: Recycle bin also provides us the option to restore all the
files directly with a single click. You need not restore files one by one and
can do it directly with a single click.

How to Recover Files sent to the Recycle Bin?


 Navigate to the desktop window where the recycle bin icon will be shown.
 To see the deleted files, open the recycle bin window by double-clicking the
recycle bin icon.
 Now you need to select the file that you want to restore from the recycle bin
window, then choose the Restore option after right-clicking on the selected
file. The file will be returned to its original storage place on the hard disc
from where it was erased by the user.
 The recycle bin also allows you to restore the file to the desired location on
your hard drive. To do this, choose the file that you wish to recover and
right-click on it.
 Then, click the Cut option, or use the shortcut key Ctrl + X to cut the file.
 Now, select the location where you wish to restore the deleted file and press
Ctrl + V or click the Paste option.
 You may also use the drag-and-drop feature to restore deleted files from the
recycle bin to the desired location or folder.

Advantages of Recycle Bin


 Accidental Data Protection: If you accidentally deleted a file but need it
after some time then because of the recycle bin you can recover it because
of the recycle bin. Your data is not permanently gone. You can go to the
recycle bin and click to restore it. This is also the primary purpose of a
recycle bin which is to safeguard against accidental deletions.
 Optimizes Storage: Instead of re-downloading the deleted files we can
restore them from the recycle bin this will save the storage bandwidth. This
becomes very important when you are working with large files and limited
internet resources.
 Easy User Interface: The user interface of the recycle bin is very easy to use
and understand. Even a beginner can understand how to restore deleted
files with just a single click. The restored file will come back to its original
location from where it was deleted.
 User confirmation: Even if you try to delete a file from the recycle bin it will
ask for user confirmation This extra step helps prevent accidental
permanent deletions by requiring users to confirm their intention to remove
files.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Disadvantages of Recycle Bin-


 Occupies storage space: The Recycle bin does not store the deleted files on
external storage such as the cloud rather it takes space from the
computer's hard drive. So, it cannot be used as a backup for cloud storage
and if you are deleting things for getting storage back then recycle bin will
not help much.
 Slows down the deletion process: In the case you want to delete the files
permanently then also recycle bin is not helpful because of recycle bin you
first delete the file then it will move to recycle bin then you have it from
there. So, for normal people it will slow down the process of deletion because
of recycle bin. But there is a way you can delete the file permanently without
storing it to recycle bin. It is done by holding the shift key while deleting the
file. In this will file won't be stored in recycle bin and will be deleted
permanently.
 Potential security risk: If sensitive or confidential files are deleted and not
permanently removed from the Recycle Bin, there is a potential security risk.
Someone with access to the computer could restore these files and gain
unauthorized access to sensitive information.

 Not applicable to network locations: The process of storing to recycle bin


will only work if the files are deleted from local storage drive but for network
files location it won’t work in the same way and if the files are deleted from
network location.

What is Microsoft Office? Components, Uses, Pros & cons of MS Office

Microsoft office comes in two flavors, MS Office and Office 365. MS office is the
traditional including includes basic MS office applications like Word, Excel,
PowerPoint, and documents.
Office 365 is the version of MS Office that you would use if you have an online
account. Students, professionals, and business people used Microsof
worldwidethe world. This office suite gives a good user experience with its latest
version, i.e., Microsoft Office 2016.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Components of MS Office
There are over five components of Microsoft Office that are helpful for people to
complete their daily tasks. They are:

 Microsoft Word
 Microsoft Excel
 Microsoft PowerPoint
 Microsoft Access
 Microsoft OneNote
 Microsoft Outlook

Microsoft Word

MS Word is a document creation application with many templates, styles, and


fonts. This is one of the most commonly used applications with lots of add-ons
that allow us to change it according to the needs.
Learn More About word. Copy & Paste, Find & Replace, Referencing, are some
functions of MS Office.

Microsoft Excel

MS Excel is a spreadsheet application with formatting options, pivot tables,


functions, and formulas. With the help of this application, we can create any
kind of document. This is also one of the most commonly used software for
creating professional data-driven documents.

Microsoft PowerPoint

It is a presentation creation tool that allows us to enhance our talk. With the
help of this application, we can make professional presentations. In short, it is
used for creating and delivering presentations and other business documents.

MS PowerPoint has some auto-generated templates for presenting a document.


You can also animate your document through PPT, Slides, and add videos and
audio.

Microsoft OneNote

MS OneNote is an application for note taking, capturing ideas, and keeping


them as a record. We also used it for creating charts and graphs or creating class
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

notes. It should be said that this is the most used application in Microsoft Office
after MS word, excel, and PowerPoint.

Microsoft Outlook

MS Outlook is an email application that supports multiple e-mail accounts,


automatic replies, and scheduling messages. This is helpful for us to stay in
touch with other people and manage our communication effectively.

Microsoft Access

MS Access is a database application that allows us to manage databases and


create websites.
Experts for designing and maintaining databases used it. Even though this is
not the main application of MS office, it has someessentialt features such as
drawing tables, form macros, and clicking on forms.

Uses of Microsoft Office


Microsoft Office is a tool for creating data-driven business documents. This
includes many templates with different styles for creating reports, presentations,
letters, and books.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

MS office is helpful for students to create presentations on their assignments,


notes on the lectures, and documents filled with research information. Below are
some other uses of MS Office:

1. Use for preparing the data report

The data report is a common assignment given to the students of Business


Administration courses, Statistics classes, Mathematics classes, etc.

If they use MS Word, they can create a professional-looking data presentation.


Students can use different styles and formats in MS word to create professional-
looking reports.

2. Helps in preparation of Dashboard

This application is helpful for students of IT, Computer Science, and Web Design
classes to create dashboards with the help of Microsoft Access and MS Excel.
They can use this application to create detailed reports before giving them to the
concerned authorities.

3. Data Sorting

One of the most important functions of MS Excel is sorting data. This is a very
helpful application for students who are preparing their final thesis,
assignments, or project reports. MS Excel can be used to sort and analyze data
on different criteria.

4. referencing

Referencing is not a common practice for students, but it is becoming a trend in


the world of education.

Students are now using MS Office as a tool for referencing and saving the data
from their coursework or projects. APA, MLA, and IEEE referencing styles are
widely accepted in the world of education and business.

5. Macros

In order to achieve the advanced features of MS Office, we can use macros.


Macros allow us to automate various actions and functions. Business
professionals and students also use macros in different fields to save time,
money, and energy.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Pros and Cons of Microsoft Office


MS Office is a powerful office suite that helps us in completing our daily tasks
effectively. But it also has its limitations. We can look for the merits and demerits
of Microsoft Office to compare it with other office suites such as Google,
OpenOffice, and LibreOffice.

1. Ease to Use

Since MS office comes in five different components, it is suitable for both


computer beginners and advanced users. It also supports online connectivity,
cloud storage facilities, etc. As a result, it is widely used all over the world.

2. Cost

MS Office is available at an affordable cost. Students and professionals obtaining


their degrees can use this application with the help of Microsoft Academic
Licensing. Small businesses also use MS Office to create professional documents
with small budgets.

3. Online Support

A huge library is available on the Microsoft website. We can find different


documentation, blogs, tutorials, solution search engines, etc. We can also get
direct answers to our queries from the online support team Microsoft.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

4. Security

MS Office is considered to be very secure software. It is used by various


industries such as banking, finance, and government, etc. As a result, it also
comes with a security feature called Intrusion Detection System (IDS).

5. Support for many languages

This software has support for different languages and character sets. We can use
this application to create documents in different languages such as English,
Chinese, French, German, Italian, etc.

Disadvantages of Microsoft Office


As earlier we discussed some advantages of MS office, here we will talk about
some disadvantages MS Office. Many people are using this application for
different purposes, but it is not the best option for every use.

1. Slow performance

This application works as a big software with various features and functions.
Due to this, it takes time to open different files and launch applications.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

2. Compatibility issues

This software supports all the latest versions of operating systems, but
sometimes it doesn’t support the older ones. If you are using an older version of
the operating system, you might face some compatibility issues.

3. Bug problems

We all know that this software is not perfect. Sometimes we face some bugs in
the application and other times it may cause us some problems opening certain
files. Bugs mean that the software is not yet complete and still needs some
upgrades.

4. Some advanced features are not available

This software has a lot of advanced features but some of them are not available
yet. We need to wait until the developers complete their development.

5. Troubleshooting problems

Sometimes we face some troubleshooting problems while using MS Office. We


need to find solutions from different online blogs and forums. This software is
still not fully developed and sometimes it needs some tweaks and patches.

6. Higher RAM usage

Microsoft Office Suite uses a lot of RAM. This is the main reason for which we do
not recommend it to keep it on the same computer.

What is Microsoft 365?

Microsoft 365 is a cloud-powered productivity platform. A subscription to


Microsoft 365 provides all of the following:

 The latest productivity apps, such as Microsoft Teams, Word, Excel,


PowerPoint, Outlook, OneDrive, and so much more.
 AI-powered features to help you enhance your personal productivity, with
Copilot in Word, Excel, PowerPoint, Outlook, and OneNote.
 The ability to install on PCs, Macs, tablets, and phones.
 1 TB of OneDrive cloud storage.
 Feature updates and upgrades not available anywhere else.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Microsoft 365 is a fantastic tool for your business or organisation. In addition to


the standard suite of apps, the platform offers strong security, great
communication channels, and additional data analysis functions.

What’s included in Microsoft 365?

Microsoft 365 is packed with apps and features to make your professional life
easier. It includes apps such as Word, Excel, and PowerPoint. Depending on
what type of plan you’ve subscribed to, you can also access Publisher, Exchange,
and SharePoint.

Furthermore, you can host your own files online and access them whenever and
wherever since you also get up to 1TB of cloud storage with OneDrive.

Introduction to Microsoft Word


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Microsoft Word is one of the most widely used word processing programs,
known for its flexibility and ease of use in creating, editing, and formatting
documents. Whether you're drafting a simple letter, preparing a resume, or
working on a formal report, MS Word provides a rich set of tools to help you
produce professional and well-structured content. With features like text
formatting in Word, inserting tables and images, page layout options, and
built-in templates, users can handle a wide range of document tasks efficiently.

With Microsoft Word, users can easily create everything from resumes, letters,
and reports to essays, invoices, and brochures. The software provides robust
tools for text formatting, image insertion, page layout, and collaboration,
making it the go-to application for document creation.

Microsoft Word Interface


The Microsoft Word interface is designed for document creation and editing:
 Title Bar: Displays the document title and quick access to minimise,
maximise, and close options.
 Ribbon Tabs: Organised into functional tabs such as Home, Insert, Layout,
and Review—each containing related tools and commands.
 Workspace: The main area where users type and format the document
content.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

MS- Word Window Elements:- Various window elements of MS- Word

 Title bar
 Menu Bar
 Toolbars
 Workspace
 Status Bar
 Scroll Bars
 Scroll Box
 Task Pane
Components of the Word Window- Besides the usual PC window components
(close box, title bar, scroll bars, etc.), a Word window has other elements

Component Functionality or Purpose of the Component

Menu Bar Contains File,Edit, View, Insert, Format, Tools, Table, Window and
Help menus

Standard Contains icons for shortcuts to menu commands.


Toolbar

Formatting Contains pop-up menus for style, font, and font size; icons for
Tool Bar boldface, italic, and underline; alignment icons; number and bullet
list icons; indention icons, the border icon, highlight, and font color
icons.

Ruler Ruler on which you can set tabs, paragraph alignment, and other
formats.

Insertion Blinking vertical bar that indicates where text you type will be
Point inserted. Don’t confuse the insertion point with the mouse I-beam. To
move the insertion point, just click the mouse where you want the
point moved.

End-of-File Non-printing symbol that marks the end of the file. You cannot insert
Marker text after this mark.

Selection Invisible narrow strip along the left edge of the window. Your mouse
Bar (Gutter) pointer changes to a right-pointing arrow when it is in this area. It is
used to select a line, a paragraph, or the entire document.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Split Handle Double-click to split the window in two (to view different portions of
the same file). Double-click to return to one window

Status Bar Displays page number, section number, and total number of pages,
pointer position on page and time of day.

Task Pane Displays and groups commonly used features for convenience.

Office An animated character that can provide help and suggestions. There
Assistant are multiple characters to choose from, and it is possible to turn the
Office Assistant off.

Microsoft Word Tabs Explained


Now let us discuss the tabs and components of the MS Word. Using these tabs,
you can perform different types of operations on your documents, like you can
create, delete, style, modify, or view the content of your document.

1. File
It contains options related to the file, like New(used to create a new document),
Open(used to open an existing document), Save(used to save document), Save
As(used to save documents), History, Print, Share, Export, Info, etc.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

2. Home
It is the default tab of MS Word and it is generally divided into five groups, i.e.,
Clipboard, Font, Paragraph, Style and Editing. It allows you to select the color,
font, emphasis, bullets, position of your text. It also contains options like cut,
copy, and paste. After selecting the home tab you will get below options:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

3. Insert
Add content such as tables, images, hyperlinks, charts, word art, date/time,
header/footer, shapes, text boxes, equations, and more to your document.

4. Draw
It is the third tab present in the menu bar or ribbon. It is used for freehand
drawing in MS Word. It provides different types of pens for drawing as shown
below:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

5. Design
It is the fourth tab present in the menu bar or ribbon. The design tab contains
document designs that you can select, such as documents with centered titles,
offset headings, left-justified text, page borders, watermarks, page colour, etc.,
as shown in the below image:

6. Layout
It is the fifth tab present on the menu bar or ribbon. It holds all the options
that allow you to arrange your Microsoft Word document pages just the way
you want them. It includes options like set margins, display line numbers, set
paragraph indentation, and lines apply themes, control page orientation and
size, line breaks, etc., as shown in the below image:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

7. References
It is the sixth tab present in the menu bar or ribbon. The references tab lets
you add references to a document, then create a bibliography at the end of the
text. The references are generally stored in a master list, which is used to add
references to further documents. It includes options like, Table of Contents,
Footnotes, Citations & Bibliography, Captions, Index, Table of Authorities,
smart look, etc. After selecting References tab, you will get the below options:

8. Mailings
It is the seventh tab present in the menu bar or ribbon. It is a least used tab in
the menu bar. This tab is where you would create labels, print them on
envelopes, do mail merge, etc. After selecting mailing, you will get the below
options:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

9. Review
It is the eighth tab present in the menu bar or ribbon. The review tab contains,
commenting, language, translation, spell check, word count tools. It is good for
quickly locating and editing comments. After selecting a review tab, you will get
the options below:

10. View
It is the ninth tab present in the menu bar or ribbon. View tab allows you to
switch between single page or double page and also allows you to control the
layout tools It includes print layout, outline, web layout, task pane, toolbars,
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

ruler, header and footer, footnotes, full-screen view, zoom, etc. as shown in the
below image:

Types of Toolbars in Microsoft Office Applications and Their Functions

Microsoft Office applications like Word, Excel, and PowerPoint feature various
toolbars and interface components that enhance usability by providing quick
access to commands, tools, and information. Here’s an overview of the most
common toolbars and their functions.

1. Title Bar

The Title Bar is the topmost bar in any Microsoft Office application window.

 Function:
 Displays the name of the open document or file.
 Contains window control buttons for minimizing, maximizing,
and closing the application.
 Example: The Title Bar in Word will show “Document1 - Microsoft Word” if
the file hasn’t been saved yet.

2. Menu Bar (Older Microsoft Office Versions)

In older versions of Microsoft Office (prior to 2007), the Menu Bar is located
directly below the Title Bar.

 Function:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Provides drop-down menus like File, Edit, View, Insert, etc., giving
access to all program functions.
 Each menu contains commands grouped by functionality (e.g., File
menu includes Save, Open, and Print options).

Example: In Word 2003, selecting Insert > Table opens tools related to tables.

3. Ribbon (Modern Toolbar in Newer Versions)

In newer Office versions (2007 onward), the Ribbon replaces traditional toolbars
and menus. The Ribbon is a visually organized toolbar with tabs and groups of
commands.

 Function:
 Categorizes commands into tabs like Home, Insert, and Design for
ease of access.
 Each tab contains groups of related commands, such as Font,
Paragraph, and Styles under the Home tab.
 Allows customization with frequently used tools.

Example: The Home Tab on the Ribbon provides quick access to text formatting
tools like Bold, Italics, and Font Size.

4. Quick Access Toolbar

The Quick Access Toolbar is located above or below the Ribbon, providing
shortcuts to frequently used commands.

 Function:
 Includes common actions like Save, Undo, Redo, and others
chosen by the user.
 Can be customized to include commands frequently used for
productivity.

Example: A teacher creating lesson plans might add commands like Print and
Align Left to the Quick Access Toolbar for quick access.

5. Status Bar

The Status Bar is located at the bottom of the application window and provides
real-time updates and information about the current document or task.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Function:

 Displays document details such as page number, word count,


and line number.

Allows adjusting the document zoom level with a slider.

 Provides quick access to modes like Read Mode, Print Mode, or Draft
Mode in Word.

Example: In Excel, the Status Bar indicates calculations such as sum or average
for selected cells.

6. Formula Bar (Specific to Excel)

The Formula Bar, located above the worksheet interface in Excel, is used to work
with data and calculations.

 Function:
 Allows users to enter, edit, or view data and formulas associated
with the active cell.
 Displays the complete formula while only the result appears in the
selected cell.

Example: When entering = SUM(A1:A10), the Formula Bar shows the formula
while the corresponding cell displays the total sum.

7. Task Pane

The Task Pane is a supplementary interface element, usually appearing on the


right-hand side of the application window.

Function:

 Provides tools and options related to the current task, such as


formatting, hyperlinks, or templates.
 Offers contextual guidance depending on the feature being used.

Example: In Word, the Task Pane may display formatting options or clipboard
history when dealing with design tasks or copy-paste operations.

Summary Table of Toolbars and Components


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Toolbar/Component Location Function

Top of the Displays file name and window control


Title Bar
application buttons.
Provides drop-down menus for
Below the Title
Menu Bar commands (used in older Office
Bar
versions).
Below the Title Organizes commands into tabs and
Ribbon
Bar groups (modern Office versions).

Quick Access Above or below Provides shortcuts to frequently used


Toolbar the Ribbon commands like Save, Undo, and Redo.

Bottom of the Displays document info (e.g., page


Status Bar
application number, word count, and zoom slider).

Top of worksheets Enables data entry, editing, and


Formula Bar
in Excel viewing formulas in Excel.
Displays contextual tools for formatting
Task Pane Right-hand side
and task-specific

Importance of Toolbars in Microsoft Office

Toolbars and interface components in Microsoft Office significantly improve


productivity and usability by:

1. Providing Quick Access: Frequently used tools are just a click away,
reducing time spent searching for commands.
2. Enhancing Functionality: Features like the Ribbon and Quick Access
Toolbar make navigating complex tools easier.
3. Improving User Experience: Components such as the Status Bar and
Formula Bar provide real-time feedback and make tasks intuitive.

Cursor: The cursor in MS Word is the blinking vertical line indicating where you
can type, which can be moved with a mouse or keyboard shortcuts. You can also
customize its size, color, and thickness through your operating system's settings
for better visibility.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Moving the cursor


 Mouse: Click on the desired location in the document with the left mouse
button.
 Keyboard: Use the arrow keys to move one character at a time.
o Ctrl + Left/Right Arrow: Moves one word at a time.
o Ctrl + Up/Down Arrow: Moves up or down one paragraph.
o Home/End: Moves to the beginning or end of the current line.
o Ctrl + Home/End: Moves to the beginning or end of the document.

Microsoft Word Shortcut Keys

Using keyboard shortcuts in Microsoft Word helps you work faster and more
easily. Whether you are writing, formatting, or working with tables, these
shortcuts let you do tasks quickly without needing the mouse. This guide will
show you important shortcuts to help you use Word more efficiently and save
time.

Definition of Hotkeys in MS Word:

In Microsoft Word, hotkeys (also called keyboard shortcuts) are specific key
combinations that perform certain commands or actions quickly—without
needing to use the mouse or navigate through menus.

Select Text, Move, and Delete Text Shortcut Keys in MS Word


Here are more advanced MS Word hotkeys for selecting, moving, and deleting
text:
Shortcut Description

Shift + Arrow Right / Arrow Extend selection one character to the right
Left / to the left

Ctrl + Shift + Arrow Right / Extend selection one word to the right / to
Arrow Left the left
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Shortcut Description

Extend selection to the end / to beginning


Shift + End / Home of a line

Extend selection one line down / one line


Shift + Arrow Down / Arrow Up up

Extend selection one screen down / one


Shift + Page Down / Page Up screen up

Extend selection to end / to beginning of


Ctrl + Shift + End / Home document

Alt + Ctrl + Shift + Page Down Extend selection to end / to beginning of


/ Page Up visible window

Select all - Extend selection to entire


Ctrl + A document

Frequently Used Shortcuts in MS Word


Here are some of the frequently used Microsoft Word shortcuts:
Shortcut Description

Ctrl + N Create new document

Ctrl + O Open document

Ctrl + W Close document

Ctrl + S Save document

F12 Save document as

Ctrl + P Print document/ print preview


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Shortcut Description

Ctrl + F6 Switch between multiple Word documents

Alt + F, R Open Recent (file, recent)

Alt + Ctrl + P Switch to Print Layout view

Alt + Ctrl + O Switch to Outline view

Alt + Ctrl + N Switch to Draft view (used to be normal view)

Ctrl + scroll
Zoom in and zoom out
mouse

Open Zoom Menu (no native shortcut exists for zoom in/
Alt + W, Q zoom out)

Alt + Ctrl + S Split the document window

Formatting Shortcut Keys in Microsoft Word


To speed up formatting in MS Word, use these MS Word shortcut commands:
Shortcut Description

Ctrl + B Apply/remove bold

Ctrl + I Apply/remove italic

Ctrl + U Apply/remove underline

Ctrl + D Open the Font dialog box


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Shortcut Description

Ctrl + Shift + D Apply/remove double-underline

Ctrl + Shift + <, > Decrease/increase font size by one value

Ctrl + = Apply/remove subscript

Ctrl + Shift + = Apply/remove superscript

Ctrl + R Right-align paragraph

Ctrl + L Left-align paragraph

Ctrl + E Center-align paragraph

Ctrl + J Justify-align paragraph

Ctrl + T Increase hanging indent

Ctrl + Shift + T Decrease hanging indent

Ctrl + Alt + H Apply/remove Highlight Text Feature

Apply/remove words underline (only words, no


Ctrl + Shift + W spaces)
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Shortcut Description

Ctrl + Shift + H Apply/remove hidden formatting

Ctrl + Shift + A Apply/remove all caps

Ctrl + Shift + K Apply/remove small capitals

Change between all upper-, first letter upper-,


Shift + F3 and all lower-case

Alt + H, 4 Apply strike-through formatting (font dialog)

Ctrl + Shift + Q Change the selection to the Symbol font

Reveal Formatting (show all formats of


Shift + F1 selection)

Indent paragraph from the left and


Ctrl + M / Ctrl + Shift + M increase/decrease indent

Add or remove one line space preceding a


Ctrl + 0 paragraph

Ctrl + 1 Set line-spacing to single-space

Ctrl + 2 Set line-spacing to double-space


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Shortcut Description

Ctrl + 5 Set line-spacing to 1.5

Alt + Ctrl + Shift + S Open or close Styles task pane

Alt + Ctrl + 1 Apply Heading 1 style

Alt + Ctrl + 2 Apply Heading 2 style

Alt + Ctrl + 3 Apply Heading 3 style

Ctrl + Shift + N Apply Normal style

Alt + Shift + Arrow Right /


Promote/demote headings
Arrow Left

Ctrl + Shift + S Open Apply Styles task pane

Search and Replace Shortcut Keys in MS Word


Shortcut keys helps in search and replace are as follows:
Shortcut Description

Ctrl + H Open Find and Replace window

Ctrl + H, then Alt + D Open Find window

Shift + F4 Repeat last find after closing Find window


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Shortcut Description

Ctrl + Tab Jump between Find menu and document

Esc Close traditional Search window if active

Ctrl + F Open (new) Search menu in Navigation task pane

Alt + W, K Open and close Navigation pane (View, Navigation)

MS Word Ribbon Keyboard Shortcut Commands


MS Word shortcuts keys performed at the ribbon.
Shortcut Description

Ctrl + F1 Show or hide the ribbon

Space or
When in ribbon, open or activate the selected item
Enter

Alt + W, K Open and close Navigation pane (View, Navigation)

With Navigation Pane open: Switch forward/backwards


F6 / Shift + between (1) Navigation Pane, (2) Bottom Taskbar, (3) Ribbon,
F6 and (4) Document

Tab / Shift
In Navigation Pane: Move through Navigation Pane options
+ Tab

Tables Shortcut Keys in MS Word


Shortcut Keys used in MS Word for a table are as follows:
Shortcut Description

Arrow Down/Arrow Up Jump one row down/one row up


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Shortcut Description

Jump to (and select) next/previous


Tab/Shift + Tab table cell

Jump to first column/jump to last


Alt + Home/Alt + End column

Alt + Page Up/Alt + Page Down Jump to first row/jump to last row

Ctrl + Arrow Left/Ctrl + Arrow Right One cell to the left/to the right

Shift + End Select current table cell

End, then Shift + Home Select content of current table cell

Press and hold Shift + Arrow keys


Extend selection to adjacent cells
repeatedly

Ctrl + Shift + F8 Extend selection or block

Alt + S on numeric keypad Select an entire table

Alt + Shift + Arrow Up/Alt + Shift +


Move current row up or down
Arrow Down

In first column, press Shift + End Select row

In first row, press Alt + Shift + Page


Select column
Down

Delete columns with columns


Shift + Del selected

Shortcut key to check Spelling and Grammar in MS Word


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Task Shortcut Key

Check Spelling and Grammar F7

Print Documents Shortcuts Keys in MS Word

Shortcut keys in MS Word to print or close a document.


Shortcut Description

Ctrl + P Print a document (print preview)

Esc Close print preview

Arrow keys, Page up / Page Move around the preview pages (with focus on
Down preview page)

Move to first page / last page (with focus on


Ctrl + Home / Ctrl + End preview page)

1. Editing Text

Editing text means making changes to the content of a document.


It includes:

 Adding or deleting text


 Copying, cutting, and pasting text
 Undoing or redoing changes
 Checking spelling and grammar

Common hotkeys:

 Ctrl + X → Cut
 Ctrl + C → Copy
 Ctrl + V → Paste
 Ctrl + Z → Undo
 Ctrl + Y → Redo
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

2. Opening a Document

Opening means loading an existing document into Microsoft Word so you can
view or edit it.

Steps:

1. Click File → Open, or


2. Press Ctrl + O
3. Select the file and click Open

3. Creating a New Document

Creating means starting a blank or template-based document to type new


content.

Steps:

1. Click File → New


2. Choose Blank Document or a Template
3. Or press Ctrl + N

4. Saving a Document

Saving means storing your work on a computer or drive so it can be accessed


later.

Steps:

 First time: File → Save As (choose location and name)


 Afterward: File → Save or press Ctrl + S

Shortcuts:

 Ctrl + S → Save
 F12 → Save As

5. Printing a Document

Printing means producing a hard copy of your document using a printer.

Steps:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

1. Click File → Print, or


2. Press Ctrl + P
3. Choose printer settings and click Print

6. Editing Files

Editing files involves opening, modifying, and saving existing Word documents.
It can include:

 Adding new text or images


 Deleting or changing content
 Formatting paragraphs or pages

Shortcut:

 Ctrl + O → Open file


 Ctrl + S → Save changes

7. Formatting Text

Formatting means changing the appearance of text to make it look better or


emphasize meaning.

Examples:

 Font style, size, and color


 Bold, italic, underline
 Aligning text (left, right, center, justify)
 Line spacing and indentation

Common hotkeys:

 Ctrl + B → Bold
 Ctrl + I → Italic
 Ctrl + U → Underline
 Ctrl + E → Center align
 Ctrl + L → Left align
 Ctrl + R → Right align

8. Find and Replace

This feature helps you search for specific words or phrases and optionally
replace them with something else.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Steps:

1. Press Ctrl + F → Open Find pane


2. Press Ctrl + H → Open Find and Replace dialog
3. Enter the word(s) to find and what to replace them with
4. Click Replace or Replace All

9. Tables in MS Word

Definition:
A table is a way to organize information into rows and columns — similar to a
grid. Tables make data easier to read and compare.

Steps to Insert a Table:

1. Go to the Insert tab.


2. Click Table → Select the number of rows and columns you want.
3. Type your text inside the table cells.

You can:

 Add or delete rows/columns.


 Merge or split cells.
 Format the table (change border color, shading, text alignment, etc.).

Shortcut:

 Alt + N, T → Opens the Insert Table menu.

10. Columns in MS Word

Definition:
Columns divide the text of a document into two or more vertical sections —
similar to newspaper or magazine layouts.

Steps to Create Columns:

1. Select the text you want in columns.


2. Go to the Layout (or Page Layout) tab.
3. Click Columns → Choose Two, Three, or More Columns.

You can adjust:


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Number of columns.
 Width and spacing of columns.
 Apply to part of a document or the whole page.

Shortcut:

 Alt + P, J → Opens Columns menu (in some Word versions).

11. Spell Check in MS Word

Definition:
Spell Check is a built-in feature that checks for spelling and grammar
mistakes in your document and suggests corrections.

Steps to Use Spell Check:

1. Go to the Review tab.


2. Click Spelling & Grammar.
3. Word highlights errors and suggests corrections.
4. You can choose Change, Ignore, or Add to Dictionary.

Shortcuts:

 F7 → Run Spell Check.


 Right-click a red (spelling) or blue (grammar) underlined word for quick
fixes.

Indicators:

 🔴 Red underline → Spelling mistake


 🔵 Blue underline → Grammar or formatting issue

Thesaurus- A thesaurus can refer to any of the following:

1. A thesaurus is a software tool included with some word processors that


provides synonyms for selected words on command. Users using Microsoft
Word can open a thesaurus by highlighting the word they want to look up
and pressing the keyboard shortcut Shift+F7.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

2. A thesaurus is a book, program, or online service that provides alternative


or similar words to a word. For example, searching for "hope" may return
synonyms like "achievement," "faith," "ambition," and "optimism."

On Windows (Microsoft Word desktop app)

1. Highlight the word you want to find synonyms for.


2. Go to the Review tab on the Ribbon.
3. Click Thesaurus (it’s usually next to Spelling & Grammar).
4. The Thesaurus pane will open on the right — you can click any synonym
to replace your word.

Shortcut:
Press Shift + F7 after selecting a word to open the Thesaurus directly.

Thesaurus vs. dictionary

A thesaurus groups words with the same meaning (synonyms) and similar
words. On the other hand, a dictionary explains the definition of a word. For
example, looking up the word "computer" in a thesaurus may give words like
"PC," "CPU (central processing unit)," "calculator," "abacus," and "laptop" that
could be used instead of the word computer. Looking up the word "computer" in
a dictionary would define the word like what is found on our computer definition.

File protection: -

File protection in Microsoft Word helps keep your documents safe — either from
unauthorized editing, viewing, or accidental changes.

1. Password Protect a Document (to Open or Modify)

➤ To require a password to open or edit a document:

1. Click File → Info.


2. Select Protect Document → Encrypt with Password.
3. Enter a password and click OK.
4. Save your document.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

2. Restrict Editing

➤ To allow people to read but not edit (or only edit certain parts):

1. Click File → Info.


2. Click Protect Document → Restrict Editing.
3. In the panel that appears:
o Under Formatting restrictions, limit formatting changes.
o Under Editing restrictions, choose Allow only this type of editing in
the document → select No changes (Read only) or another option.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

o Click Yes, Start Enforcing Protection and set a password


(optional).

3. Mark as Final

➤ To indicate a document is complete and discourage editing:

1. Click File → Info.


2. Click Protect Document → Mark as Final.
3. Save and close.

4. Add a Digital Signature

➤ To verify authorship and integrity:

1. Click File → Info → Protect Document → Add a Digital Signature.


2. Follow the prompts to insert your certificate.

Protect a document with a password

You can control access to a document by implementing a password for


it. Passwords are case-sensitive and can be a maximum of 15 characters
long. Create a strong password, ideally one that you can easily remember. But
in case you might forget, you should also keep a copy of it in a safe place.

If you lose or forget your document password, Word won't be able to recover it
for you. It may be possible for your IT admins to help with password recovery,
but only if they had implemented the DocRecrypt tool before you created the
document password.

Windows: Go to File > Info > Protect Document > Encrypt with Password.

1. Type a password, press OK, type it again and press OK to confirm it.
2. Save the file to make sure the password takes effect.

1. Go to File > Info > Protect Document > Encrypt with Password.
2. Type a password, press OK, type it again and press OK to confirm it.
3. Save the file to make sure the password takes effect.

Mail Merge in MS Word


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Mail Merge in MS Word is a powerful tool that allows you to create personalized
documents quickly and efficiently. Whether you're sending out invitations,
newsletters, or customized letters, using Mail Merge in Word can save you
hours of manual work by automating the process of creating multiple
documents with unique data.

How to Mail Merge in MS Word-


Here are the steps to perform a mail merge in MS Word and personalize mass
letters by linking your document to a data source.

Step 1: Create a New Address List


Open MS Word and navigate to the Mailings tab. Then, click on the Start Mail
Merge group, select the Select Recipients button, and choose Type New List.
This will allow you to create a new address list for your mail merge.

Step 2: Enter Data in the "New Address List" Dialog


A dialog named "New Address List" will appear. Enter the desired data under
the given headings. To add a new record, click on the New Entry button at the
bottom of the dialog, and then click OK when you are done.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Step 3: Prepare the Master Letter


The next step is to prepare your master letter for use in the mail merge. Before
entering the letter text, link the Word document to your list of names. Create a
blank Word document, then go to the Mailings tab, click the Start Mail
Merge group, and select Start Mail Merge → Letters.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Step 4: Link the Master Letter to the Existing List


Click the Mailings tab, navigate to the Start Mail Merge group, and select
the Select Recipients button. Then choose the Use Existing List command to
link your master letter to the existing address list.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Step 5: Start Typing the Letter and Insert Merge Fields


Begin typing the letter content. To add the name, address, and other details for
the people on the list, go to the Mailings tab and, in the Write & Insert
Fields group, click the Insert Merge Field button. A dropdown will appear
showing all the table headings. Choose Title, then press the spacebar to create
a space.

Step 6: Add First Name, Last Name, and Address


Next, repeat the process to choose FirstName, followed by a space (press only
the spacebar, no other keys). Then, choose LastName and press the Enter key
to create a new line. Afterward, repeat the steps to select the Address field and
press the Enter key again.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Step 7: Preview the Merged Letters


Before carrying out the mail merge, preview how the merged letters will appear.
Go to the Mailings tab, and in the Preview Results group, click the Preview
Results button to see the merged fields in the document.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Step 8: Carry Out the Mail Merge


Once you're satisfied with the preview, proceed to the Mailings tab, go to
the Finish group, and click the Finish & Merge button. Select Edit Individual
Documents to carry out the actual mail merge.

Step 9: Create Separate Letters for Each Person


In the Merge to New Document panel, click All to create a separate letter for
each person on the list. Word will generate a new document with as many pages
as there are names on your list, and each page will contain the correctly merged
letter with the individual's details.

Step 10: Save the Merged Document


Once the merge is complete, save the new document with an appropriate name,
such as [Link], to keep your merged letters organized.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Macros in MS Word
A macro is a recorded set of commands or actions in Word that can be replayed
to perform repetitive tasks automatically. Macros are created using the
Developer tab’s recording feature, which captures user actions like formatting
text or inserting objects, and are stored for reuse in the same or other
documents.
Key Features
 Record and Replay: Capture a sequence of actions (e.g., formatting text)
and replay them with a single command.
 Customizable Triggers: Assign macros to keyboard shortcuts or buttons for
quick access.
 Document-Specific or Global: Save macros to a specific document or the
Normal template for universal use.
Example: Record a macro to apply consistent heading styles across a report.
How to Use Macros
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Step 1. Enable the Developer Tab

Step 2. Record a Macro


Start Recording:
 Go to Developer > Code group > Record
Macro (or View > Macros > Record Macro).
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

In the Record Macro dialog box:


o Enter a Macro name (e.g., “FormatText”), using no spaces or special
characters.

Choose where to store:


o All Documents ([Link]): Available in all Word documents.
o This Document: Available only in the current document.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

Assign a trigger (optional):


o Button: Add to the Quick Access Toolbar.
o Keyboard: Assign a shortcut.

Click OK to start recording.


MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Perform the desired actions (e.g., change font size, apply bold, insert a table).
 Click Developer > Stop Recording (or View > Macros > Stop Recording)
to finish.

Step 3. Run a Macro


Execute a Macro:
 Go to Developer > Macros (or View > Macros > View Macros).
 In the Macros dialog box, select the macro (e.g., “FormatText”) and
click Run.
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office

 Alternatively, use the assigned keyboard shortcut or Quick Access Toolbar


button.
Apply to Text or Document:
 Select the text or place the cursor where the macro should apply before
running it.
Step 4. Manage Macros
View and Delete Macros:
 Go to Developer > Macros > View Macros.
 Select a macro and click Delete to remove it, or Organizer to copy macros
between documents or templates.

Save Macro-Enabled Documents:


 Save documents with macros as Word Macro-Enabled Document
(*.docm) via File > Save As to preserve macro functionality.
UNIT-II CONTROL STRUCTURES AND FUNCTIONS

Contents
Control Structures- Conditional Statements, Looping Statements
Functions-Library Functions, User defined Functions, Function Prototype, Function Definitions,
Types of Functions, Functions with and without arguments, Functions with no return and with
Return Values - Nested Functions - Recursion.

CONTROL STRUCTURES
CONTROL STRUCTURE

Control Statements

Conditional Unconditional

[Link]

Decision Making Statement Loop Control Statement 2. continue

1. if Statement 1. for 3. break

2. if.. else statement 2. while

3. nested if statement 3. do-while

4. if..else ladder

5. switch statement

CONDITIONAL STATEMENT

Decision Making Statement


If Statement:
 The if statement is a decision making statement.
 It is used to control the flow of execution of the statement and also used to the
logically whether the condition is true or false
 It is always used in conjunction with condition.
False
Condition

True

Statements

Syntax:
If(condition)
{

True statements;
}
 If the condition is true, then the true statements are executed.
 If the condition is false then the true statements are not executed, instead the
program skips past them.
 The condition is given by relational operators like ==,<=,>=,!=,etc.

Example 1: //program to check whether the entered number is less than 25

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
printf(“Enter one value”);
scanf(“%d”,&i);
if(i<=25)
printf(“The entered no %d is < 25”,i);
getch();
}
Output:

Enter one value 5


The entered no 5 is < 25

Example 2: //program to calculate the sum and multiplication using if Statement

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,n;
clrscr();
printf(“Enter two values”);
n=scanf(“%d%d”,&a,&b);
if(n==2)
{
printf(“the sum of two numbers : %d”,a+b);
printf(“the product of two numbers:%d”,a*b);
}
getch();
}

Output:

Enter two value 5 10


the sum of two numbers : 15
the product of two numbers : 50

if.. else statement:

 It is basically two way decision making statement and always used in conjunction
with condition.
 It is used to control the flow of expression and also used to carry the logical test and
then pickup one of the two possible actions depending on the logical test.
 If the condition is true, then the true statements are executed otherwise false
statements are executed.
 The true and false statements may be single or group of statements.

Condition

True Statements False Statements


Syntax:
If (condition)

True statements;
else
False statements;

Example 1: //program to find the greatest of two number.

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf(“Enter two value”);
scanf(“%d%d”,&a,&b);
if(a>b)

printf(“The given no %d is greatest”,a);


else
printf(“The given no %d is greatest”,b);
}

Output:

Enter two value 5 10


The given no 10 is greatest

Nested if..else Statement:

When a series of if_else statements are needed in a program, we can write an entire
if_else statement inside another if and it can be further nested. This is called nesting if.

Syntax:
if(condition 1)
{
if(condition 2)
{
True statement 2;
else
False statement 2;
}
else
False statement 1;
}
Example 1: //program to find the greatest of three numbers.

#include <stdio.h>

int main ()
{
/* local variable definition */
int a = 100;
int b = 200;

/* check the boolean condition */


if( a == 100 )
{
/* if condition is true then check the following */
if( b == 200 )
{
/* if condition is true then print the following */
printf("Value of a is 100 and b is 200\n" );
}
}
printf("Exact value of a is : %d\n", a );
printf("Exact value of b is : %d\n", b );

return 0;
}

Output:

Value of a is 100 and b is 200


Exact value of a is : 100
Exact value of b is : 200
If_else Ladder:

 Nested if statements will become complex, if several conditions have to be checked.


 In such situations we can use the else if ladder .

Syntax:
if(condition 1)
{
if(condition 2)
{
True statement 2;
}
elseif(condition 3)
{
True statement 3;
else
False statement 3;
}
else
False statement 1;
}

Switch Statement
 The switch statement is used to execute a particular group of statements from
several available groups of statements.
 It allows us to make a decision from the number of choices.
 It is a multi-way decision statement.

Rules for writing switch () statement.


 The expression in switch statement must be an integer value or a character
constant.
 No real numbers are used in an expression.
 Each case block and default block must be terminated with break statement.
 The default is optional and can be placed anywhere, but usually placed at end.
 The ‘case’ keyword must terminate with colon(:).
 Cases should not be identical.
 The values of switch expression is compared with the case constant expression in
the order specified i.e., from top to bottom.
switch
( Expression)

case 1: statements
break;

case 2: statements
break;

default: statements
break;

Syntax:

switch(expression)
{
case 1:
state
ment;
break;
case 2:
state
ment;
break;
default: statement;
break;
}

// program to print the give number is odd / even using switch case statement.

#include<stdio.h>
#include<conio.h> void main()
{
int a,b,c;
printf(“Enter one value”); scanf(“%d”,&a);
switch(a%2)
{
case 0:
printf(“The given no %d is even”, a);
break;
default :
printf(“The given no %d is odd”, a);
break;
}
}

Output:

Enter one value 5


The given no 5 is odd

Unconditional statement
Break statement
 The break statement is used to terminate the loop.
 When the keyword break is used inside any loop, control automatically transferred to
the first statement after the loop.

Syntax:
break;

//program to print the number upto 5 using break statement

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=1;i<=10;i++)
{
if(i==6)
break;
printf(“%d”,i);
}
}
Output:
1 2 3 4 5

While(condition) Do for(initialize;condition; incr/dec)


{ …….. { …….. { ……..
if(condition) if(condition) if(condition)
beak; break; break;
………. ………. ……….
} }while(condition); }

Continue Statement

 In some situation, we want to take the control to the beginning of the loop, bypassing
the statement inside the loop which have not been executed, for this purpose the
continue is used.
 When the statement continue is encountered inside any loop, control automatically
passes to the beginning of the loop.

Syntax:
continue;

While(condition)
{
……..
if(condition)
continue;
……….
}

While(condition) Do for(initialize;condition; incr/dec)


{ …….. { …….. { ……..
if(condition) if(condition) if(condition)
continue; continue; continue;
………. ………. ……….
} } while (condition); }
Difference between break and continue

Break Continue

Break statement takes the control to the Continue statement takes the control to be
outside of the loop beginning of the loop
It is also in switch statement This can be used only in loop statements

Always associated with if condition in loop This is also associated with if condition

Goto Statement:

 C provides the goto statement to transfer control unconditionally from one place to
another place in the program.
 A goto statement can change the program control to almost anywhere in the program
unconditionally.
 The goto statement require a label to identify the place to move the execution.
 The label is a valid variable name and must be ended with colon(:).

Syntax:

1. goto label; 2. label:


…… …..……
……. ………..
label: goto label;

/* program to print the given both number is equal or not*/

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf(“Enter the numbers”);
scanf(“%d%d”,&a,&b);
if(a==b)
goto equal;
else
{
printf(“%d and %d are not equal”,a,b);
exit(0);
}
equal: printf(“%d and %d are equal”,a,b);
}

Output:

Enter the numbers 4 5


4 and 5 are not equal

Enter the numbers 5 5


5 and 5 are equal

LOOPING STATEMENTS

A loop statement allows us to execute certain block of code repeatedly until test condition is
false.

There are 3 types of loops in C programming:

1. for loop
2. while loop
3. do...while loop

for loop:

The syntax for a for loop is

for ( variable initialization; condition; variable update )


{
Code to execute while the condition is true
}

The initialization statement is executed only once at the beginning of the for loop. Then the test
expression is checked by the program. If the test expression is false, for loop is terminated. But
if test expression is true then the code/s inside body of for loop is executed and then update
expression is updated. This process repeats until test expression is false.
for loop example

Write a program to find the sum of first n natural numbers where n is entered by user.
Note: 1,2,3... are called natural numbers.

#include <stdio.h>
void main(){
int n, count, sum=0;
printf("Enter the value of n.\n");
scanf("%d",&n);
for(count=1;count<=n;++count) //for loop terminates if count>n
{
sum+=count; /* this statement is equivalent to
sum=sum+count */
}
printf("Sum=%d",sum);

Output

Enter the value of


n. 19
Sum=190
In this program, the user is asked to enter the value of n. Suppose you entered 19 then, count is
initialized to 1 at first. Then, the test expression in the for loop,i.e., (count<= n) becomes true.
So, the code in the body of for loop is executed which makes sum to 1. Then, the expression
++count is executed and again the test expression is checked, which becomes true. Again, the
body of for loop is executed which makes sum to 3 and this process continues. When count is
20, the test condition becomes false and the for loop is terminated.

/* C program to check whether a number is prime or not. */

#include <stdio.h>
int main()
{
int n, i, flag=0;
printf("Enter a positive integer: ");
scanf("%d",&n);
for(i=2;i<=n/2;++i)
{
if(n%i==0)
{
flag=1;
break;
}
}
if (flag==0)
printf("%d is a prime number.",n);
else
printf("%d is not a prime number.",n);
return 0;
}

Output

Enter a positive integer: 29


29 is a prime number.

This program takes a positive integer from user and stores it in variable n. Then, for loop is
executed which checks whether the number entered by user is perfectly divisible by i or not
starting with initial value of i equals to 2 and increasing the value of i in each iteration. If the
number entered by user is perfectly divisible by i then, flag is set to 1 and that number will not
be a prime number but, if the number is not perfectly divisible by i until test condition i<=n/2 is
true means, it is only divisible by 1 and that number itself and that number is a prime number.
Different Types of For Loop in C Programming

For loop can be implemented in different ways

1. Single Statement inside For Loop


2. Multiple Statements inside For Loop
3. No Statement inside For Loop
4. Semicolon at the end of For Loop
5. Multiple Initialization Statement inside For
6. Missing Initialization in For Loop
7. Missing Increment/Decrement Statement
8. Infinite For Loop
9. Condition with no Conditional Operator.

Single Statement inside For Loop:

for(i=0;i<5;i++)
printf("sathyabama");

1. Above code will print sathyabama word 5 times.


2. We have single statement inside for loop body.
3. No need to wrap printf inside opening and closing curly block.
4. Curly Block is Optional.

Multiple Statements inside For Loop

for(i=0;i<5;i++)
{
printf("Statement 1"); printf("Statement 2");
printf("Statement 3"); if(condition)
{
--------
--------
}
}
If we have block of code that is to be executed multiple times then we can use curly braces to
wrap multiple statement in for loop
No Statement inside For Loop

for(i=0;i<5;i++)
{

}
It is bodyless for loop. It is used to increment value of “i”.This are not used generally. At
the end ,for loop value of i will be 5.

Semicolon at the end of For Loop:

for(i=0;i<5;i++);

 We will not get compile error if semicolon is at the end of for loop.
 This is perfectly legal statement in C Programming.
 This statement is similar to bodyless for loop.

Multiple Initialization Statement inside For:

for(i=0,j=0;i<5;i++)
{
statement1;
statement2;
statement3;
}

Multiple initialization statements must be seperated by Comma .

Missing Increment/Decrement Statement:


for(i=0;i<5;)
{
statement1;
statement2;
statement3;
i++;
}

we have to explicitly alter the value i in the loop body.

Missing Initialization in For Loop:


i = 0;
for(;i<5;i++)
{
statement1;
statement2;
statement3;
}

we have to set value of ‘i’ before entering in the loop otherwise it will take garbage value of „i‟.
Infinite For Loop:
i = 0;
for( ; ; )
{
statement1;
statement2;
statement3;
if(breaking condition)
break;
i++;
}

Infinite for loop must have breaking condition in order to break for loop. otherwise it will cause
overflow of stack.
While Loop

while loop repeatedly executes a target statement as long as a given


condition is true.

Initialization;
while(condition)
{
----------
---------
----------
------
Increment/decrement;
}

 For Single Line of Code – Opening and Closing braces are not needed. while(1) is used
for Infinite Loop
 Initialization, Increment/Decrement and Condition steps are on different Line.
 While Loop is also Entry Controlled Loop.[i.e conditions are checked if found true then
and then only code is executed ]
Examples:
#include <stdio.h>

int main()
{
int y = 0;/* Don't forget to declare variables*/
while ( y < 10 ) {/* While y is less than 10 */
printf( "%d\n", y );
y++; /* Update y so the condition can be met
eventually */
}
getchar();
}

C Program to Find Number of Digits in a Number


#include <stdio.h>
int main()
{
int n,count=0;
printf("Enter an integer: ");
scanf("%d", &n);
while(n!=0)
{
n/=10; /* n=n/10 */
++count;
}
printf("Number of digits: %d",count);
}
Output:
Enter an integer: 34523 Number of digits: 5
Types of infinite while loop

Semicolon at the end of while loop

#include<stdio.h>
void main()
{
int num=300;
while(num>255); //Note it Carefully
printf("Hello");
}
Output :
Will not print anything
1. In the above program , Condition is specified in the While Loop
2. Semicolon at the end of while indicated while without body.
3. In the program variable num doesn‟t get incremented , condition remains true forever.
4. As Above program does not have Loop body , It won‟t print anything

Non-Zero Number as a Parameter

#include<stdio.h>
void main()
{
while(1)
printf("Hello");
}
Output :

Infinite Time "Hello" word

1. We can specify any non-zero positive number inside while loop


2. Non zero number is specified in the while loop which means that while loop will remains
true forever.

Subscript variable remains the same

#include<stdio.h>
void main()
{
int num=20;
while(num>10) {
printf("Hello");
}
}

Output :

Infinite Time "Hello C" word


Explanation :

1. Condition is specified in while Loop, but terminating condition is not specified and even
we haven‟t modified the condition variable.
2. In this case our subscript variable (Variable used to Repeat action) is not either
incremented or decremented
3. so while remains true forever.
Character as a Parameter in While Loop

#include<stdio.h>
void main()
{
while('A')
printf("Hello");
}

Output :
Infinite Time "Hello" word

Explanation :

1. Character is Represented in integer in the form of ASCII internally.


2. Any Character is Converted into Non-zero Integer ASCII value
3. Any Non-zero ASCII value is TRUE condition , that is why Loop executes forever

DO..WHILE

DO..WHILE loops executes the body of the loop atleast once.

The structure is

initialization;
do
{
--------------
--------------
incrementation;
}while(condition);

The condition is tested at the end of the block instead of the beginning, so the block will be
executed at least once. If the condition is true, it go back to the beginning of the block and
execute it again. A do..while loop is almost same as a while loop except that the loop body is
guaranteed to execute at least once.

 It is Exit Controlled Loop.


 Initialization , Incrementation and Condition steps are on different Line.
 It is also called Bottom Tested.
 Semicolon must be added after the while
Example:

#include <stdio.h>

int main()
{
int z;

z = 0; do {
/* " sathyabama is printed at least one time even though the
condition is false */
printf( "sathyabama\n" ); } while ( z != 0 );
getchar();

C Program to print first 5 Natural Numbers

Using For Loop

#include<stdio.h>

void main() { int i = 1;

for (i = 1; i <= 5; i++) { printf("%d", i);


}
}
1
2
3
4
5

Using While Loop

#include<stdio.h>

void main() { int i = 1;


while (i <= 5) {
printf("%d", i); i++;
}
}

Using Do-While Loop

#include<stdio.h>

void main() {
int i = 1;

do {
printf("%d", i);
i++;
} while (i <= 5);

}
FUNCTIONS

LIBRARY FUNCTIONS

Definition

C Library functions are inbuilt functions in C language which are clustered in a group and
stored in a common place called Library. Each and every library functions in C executes explicit
functions. In order to get the pre- defined output instead of writing our own code, these library
functions will be used. Header file consists of these library functions like Function prototype and
data definitions.

 Every input and output operations (e.g., writing to the terminal) and all mathematical
operations (e.g., evaluation of sines and cosines) are put into operation by library
functions.
 The C library functions are declared in header files (.h) and it is represented as
[file_name].h
 The Syntax of using C library functions in the header file is declared as
“#include<file_name.h>”. Using this syntax we can make use of those library functions.
 #include<filename.h>” command defines that in C program all the codes are included in
the header files followed by execution using compiler.
 It is required to call the suitable header file at the beginning of the program in terminal in
order to use a library function. A header file is called by means of the pre-processor
statement given below,

#include<filename.h>

Whereas the filename represents the header file name and #include is a pre- processor directive.
To access a library function the function name must be denoted, followed by a list of
arguments, which denotes the information being passed to the function.

Example

In case if you want to make use of printf() function, the header file <stdio.h> should be included at
the beginning of the C program.

#include <stdio.h>
int main()
{
/* NOTE: Error occurs if printf() statement is written without using
the header file */

printf(" Hello World");


}
The „main() function‟ is also a library function which is called at the initial of the program.

Example
To find the square root of a number we use our own part of code to find them but this may
not be most efficient process which is time consuming too. Hence in C programming by declaring
the square root function sqrt() under the library function “math.h” will be used to find them rapidly
and less time consuming too. Square root program using the library functions is given below:
Finding Square root Using Library Function
#include <stdio.h>
#include <math.h>
int main(){
float num,root;
printf("Enter a number to find square root.");
scanf("%f",&num);
root=sqrt(num); /* Computes the square root of num and stores in
root. */
printf("Square root of %.2f=%.2f",num,root);
return 0;
}

List of Standard Library Functions in C Programming

C Header Files

ctype.h stdio.h conio.h string .h m ath.h stdlib.h tim e.h

Adding User Defined functions in C library:

 In C Programming we can declare our own functions in C library which is called as user-
defined functions.
 It is possible to include, remove, change and access our own user defined function to or
from C library functions.
 Once the defined function is added to the library it is merely available for all C programs
which are more beneficial of including user defined function in C library function
 Once it is declared it can be used anywhere in the C program just like using other C library
functions.
 By using these library functions in GCC compilers (latest version), compilation time can be
consumed since these functions are accessible in C library in the compiled form.
 Commonly the header files in C program are saved as ”file_name.h” in which all library
functions are obtainable. These header files include source code and this source code is
further added in main C program file where we include this header file via “#include
<file_name.h>” command.

Steps for adding user defined functions in C library:

Step 1:

For instance, hereby given below is a test function that is going to be included in the C
library function. Write and save the below function in a file as “addition.c”

addition(int a, int b)
{
int sum;
total =a + b;
return sum;
}

Step 2:

Compile “addition.c” file by using Alt + F9 keys (in turbo C).


step 3:

A compiled form of “addition.c” file would be created as “[Link]”.


Step 4:

To add this function to library, use the command given below (in turbo C).
c:\> tlib [Link] + c:\ [Link]
+ represents including c:\[Link] file in the math library.
We can delete this file using – (minus).

Step 5:
Create a file “addition.h” and declare sample of addition() function like below.
int addition (int a, int b);
Now “addition.h” file has the prototype of function “addition”.

Note : Since directory name changes for each and every IDE, Kindly create, compile and
add files in the particular directory.
Step 6:

Here is an example to see how to use our newly added library function in a C program.

# include <stdio.h>
// User defined function is included here.
# include “c:\\addition.h”
int main ( )
{
int total;
// calling function from library
total = addition (10, 20);
printf ("Total = %d \n", total);
}

Output:
Total = 30

 Source code checking for all header files can be checked inside “include” directory
following C compiler that is installed in system.
 For instance, if you install DevC++ compiler in C directory in our system, “C:\Dev-
Cpp\include” is the path where all header files will be readily available.

Mostly used header files in C:


C library functions and header files in which they are declared in conio.h is listed below:
[Link] Header file Description
1 stdio.h A standard input/output header file where Input/ Output functions are
declared
2 conio.h Console input/output header file
3 string.h String functions are defined in this header file
4 stdlib.h The general functions used in the C program is defined in this header file.
5 math.h Mathematical related functions are defined in this header file.
6 time.h Time and clock allied functions are defined in this header file.
7 ctype.h Every character managing functions are declared in this header file
8 errno.h This header file contains Error handling functions.
9 assert.h Diagnostics functions are declared in this header file.

C – conio.h library functions

The entire C programming inbuilt functions that are declared in conio.h header file are given
below. The source code for conio.h header file is also given below for your reference.
List of inbuilt conio.h file C functions:

[Link] Function Description


1 clrscr() This function is used to clear the output screen.
2 getch() It reads character from keyboard
3 getche() It reads character from keyboard and echoes to o/p screen
4 textcolor() This function is used to change the text colour
5 textbackground() This function is used to change text background

C – stdio.h library functions


Inbuilt functions of C declared in stdio.h header file are given below.
[Link] Function Description
1 printf() This function is used to print the character, string, float, integer, octal
and hexadecimal values onto the output screen
2 scanf() This function is used to read a character, string, numeric data from keyboard.
3 getc() It reads character from file
4 gets() It reads line from keyboard
5 getchar() It reads character from keyboard
6 puts() It writes line to o/p screen
7 putchar() It writes a character to screen
8 clearerr( ) Clears the error indicators
9 f open() All file handling functions are defined in this header file.
10 f close() closes an opened file
11 getw() reads an integer from file
12 putw() writes an integer to file
13 f getc() reads a character from file
14 putc() writes a character to file
15 f putc() writes a character to file
16 f gets() reads string from a file, per line at a time
17 f puts() writes string to a file
18 f eof() finds end of file
19 f getchar reads a character from keyboard
20 f getc() reads a character from file
21 f printf() writes formatted data to a file
22 f scanf() reads formatted data from a file
23 f getchar reads a character from keyboard
24 f putchar writes a character from keyboard
25 f seek() moves file pointer position to given location
26 SEEK_SET moves file pointer position to the beginning of the file
27 SEEK_CUR moves file pointer position to given location
28 SEEK_END moves file pointer position to the end of file.
29 f tell() gives current position of file pointer
30 rewind() moves file pointer position to the beginning of the file
31 putc() writes a character to file
32 sprint() writes formatted output to string
33 sscanf() Reads formatted input from a string
34 remove() deletes a file
35 fflush() flushes a file
Functions

 A function is a group of statement that is used to perform a specified task which


repeatedly occurs in the main program. By using function, we can divide the complex
problem into a manageable problem.
 A function can help to avoid redundancy.
 Function can be of two types, there are
1. Built-in Function (or) Predefined Function (or) Library
Function
2. User defined Function

Functions

Predefined Function User-defined Function

Difference between Predefined and User-defined Functions

Predefined Function User-defined function

Predefined function is a function which is User- Defined function is a function which is


already defined in the header file (Example: created by the user as per requirement of its
math.h, string.h, etc) owner

Predefined Function is a part of a header file, User- Defined function are part of the program
which are called at runtime which are compiled at runtime

The Predefined function name is given by the User- Defined function name created by the
developer user

Predefined Function name cannot be changed User defined Function name can be changed
User Defined Functions

 The function defined by the users according to their context (or) requirements is
known as a user defined function.
 The User defined function is written by the programmer to perform specific task (or)
operation, which is repeatedly used in the main program.
 These functions are helpful to break down the large program into a number of the
smaller function.
 The user can modify the function in order to meet their requirements.
 Every user define function has three parts namely
Function Declaration
Function Calling
Function Definition

Need for user-defined function

 While it is possible to write any complex program under the function, and it leads to a
number of problems, such as
 The problem becomes too large and complex.
 The user can‟t go through at a glance
 The task of debugging, testing and maintenance become difficult.
 If a problem is divided into a number of parts, then each part may be independently
coded and later it combined into a single program. These subprograms are called
functions, it is much easier to understand, debug and test the program.

Merits of User-Defined Function


 The length of the source program can be reduced by dividing it into smaller functions
 It provides modularity to the program
 It is easy to identify and debug an error
 Once created a user defined function, can be reused in other programs
 Function facilitates top-down programming approach
 The Function enables a programmer to build a customized library of repeatedly used
routines
 Function helps to avoid coding of repeated programming of the similar instruction

Elements of User-Defined Function


1. Function Declaration
2. Function Call
3. Function Definition

Function Declaration
 Like normal variable in a program, the function can also be declared before they
defined and invoked
 Function declaration must end with semicolon (;)
 A function declaration must declare after the header file
 The list of parameters must be separated by comma.
 The name of the parameter is optional, but the data type is a must.
  If the function does not return any value, then the return type void is must.
 If there are no parameters, simply place void in braces.
 The data type of actual and formal parameter must match.

Syntax:
Return_type function_name (datatype parameter1, datatype parameter2,…);
Description:

Return type : type of function


Function_name : name of the function
Parameter list or argument list : list of parameters that the function
can convey.

Example:
int add(int x,int y,int z);

Function Call
The function call be called by simply specifying the name of the function, return
value and parameters if presence.

Syntax: function_name();
function_name(parameter);
return_value =function_name (parameter);

Description:
function_name : Name of the function
Parameter : Actual value passed to the calling function

Example
fun();
fun(a,b);
fun(10,20);
c=fun(a,b);
e=fun(2.3,40);

Function Definition

 It is the process of specifying and establishing the user defined function by specifying
all of its element and characteristics.
Syntax:
Return_type function_name (datatype parameter1, datatype parameter2)
Example 1
#include<stdio.h>
#include<conio.h>
void add(); //Function Declaration void sub();//Function Declaration
void main()
{
clrscr();
add(); //Function call
sub(); //Function call
getch();
}
void add() //Function Definition
{
int a,b,c;
printf(“Enter two values”);
scanf(“%d%d”,&a,&b); c=a+b;
printf(‚add=%d‛,c);
}
void sub() //Function Definition
{
int a,b,c;
printf(“Enter two values”);
scanf(“%d%d”,&a,&b);
c=a-b;
printf(“sub=%d”,c);
}
Example 2 :
//Program to check whether the given number is odd or even
#include<stdio.h>
#include<conio.h>
void oddoreven()
{
printf("Enter One value");
scanf("%d",&oe);
if(oe%2==0)
printf("The Given Number%d is even");
else
printf("The Given Number %d is odd");
}
void main()
{
clrscr();
oddoreven();
getch();
}

Function Parameter

 The Parameter provides the data communication between the calling function and called
function.
 There are two types of parameters.

o Actual parameter: passing the parameters from the calling function to the
called function i.e the parameter, return in function is called actual parameter
o Formal parameter: the parameter which is defined in the called function i.e. The
parameter, return in the function definition is called formal parameter

Example:
main()
{
………..
Where
………..
Fun(a,b);
a,b are the actual
……….. parameters
………..
} x,y are formal parameter
Fun(int x,int y)
{
…………
…………
}
Example Program

#include<stdio.h>
#include<conio.h>
void add(int,int); //Function Declaration Output:
void sub(float,int);//Function Declaration
void main() add=7
{ sub=-2.500000
clrscr();
add(3,4); //Function call
sub(2.5,5); //Function call
getch();
}
void add(int a,int b)//Function Definition
{
int c;
c=a+b;
printf(“add=%d”,c);
}
void sub(float a, int b) //Function Definition
{
float c;
c=a-b;
printf(“sub=%f”,c);
}
Example 2:
//program for factorial of given
number #include<stdio.h>
#include<conio.h> void main()
{
int fact(int); Output:
int f; Enter one value 5
clrscr(); The Factorial of given
printf("Enter one value"); number 5 is 120
scanf("%d",&f);
printf("The Factorial of given number %d is %d",f,fact(f));
getch();
}
int fact(int f)
{
if(f==1) return 1;
else
return(f*fact(f-1));
}
Function Prototype (or) Function Interface

 The functions are classified into four types depends on whether the arguments
are present or not, whether a value is returned or not. These are called
function prototype.
 In ‘C’ while defining user defined function, it is must to declare its prototype.
 A prototype states the compiler to check the return type and arguments type of
the function.
 A function prototype declaration consists of the function’s return type, name
and argument. It always ends with semicolon. The following are the function
prototypes
o Function with no argument and no return value.
o Function with argument and no return value.
o Function with argument and with return value.
o Function with no argument with return value.

Function with no argument and no return value

 In this prototype, no data transfer takes place between the calling function and
the called function. i.e., the called program does not receive any data from the
calling program and does not send back any value to the calling program.

Syntax:-
main() void Fun()
{ {
The dotted lines indicates that,
………..
there is only transfer of control,
………..
……….. but no data transfer.
………..
Fun();
……….. }
………..
}
Example program 1
#include<stdio.h> Output:
#include<conio.h> Enter two values 6 4
mul=24
void mul();
void main()
{
clrscr();
mul();
getch();
}
void mul()
{
int a,b,c;
printf(“Enter two values”);
scanf(“%d%d”,&a,&b);
c=a*b;
printf(“mul=%d”,c);
}
Example program 2
//Program for finding the area of a circle using Function with no argument
and no return value
I#include<stdio.h>
#include<conio.h>
void circle();
Output:
void main()
Enter radius 5
{ The area of circle 78.500000
circle();
}
void circle()
{
int r;
float cir;
printf("Enter radius");
scanf("%d",&r);
cir=3.14*r*r;
printf("The area of circle is %f",cir);
}
Function with argument and no return value
 In this prototype, data is transferred from the calling function to called
function. i.e., the called function receives some data from the calling function
and does not send back any values to calling function
 It is one way data communication.
Syntax:-
main() void Fun(x,y) The solid lines indicate data
{ { transfer and dotted line indicates
……….. ……….. a transfer of control.
……….. ………..
Fun(a,b);
a and b are the actual
……….. }
……….. parameters
}
Example program 1: x and y are formal parameters
#include<stdio.h>
#include<conio.h>
void add(int,int);
void main() Output:
{ Enter two values 6 4
clrscr(); add=10

int a,b;
printf(“Enter two values”);
scanf(“%d%d”,&a,&b);
add(a,b);
getch();
}
void add(int x,int y)
{
int c;
c=x+y;
printf(“add=%d”,c);
}
Example program 2:
//Program to find the area of a circle using Function with argument and no return value
#include<stdio.h>
#include<conio.h>
void circle(int);
Output:
void main()
Enter radius 5
{ The area of circle 78.500000
int r;
clrscr();
printf("Enter radius");
scanf("%d",&r);
circle(r);
}
void circle(int r)
{
float cir;
cir=3.14*r*r;
printf("The area of circle is %f",cir);
getch();
}

Function with argument and with return value.


 In this prototype, the data is transferred between the calling function and
called function. i.e., the called function receives some data from the calling
function and sends back returned value to the calling function.
 It is two way data communication
Syntax:- The solid lines indicates data transfer
main() int Fun(x,y) takes place in between thecalling
{ { program and called program
……….. ………..
……….. ……….. a,b are the actual parameter
c=Fun(a,b); return(z);
……….. } x,y are formal parameter
}
Example program 1:
#include<stdio.h>
#include<conio.h> Output:
void add(int,int); Enter two values 6 4
Add=10
void main()
{
clrscr();
int a,b,c;
printf(“Enter two values”);
scanf(“%d%d”,&a,&b);
c=add(a,b);
printf(“Add=%d”,c);
getch();
}
void add(int x,int y)
{
int m;
m=x+y;
return m;
}
Example Program 2
// Program to find the area of a circle using Function with argument
and with return value
#include<stdio.h>
#include<conio.h>
float circle(int);
void main()
{
int r;
clrscr(); Output:
printf("Enter radius"); Enter radius 5
the area of circle 78.500000
scanf("%d",&r);
printf("the area of circle is %f",circle(r));
getch();
}
float circle(int r)
{
float cir;
cir=3.14*r*r;
return cir;
}
Function with no argument with return value
 In this prototype, the calling function cannot pass any arguments to the called
function, but the called program may send some return value to the calling function.
 It is one way data communication
Syntax:-
main() int Fun() The dotted line indicates a
{ { control transfer to the called
………..
……….. program and the solid line
……….. indicates data return to the
………..
Fun(); calling program
return(z);
……….. }
………..
}
Example program 1
#include<stdio.h>
#include<conio.h>
int add();
void main()
Output:
{
Enter two values 6 4
clrscr(); Add=10
int z;
z=add();
printf(“Add=%d”,z);
getch();
}
int add()
{
int a,b,c;
printf(“Enter two values”);
scanf(“%d%d”,&a,&b);
c=a+b;
return c;
}
Example Program 2
// Program to the area of a circle using no argument with a return
value
#include<stdio.h>
#include<conio.h>
float circle();
Output:
void main()
Enter radius 5
{ the area of circle 78.500000
clrscr();
printf("the area of circle is %f",circle());
getch();
}
float circle()
{
float cir;
int r;
printf("Enter radious");
scanf("%d",&r);
cir=3.14*r*r;
return cir;
}
Parameter Passing Methods (or) Passing Arguments to Function

 Function is a good programming style in which we can write reusable code that
can be called whenever required.
 Whenever we call a function, the sequence of executable statements gets
executed. We can pass some of the information (or) data to the function for
processing is called a parameter.
 In ‘C’ Language there are two ways a parameter can be passed to a function.
They are

o Call by value
o Call by reference

Call by Value:
 This method copies the value of the actual parameter to the formal parameter of the
function.
 Here, the changes of the formal parameters cannot affect the actual parameters,
because formal parameter are photocopies of the actual parameter.
 The changes made in formal arguments are local to the block of the called function.
Once control returns back to the calling function the changes made disappears.

Example Program
#include<stdio.h>
#include<conio.h>
void cube(int);
int cube1(int);
void main() Output:

{ Enter one values 3


Value of cube function is 3
int a; Value of cube1 function is 27
clrscr();
printf(“Enter one values”);
scanf(“%d”,&a);
printf(“Value of cube function is=%d”, cube(a));
printf(“Value of cube1 function is =%d”, cube1(a ));
getch();
}
void cube(int x)
{
x=x*x*x;
return x;
}
int cube1(int x)
{
x=x*x*x;
return x;
}

Call by reference
 Call by reference is another way of passing parameter to the function.
 Here the address of the argument is copied into the parameter inside the function, the
address is used to access arguments used in the call.
 Hence, changes made in the arguments are permanent.
 Here pointer is passed to function, just like any other arguments.
Example Program
#include<stdio.h>
#include<conio.h>
void swap(int,int);
Output:
void main() Before swapping a=5 b=10
After swapping a=10 b=5
{
int a=5,b=10;
clrscr();
printf(“Before swapping a=%d b=%d”,a,b);
swap(&a,&b);
printf(“After swapping a=%d b=%d”,a,b);
getch();
}
void swap(int *x,int *y)
{
int *t;
t=*x;
*x=*y;
*y=t;
}

Nesting of function call in c programming

If we are calling any function inside another function call, then it is known as Nesting
function call. In other words, a function calling different functions inside is termed as Nesting
Functions.

Example:
// C program to find the factorial of a number.

#include <stdio.h>

//Nesting of functions
//calling function inside another function
//calling fact inside print_fact_table
function

void print_fact_table(int); // function declaration

int fact(int); // function declaration

void main() // main function


{
print_fact_table(5); // function call
}

void print_fact_table(int n) // function definition


{
int i;
for (i=1;i<=n;i++)
printf("%d factorial is %d\n",i,fact(i)); //fact(i)-- function call
}

int fact(int n) // function definition


{
if (n == 1)
return 1;
else
return n * fact(n-1);
}

Output:
1 factorial is 1
2 factorial is 2
3 factorial is 6
4 factorial is 24
5 factorial is 120

Recursion

A function calling same function inside itself is called as recursion.

Example: // C program to find the factorial of a number.

#include <stdio.h>
int fact(int); // function declaration
void main() // main function
{
printf("Factorial =%d",fact(5)); // fact(5) is the function call
}
int fact(int n) // function definition
{
if (n==1) return 1; else
return n * fact(n-1); // fact(n-1) is the recursive function call
}

Output:
Factorial = 120

Discussion:
For 1! , the functions returns 1, for other values, it executes like the one below:
When the value is 5, it comes to else part and calculates like this,
= 5 * fact (5-1) = 5 * fact (4)

= 5* 4* fact (4-1) = 5 * 4* fact (3)

= 5* 4* 3* fact (3-1) = 5 * 4* 3* fact (2)

= 5* 4* 3* 2* fact (2-1) = 5 * 4* 3* 2* fact (1)

= 5* 4* 3* 2* 1 (if (n==1) then return 1, hence we get 1)

=120

Example :

// A program that contains both nested functions and recursion in it.


// Find the maximum number among five different integers using nested function call
and recursion.

int max(int x,int y) // function defintion


{
return x>y ? x:y; // condition operator is used (exp1?exp2:exp3)
}

void main() // main function


{
int m;
m=max(max(4,max(11,6)),max(10,5)); //nested, recursive call
of function max
printf("%d",m);
getch();
}

Output: 11
QUESTIONS FOR PRACTICE
1. What would be the output of the following programs:

(a) main( )
{
int a = 300, b, c ; if ( a >= 400 )
b = 300 ; c = 200 ;
printf ( "\n%d %d", b, c ) ;
}

(b) main( )
{
int a = 500, b, c ; if ( a >= 400 )
b = 300 ; c = 200 ;
printf ( "\n%d %d", b, c ) ;
}

(c) main( )
{
int x = 10, y = 20 ; if ( x == y ) ;
printf ( "\n%d %d", x, y ) ;
}

(d) main( )
{
int x = 3, y = 5 ;
if ( x == 3 )
printf ( "\n%d", x ) ;
else
printf ( "\n%d", y ) ;
}

(e) main( )

{
int x = 3 ; float y = 3.0 ;
if ( x == y )
printf ( "\nx and y are equal" ) ;
else
printf ( "\nx and y are not equal" ) ;
}

(f) main( )
{
int x = 3, y, z ; y = x = 10 ;
z = x < 10 ;
printf ( "\nx = %d y = %d z = %d", x, y, z ) ;
}

(g) main( )
{
int k = 35 ;
printf ( "\n%d %d %d", k == 35, k = 50, k > 40 ) ;
}

(h) main( )
{
int i = 65 ; char j = ‘A’ ;
if ( i == j )
printf ( “C is WOW” ) ;
else
printf( "C is a headache" ) ;
}

(i) main( )
{
int a = 5, b, c ; b = a = 15 ;
c = a < 15 ;
printf ( "\na = %d b = %d c = %d", a, b, c ) ;
}

(j) main( )
{

int x = 15 ;
printf ( "\n%d %d %d", x != 15, x = 20, x < 30 ) ;
}

2. What is the output of this C code (when 1 is entered)?

#include <stdio.h> void main()


{
double ch;
printf("enter a value btw 1 to 2:");
scanf("%lf", &ch);
switch (ch)
{
case 1: printf("1"); break;
case 2: printf("2"); break;
}
}
a) Compile time error
b) 1
c) 2
d) Varies

3. What is the output of this C code (When 1 is entered)?

#include <stdio.h> void main()


{
int ch;
printf("enter a value btw 1 to 2:");
scanf("%d", &ch);
switch (ch, ch + 1)
{
case 1: printf("1\n"); break;
case 2: printf("2"); break;
}
}
a) 1
b) 2
c) 3
d) Run time error

4. Find the output for the following Program


main()
{
int a,b , c =
1000; a = 100;
b = 20;
go to lab;
c = -1000;
printf(“\n Dummy”);
lab: print(“\n C value is %d”,c);
}

5. C program to display all prime numbers between Two interval entered by user.
6. C program to reverse a given number.
7. Program to Check Whether Given Number is Perfect Or Not.
8. Program Even Number Pyramid in C

2 4
2 4 6
2 4 6 8

9. Print prime number Pyramid in C

3 5
7 11 13
17 19 23 29
31 37 41 43 47

10. Write a C program to find the summation of the following series :

a) 1+ 2 + 3 +......+ n.
2 2 2 2
b) 1 + 2 + 3 +.... + n .
11. The keyword used to transfer control from a function back to the calling
function is
a) Switch b) Return c) Goto
12. Write a program to Calculate the Power of a Number Using Recursion
13. How many times the program will print "Sathyabama University" ?
#include<stdio.h>
int main()
{
printf("\nSathyabma University");
main();
return 0;
}
a) Infinite times b) 32767 times c) Till stack overflows
14. What will be the output of the program?
#include<stdio.h>
int f1(int);
int main()
{
int k=35;
k = f1(k=f1(k=f1(k)));
printf("k=%d\n", k);
return 0;
}
int f1(int k)
{
k++;
return k;
}
15. Which of the following function declaration is illegal?
a) int 11bhk(int); b) int 11bh2k(int a);
c) int 22bhk2(int*, int []); d) All of the mentioned

16. Which function is not called in the following program?


#include <stdio.h>
void one()
{
printf("first");
}
void two()
{
one();
}
void three()
{
two();
}
void main()
{
void (*ptr)();
ptr = three;
ptr();
}
a) Function first b) Function second
c) Function third d) None of the mentioned
17. What will be the output of the program?
#include<stdio.h>
void fun(int*, int*);
int main()
{
int i=5, j=2;
fun(&i, &j);
printf("%d, %d", i, j);
return 0;
}
void fun(int *a, int *b)
{
*a = *a**b;
*b = *a**b;
}
FUNCTIONS
 A function as series of instructions or group of statements with one specific purpose.
 A function is a program segment that carries out some specific, well defined task.
 A function is a self contained block of code that performs a particular task.
4.1 Types of functions
 C functions can be classified into two types,
1. Library functions /pre defined functions /standard functions /built in functions
2. User defined functions
1. Library functions /pre defined functions /standard functions/Built in Functions
 These functions are defined in the library of C compiler which are used frequently in
the C program.
 These functions are written by designers of c compiler.
 C supports many built in functions like
 Mathematical functions
 String manipulation functions
 Input and output functions
 Memory management functions
 Error handling functions
 EXAMPLE:
 pow(x,y)-computes xy
 sqrt(x)-computes square root of x
 printf()- used to print the data on the screen
 scanf()-used to read the data from keyboard.
2. User Defined Functions
 The functions written by the programmer /user to do the specific tasks are called user
defined function(UDF’s).
 The user can construct their own functions to perform some specific task. This type of
functions created by the user is termed as User defined functions.
Elements of User Defined Function
The Three Elements of User Defined function structure consists of :
1. Function Definition
2. Function Declaration
3. Function call
1. Function Definition:
 A program Module written to achieve a specific task is called as function definition.
 Each function definition consists of two parts:
i. Function header
ii. Function body
General syntax of function definition

Function Definition Syntax Function Definition Example

Datatype functionname(parameters) void add()


{ {
declaration part; int sum,a,b;
executable part; printf(“enter a and b\n”);
return statement; scanf(“%d%d”,&a,&b);
sum=a+b;
printf(“sum is %d”,sum);
} }

i. Function header
Syntax
datatype functionname(parameters)
 It consists of three parts
a) Datatype:
 The data type can be int,float,char,double,void.
 This is the data type of the value that the function is expected to return to
calling function.
b) functionname:
 The name of the function.
 It should be a valid identifier.
c) parameters
 The parameters are list of variables enclosed within parenthesis.
 The list of variables should be separated by comma.

Ex: void add( int a, int b)


 In the above example the return type of the function is void
 the name of the function is add and
 The parameters are 'a' and 'b' of type integer.
ii. Function body
 The function body consists of the set of instructions enclosed between { and } .
 The function body consists of following three elements:
a) declaration part: variables used in function body.
b) executable part: set of Statements or instructions to do specific activity.
c) return : It is a keyword,it is used to return control back to calling function.
If a function is not returning value then statement is:
return;
If a function is returning value then statement is:
return value;

2. Function Declaration
 The process of declaring the function before they are used is called as function
declaration or function prototype.
 function declaration Consists of the data type of function, name of the function
and parameter list ending with semicolon.

Function Declaration Syntax


datatypefunctionname(type p1,type p2,………type pn);
Example
int add(int a, int b);
void add(int a, int b);

Note: The function declaration should end with a semicolon ;


3. Function Call:
 The method of calling a function to achieve a specific task is called as function
call.
 A function call is defined as function name followed by semicolon.
 A function call is nothing but invoking a function at the required place in the
program to achieve a specific task.
Ex:
void main()
{
add( ); // function call without parameter
}

Formal Parameters and Actual Parameters


 Formal Parameters:
 The variables defined in the function header of function definition are called
formal parameters.
 All the variables should be separately declared and each declaration must be
separated by commas.
 The formal parameters receive the data from actual parameters.
 Actual Parameters:
 The variables that are used when a function is invoked)in function call) are called
actual parameters.
 Using actual parameters, the data can be transferred from calling function.
to the called function.
 The corresponding formal parameters in the function definition receive them.
 The actual parameters and formal parameters must match in number and type of
data.
Actual Parameters Formal Parameters

Actual parameters are also called as Formal parameters are also


argument list. called as dummy parameters.
Ex: add(m,n) Ex:int add(int a, int b)
The variables used in function call are The variables defined in function
called as actual parameters header are called formal
parameters
Actual parameters are used in calling Formal parameters are used in
function when a function is called or the function header of a called
invoked function.
Ex: add(m,n) Example:
Here, m and n are called actual int add(int a, int b)
parameters { ………..
}
Here, a and b are called formal
parameters.
Actual parameters sends data to the Formal parameters receive data
formal parameters from the actual parameters.
Example:

 Differences between Actual and Formal Parameters

4.2 Categories of the functions

1. Function with no parameters and no return values


2. Function with no parameters and return values.
3. Function with parameters and no return values
4. Function with parameters and return values

1. Function with no parameters and no return values


1. Function with no parameters and no return values
(void function without parameter)
Calling function Called function

/*program to find sum of two numbers


using function*/
#include<stdio.h> void add ( )
void add( ); {
void main() int sum;
{ printf(“enter a and b values\n”);
add( ); scanf(“%d%d”,&a,&b);
} sum=a+b;
printf(“\n The sum is %d”, sum);
return;
}

 In this category no data is transferred from calling function to called function,


hence called function cannot receive any values.
 In the above example,no arguments are passed to user defined function add( ).
 Hence no parameter are defined in function header.
 When the control is transferred from calling function to called function a ,and b
values are read,they are added,the result is printed on monitor.
 When return statement is executed ,control is transferred from called function/add
to calling function/main.
2. Function with parameters and no return values
(void function with parameter)
Calling function Called function

/*program to find sum of two numbers


using function*/
#include<stdio.h>
void add(int m, int n);
void main() void add(int a, int b)
{ {
int m,n; int sum;
printf(“enter values for m and n:”); sum = a+b;
scanf(“%d %d”,&m,&n); printf(“sum is:%d”,sum);
add(m,n); return;
} }

 In this category, there is data transfer from the calling function to the called
function using parameters.
 But there is no data transfer from called function to the calling function.
 The values of actual parameters m and n are copied into formal parameters a and b.
 The value of a and b are added and result stored in sum is displayed on the screen
in called function itself.
3. Function with no parameters and with return values
Calling function Called function

/*program to find sum of two numbers


using function*/
#include<stdio.h> int add( ) /* function header */

int add();
{
void main()
{ int a,b,sum;

int result; printf(“enter values for a and

result=add( ); b:”);

printf(“sum is:%d”,result); scanf(“%d %d”,&a,&b);

} sum= a+b;
return sum;
}

 In this category there is no data transfer from the calling function to the
called function.
 But, there is data transfer from called function to the calling function.
 No arguments are passed to the function add( ). So, no parameters are defined in
the function header
 When the function returns a value, the calling function receives one value from
the called function and assigns to variable result.
 The result value is printed in calling function.
4. Function with parameters and with return values
Calling function Called function

/*program to find sum of two numbers


using function*/
#include<stdio.h>
int add();
int add(int a, int b) /* function header */
void main()
{ {

int result,m,n; int sum;


printf(“enter values for m and sum= a+b;
n:”); return sum;
scanf(“%d %d”,&m,&n); }
result=add(m,n);
printf(“sum is:%d”,result);
}

 In this category, there is data transfer between the calling function and called
function.
 When Actual parameters values are passed, the formal parameters in called
function can receive the values from the calling function.
 When the add function returns a value, the calling function receives a value from
the called function.
 The values of actual parameters m and n are copied into formal parameters a and
b.
 Sum is computed and returned back to calling function which is assigned to
variable result.
4.3 Passing parameters to functions or Types of argument passing
The different ways of passing parameters to the function are:
 Pass by value or Call by value
 Pass by address or Call by address
C Programming and Problem Solving-18CPS23 Module 4

1. Call by value:
 In call by value, the values of actual parameters are copied into formal parameters.
 The formal parameters contain only a copy of the actual parameters.
 So, even if the values of the formal parameters changes in the called function, the
values of the actual parameters are not changed.
 The concept of call by value can be explained by considering the following program.
Example:
#include<stdio.h>
void swap(int a,int b);
void main()
{
int m,n;
printf("enter values for a and b:");
scanf("%d %d",&m,&n);
printf("the values before swapping are m=%d n=%d \n",m,n);
swap(m,n);
printf("the values after swapping are m=%d n=%d \n",m,n);
}

void swap(int a, int b)


{
int temp;
temp=a;
a=b;
b=temp;
}

 Execution starts from function main( ) and we will read the values for variables
m and n, assume we are reading 10 and 20 respectively.
 We will print the values before swapping it will print 10 and 20.
 The function swap( ) is called with actual parameters m=10 and n=20.
 In the function header of function swap( ), the formal parameters a and b
receive the values 10 and 20.
 In the function swap( ), the values of a and b are exchanged.

Dr. Jyoti Metan Dept of CSE,ACSCE 10


C Programming and Problem Solving-18CPS23 Module 4

 But, the values of actual parameters m and n in function main( ) have not been
exchanged.
 The change is not reflected back to calling function.

2. Call by Address
 In Call by Address, when a function is called, the addresses of actual
parameters are sent.
 In the called function, the formal parameters should be declared as pointers
with the same type as the actual parameters.
 The addresses of actual parameters are copied into formal parameters.
 Using these addresses the values of the actual parameters can be changed.
 This way of changing the actual parameters indirectly using the addresses of
actual parameters is known as pass by address.
Example:
#include<stdio.h>
void swap(int a,int b);
void main()
{
int m,n;
printf("enter values for a and b:");
scanf("%d %d",&m,&n);
printf("the values before swapping are m=%d n=%d \n",m,n);
swap(&m,&n);
printf("the values after swapping are m=%d n=%d \n",m,n);
}

void swap(int*a, int*b)


{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
NOTE:

Dr. Jyoti Metan Dept of CSE,ACSCE 11


C Programming and Problem Solving-18CPS23 Module 4

Pointer: A pointer is a variable that is used to store the address of another variable.
Syntax: datatype *variablename;
Example: int *p;
#include<stdio.h>
void main()
{
inta ,*p;
p=&a;
}
In the above program p is a pointer variable, which is storing the address of variable a.

Differences between Call by Value and Call by reference

Call by Value Call by Address


When a function is called the values When a function is called the addresses of
of variables are passed variables are passed

The type of formal parameters should The type of formal parameters should be
be same as type of actual parameters same as type of actual parameters, but
they have to be declared as pointers.

Formal parameters contains the Formal parameters contain the addresses


values of actual parameters of actual parameters.

Scope and Life time of a variable


Scope of a variable is defined as the region or boundary of the program in which
the variable is visible. There are two types
(i) Global Scope
(ii) Local Scope
i. Global Scope:
 The variables that are defined outside a block have global scope.
 That is any variable defined in global area of a program is visible from its
definition until the end of the program.
 For Example, the variables declared before all the functions are visible
everywhere in the program and they have global scope.

Dr. Jyoti Metan Dept of CSE,ACSCE 12


Programming in C and Data Structures Module 3

ii. Local Scope


a. The variables that are defined inside a block have local scope.
b. They exist only from thepoint of their declaration until the end of the block.
c. They are not visible outside the block.
 Life Span of a variable
 The life span of a variable is defined as the period during which a variable is
active during execution of a program.
For Example
 The life span of a global variable is the life span of the program.
 The life span of local variables is the life span of the function, they are created.
 Storage Classes
 There are following storage classes which can be used in a C Program:
i. Global variables
ii. Local variables
iii. Static variables
iv. Register variables
i. Global variables:
 These are the variables which are defined before all functions in global area of
the program.
 Memory is allocated only once to these variables and initialized to zero.
 These variables can be accessed by any function and are alive and active
throughout the program.
 Memory is deallocated when program execution is over.
e.g
#include<stdio.h>
int x;
main()
{
x=10;
printf(“%d”,x);
printf(“x=%d”,fun1());
printf(“x=%d”,fun2());
printf(“x=%d”,fun3());
}
ii. Local variables(automatic variables)

Dr. Jyoti Metan Dept of CSE,ACSCE Page 13


Programming in C and Data Structures Module 3

 These are the variables which are defined within a functions.


 These variables are also called as automatic variables.
 The scope of these variables are limited only to the function in which they are
declared and cannot be accessed outside the function.

 e.g
#include<stdio.h>
main()
{
int m=1000;
func2();
printf(“%d\n”,m);
}
func1()
{
int m=10;
printf(“%d\n”,m);
}

iii. Static variables


 The variables that are declared using the keyword static are called static
variables.

 The static variables can be declared outside the function and inside the function.
They have the characteristics of both local and global variables.
 Static can also be defined within a function.
Ex: static int a,b;
#include<stdio.h>
main()
{
int I;
for (I=1;I<=3;I++)
stat();
}
stat()
{
static int x=0;
x=x+1;
printf(“x=%d\n”,x);
}
iv. Register variables

Dr. Jyoti Metan Dept of CSE,ACSCE Page 14


Programming in C and Data Structures Module 3

 Any variables declared with the qualifier register is called a register variable.
 This declaration instructs the compiler that the variable under use is to be stored
in one of the registers but not in main memory.
 Register access is much faster compared to memory access. Ex:
register int a;

Recursion

 Recursion is a method of solving the problem where the solution to a problem depends
on solutions to smaller instances of the same problem.
 Recursive function is a function that calls itself during the execution.
 Consider Example for finding factrorial of 5

Factorial(5)=n*fact(n-1)

Example 1.
/******* Factorial of a given number using Recursion ******/
#include<stdio.h>
int fact(int n);

void main( )
{
int num,result;
printf("enter number:");
scanf("%d",&num);
result=fact(num);
printf("The factorial of a number is: %d",result);
}

int fact(int n)
{
if(n==0)
return 1;
else
return (n*fact(n-1));

Dr. Jyoti Metan Dept of CSE,ACSCE Page 15


Programming in C and Data Structures Module 3

}
output :
enter number:5
The factorial of a number is:120

Fibonacci Sequence:

The Fibonacci Sequence is the series of numbers:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...


The next number is found by adding up the two numbers before it.
 The 2 is found by adding the two numbers before it (1+1)
 The 3 is found by adding the two numbers before it (1+2),
 And the 5 is (2+3),
 and so on!
Example 2.
/******* Factorial of a given number using Recursion ******/
#include<stdio.h>
int fibonacci(int);
void main ()
{
int n,f;
printf("Enter the value of n?");
scanf("%d",&n);
f = fibonacci(n);
printf("%d",f);
}
int fibonacci (int n)
{
if (n==0)
{
return 0;
}
else if (n == 1)
{
return 1;
}
else
{
return fibonacci(n-1)+fibonacci(n-2);
}
}

Dr. Jyoti Metan Dept of CSE,ACSCE Page 16


UNIT-III ARRAYS AND STRINGS

Contents

Single and Multidimensional Arrays: Array Declaration and Initialization of arrays – Arrays as
function arguments. Strings: Initialization and String handling functions. Structure and Union:
Definition and Declaration - Nested Structures, Array of Structures, Structure as function
arguments, Function that return structure – Union.

ARRAYS
Introduction:
So far we have used only single variable name for storing one data item. If we need to store
multiple copies of the same data then it is very difficult for the user. To overcome the difficulty a
new data structure is used called arrays.
An array is a linear and homogeneous data structure
An array permits homogeneous data. It means that similar types of elements are stored
contiguously in the memory under one variable name.
An array can be declared of any standard or custom data type.
Example of an Array:
Suppose we have to store the roll numbers of the 100 students the we have to declare 100
variables named as roll1, roll2, roll3, ……. roll100 which is very difficult job. Concept of C
programming arrays is introduced in C which gives the capability to store the 100 roll numbers
in the contiguous memory which has 100 blocks and which can be accessed by single variable
name.
1. C Programming Arrays is the Collection of Elements
2. C Programming Arrays is collection of the Elements of the same data type.
3. All Elements are stored in the Contiguous memory
4. All elements in the array are accessed using the subscript variable (index).
Pictorial representation of C Programming Arrays

The above array is declared as int a [5];


a[0] = 4; a[1] = 5; a[2] = 33; a[3] = 13; a[4] = 1;
In the above figure 4, 5, 33, 13, 1 are actual data items. 0, 1, 2, 3, 4 are index variables.
Index or Subscript Variable:
1. Individual data items can be accessed by the name of the array and an integer enclosed
in square bracket called subscript variable / index
2. Subscript Variables helps us to identify the item number to be accessed in the contiguous
memory.
What is Contiguous Memory?
1. When Big Block of memory is reserved or allocated then that memory block is called as
Contiguous Memory Block.
2. Alternate meaning of Contiguous Memory is continuous memory.
3. Suppose inside memory we have reserved 1000-1200 memory addresses for special
purposes then we can say that these 200 blocks are going to reserve contiguous memory.
Contiguous Memory Allocation
1. Two registers are used while implementing the contiguous memory scheme. These
registers are base register and limit register.
2. When OS is executing a process inside the main memory then content of each register
are as

Register Content of register

Base register Starting address of the memory location where


process execution is happening

Limit register Total amount of memory in bytes consumed by


process

Here diagram 1 represents the contiguous allocation of memory and diagram 2 represents non-
contiguous allocation of memory.
3. When process try to refer a part of the memory then it will firstly refer the base address
from base register and then it will refer relative address of memory location with respect to
base address.
How to allocate contiguous memory?
1. Using static array declaration.
2. Using alloc ( ) / malloc ( ) function to allocate big chunk of memory dynamically.
Array Terminologies:
Size: Number of elements or capacity to store elements in an array. It is always mentioned in
square brackets [ ].
Type: Refers to data type. It decides which type of element is stored in the array. It is also
instructing the compiler to reserve memory according to the data type.
Base: The address of the first element is a base address. The array name itself stores address
of the first element.
Index: The array name is used to refer to the array element. For example num[x], num is array
and x is index. The value of x begins from [Link] index value is always an integer value.
Range: Value of index of an array varies from lower bound to upper bound. For example in
num[100] the range of index is 0 to 99.
Word: It indicates the space required for an element. In each memory location, computer can
store a data piece. The space occupation varies from machine to machine. If the size of element
is more than word (one byte) then it occupies two successive memory locations. The variables
of data type int, float, long need more than one byte in memory.
Characteristics of an array:
1. The declaration int a [5] is nothing but creation of five variables of integer types in
memory instead of declaring five variables for five values.
2. All the elements of an array share the same name and they are distinguished from one
another with the help of the element number.
3. The element number in an array plays a major role for calling each element.
4. Any particular element of an array can be modified separately without disturbing the
other elements.
5. Any element of an array a[ ] can be assigned or equated to another ordinary variable or
array variable of its type.
6. Array elements are stored in contiguous memory locations.
Array Declaration:
Array has to be declared before using it in C Program. Array is nothing but the collection of
elements of similar data types.
Syntax: <data type> array name [size1][size2].....[sizen];

Syntax Parameter Significance

Data type Data Type of Each Element of the array

Array name Valid variable name


Size Dimensions of the Array
Array declaration requirements
Requirement Explanation
Data Type specifies the type of the array. We can compute the size
Data Type
required for storing the single cell of array.

Valid identifier is any valid variable or name given to the array.


Valid Identifier
Using this identifier name array can be accessed.

Size of Array It is maximum size that array can have.


What does Array Declaration tell to Compiler?
1. Type of the Array
2. Name of the Array
3. Number of Dimension
4. Number of Elements in Each Dimension

Types of Array
1. Single Dimensional Array / One Dimensional Array
2. Multi Dimensional Array

Single / One Dimensional Array:


1. Single or One Dimensional array is used to represent and store data in a linear form.
2. Array having only one subscript variable is called One-Dimensional array
3. It is also called as Single Dimensional Array or Linear Array
Single Dimensional Array Declaration and initialization:
Syntax for declaration: <data type> <array name> [size];
Examples for declaration: int iarr[3]; char carr[20]; float farr[3];
Syntax for initialization: <data type> <array name> [size] = {val1, val2, …, valn};
Examples for initialization:
int iarr[3] = {2, 3, 4};
char carr[20] = “program”;
float farr[3] = {12.5, 13.5, 14.5};
Different Methods of Initializing 1-D Array
Whenever we declare an array, we initialize that array directly at compile time.
Initializing 1-D Array is called as compiler time initialization if and only if we assign certain set of
values to array element before executing program. i.e. at compilation time.

Here we are learning the different ways of compile time initialization of an array.
Ways of Array Initializing 1-D Array:
1. Size is Specified Directly
2. Size is Specified Indirectly
Method 1: Array Size Specified Directly
In this method, we try to specify the Array Size directly.
int num [5] = {2,8,7,6,0};
In the above example we have specified the size of array as 5 directly in the initialization
statement. Compiler will assign the set of values to particular element of the array.
num[0] = 2; num[1] = 8; num[2] = 7; num[3] = 6; num[4] = 0;
As at the time of compilation all the elements are at specified position So This initialization
scheme is Called as “Compile Time Initialization“.
Graphical Representation:

Method 2: Size Specified Indirectly


In this scheme of compile time Initialization, We do not provide size to an array but instead we
provide set of values to the array.
int num[ ] = {2,8,7,6,0};
Explanation:
1. Compiler Counts the Number Of Elements Written Inside Pair of Braces and Determines
the Size of An Array.
2. After counting the number of elements inside the braces, The size of array is considered
as 5 during complete execution.
3. This type of Initialization Scheme is also Called as “Compile Time Initialization“
Example Program
#include <stdio.h>
int main()
int num[] = {2,8,7,6,0};
int i;
for (i=0;i<5;i++) {
printf(“\n Array Element num [%d] = %d”,i, num[i]); }
return 0; }
Output:
Array Element num[0] = 2
Array Element num[1] = 8
Array Element num[2] = 7
Array Element num[3] = 6
Array Element num[4] = 0

Accessing Array
1. We all know that array elements are randomly accessed using the subscript variable.
2. Array can be accessed using array-name and subscript variable written inside pair of
square brackets [ ].
Consider the below example of an array

In this example we will be accessing array like this


arr[3] = Forth Element of Array
arr[5] = Sixth Element of Array
whereas elements are assigned to an array using below way
arr[0] = 51; arr[1] = 32; arr[2] = 43; arr[3] = 24; arr[4] = 5; arr[5] =26;
Example Program1: Accessing array
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[] = {51,32,43,24,5,26};
int i;
for(i=0; i<=5; i++) {
printf("\nElement at arr[%d] is %d",i,arr[i]);
}
getch();
}
Output:
Element at arr[0] is 51
Element at arr[1] is 32
Element at arr[2] is 43
Element at arr[3] is 24
Element at arr[4] is 5
Element at arr[5] is 26
How a[i] Works?
We have following array which is declared like int arr[] = { 51,32,43,24,5,26};
As we have elements in an array, so we have track of base address of an array. Below things
are important to access an array.

Expression Description Example

arr It returns the base address of an array Consider 2000

*arr It gives zeroth element of an array 51


Expression Description Example

*(arr+0) It also gives zeroth element of an array 51

*(arr+1) It gives first element of an array 32

So whenever we tried accessing array using arr[i] then it returns an element at the location*(arr
+ i)
Accessing array a[i] means retrieving element from address (a + i).
Example Program2: Accessing array
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[] = {51,32,43,24,5,26};
int i;
for(i=0; i<=5; i++) {
printf("\n%d %d %d %d",arr[i],*(i+arr),*(arr+i),i[arr]);
}
getch();
}
Output:
51 51 51 51
32 32 32 32
43 43 43 43
24 24 24 24
5 5 5 5
26 26 26 26
Operations with One Dimensional Array
1. Deletion – Involves deleting specified elements form an array.
2. Insertion – Used to insert an element at a specified position in an array.
3. Searching – An array element can be searched. The process of seeking specific
elements in an array is called searching.
4. Merging – The elements of two arrays are merged into a single one.
5. Sorting – Arranging elements in a specific order either in ascending or in descending
order.
Example Programs:
1. C Program for deletion of an element from the specified location
from an Array
#include<stdio.h>
int main() {
int arr[30], num, i, loc;
printf("\nEnter no of elements:");
scanf("%d", &num);
//Read elements in an array
printf("\nEnter %d elements :", num);
for (i = 0; i < num; i++) {
scanf("%d", &arr[i]); }
//Read the location
printf("\nLocation of the element to be deleted :");
scanf("%d", &loc);
/* loop for the deletion */
while (loc < num) {
arr[loc - 1] = arr[loc];
loc++; }
num--; // No of elements reduced by 1
//Print Array
for (i = 0; i < num; i++)
printf("\n %d", arr[i]);
return (0);
}
Output:
Enter no of elements: 5
Enter 5 elements: 3 4 1 7 8
Location of the element to be deleted: 3
3 4 7 8
2. C Program to delete duplicate elements from an array
int main() {
int arr[20], i, j, k, size;
printf("\nEnter array size: ");
scanf("%d", &size);
printf("\nAccept Numbers: ");
for (i = 0; i < size; i++)
scanf("%d", &arr[i]);
printf("\nArray with Unique list: ");
for (i = 0; i < size; i++) {
for (j = i + 1; j < size;) {
if (arr[j] == arr[i]) {
for (k = j; k < size; k++) {
arr[k] = arr[k + 1]; }
size--; }
else
j++; }
}
for (i = 0; i < size; i++) {
printf("%d ", arr[i]); }
return (0);
}
Output:
Enter array size: 5
Accept Numbers: 1 3 4 5 3
Array with Unique list: 1 3 4 5
3. C Program to insert an element in an array
#include<stdio.h>
int main() {
int arr[30], element, num, i, location;
printf("\nEnter no of elements:");
scanf("%d", &num);
for (i = 0; i < num; i++) {
scanf("%d", &arr[i]); }
printf("\nEnter the element to be inserted:");
scanf("%d", &element);
printf("\nEnter the location");
scanf("%d", &location);
//Create space at the specified location
for (i = num; i >= location; i--) {
arr[i] = arr[i - 1]; }
num++;
arr[location - 1] = element;
//Print out the result of insertion
for (i = 0; i < num; i++)
printf("n %d", arr[i]);
return (0);
}
Output:
Enter no of elements: 5
1 2 3 4 5
Enter the element to be inserted: 6
Enter the location: 2
1 6 2 3 4 5
4. C Program to search an element in an array
#include<stdio.h>
int main() {
int a[30], ele, num, i;
printf("\nEnter no of elements:");
scanf("%d", &num);
printf("\nEnter the values :");
for (i = 0; i < num; i++) {
scanf("%d", &a[i]); }
//Read the element to be searched
printf("\nEnter the elements to be searched :");
scanf("%d", &ele);
//Search starts from the zeroth location
i = 0;
while (i < num && ele != a[i]) {
i++; }
//If i < num then Match found
if (i < num) {
printf("Number found at the location = %d", i + 1);
}
else {
printf("Number not found"); }
return (0);
}
Output:
Enter no of elements: 5
11 22 33 44 55
Enter the elements to be searched: 44
Number found at the location = 4
5. C Program to copy all elements of an array into another array
#include<stdio.h>
int main() {
int arr1[30], arr2[30], i, num;
printf("\nEnter no of elements:");
scanf("%d", &num);
//Accepting values into Array
printf("\nEnter the values:");
for (i = 0; i < num; i++) {
scanf("%d", &arr1[i]); }
/* Copying data from array 'a' to array 'b */
for (i = 0; i < num; i++) {
arr2[i] = arr1[i]; }
//Printing of all elements of array
printf("The copied array is:");
for (i = 0; i < num; i++)
printf("\narr2[%d] = %d", i, arr2[i]);
return (0);
}
Output:
Enter no of elements: 5
Enter the values: 11 22 33 44 55
The copied array is: 11 22 33 44 55
6. C program to merge two arrays in C Programming
#include<stdio.h>
int main() {
int arr1[30], arr2[30], res[60];
int i, j, k, n1, n2;
printf("\nEnter no of elements in 1st array:");
scanf("%d", &n1);
for (i = 0; i < n1; i++) {
scanf("%d", &arr1[i]); }
printf("\nEnter no of elements in 2nd array:");
scanf("%d", &n2);
for (i = 0; i < n2; i++) {
scanf("%d", &arr2[i]); }
i = 0;
j = 0;
k = 0;
// Merging starts
while (i < n1 && j < n2) {
if (arr1[i] <= arr2[j]) {
res[k] = arr1[i];
i++;
k++; }
else {
res[k] = arr2[j];
k++;
j++; }
}
/*Some elements in array 'arr1' are still remaining where as the array
'arr2' is exhausted*/
while (i < n1) {
res[k] = arr1[i];
i++;
k++; }
/*Some elements in array 'arr2' are still remaining where as the array
'arr1' is exhausted */
while (j < n2) {
res[k] = arr2[j];
k++;
j++; }
//Displaying elements of array 'res'
printf("\nMerged array is:");
for (i = 0; i < n1 + n2; i++)
printf("%d ", res[i]);
return (0);
}
Enter no of elements in 1st array: 4
11 22 33 44
Enter no of elements in 2nd array: 3
10 40 80
Merged array is: 10 11 22 33 40 44 80

Programs for Practice


1 C Program to display array elements with addresses
2 C Program for Reading and printing Array Elements
3 C Program to calculate Addition of All Elements in Array
4 C Program to find Smallest Element in Array
5 C Program to find Largest Element in Array
6 C Program to reversing an Array Elements

1. C Program to display array elements with addresses


#include<stdio.h>
#include<stdlib.h>
#define size 10
int main() {
int a[3] = { 11, 22, 33 };
printf("\n a[0],value=%d : address=%u", a[0], &a[0]);
printf("\n a[1],value=%d : address=%u", a[1], &a[1]);
printf("\n a[2],value=%d : address=%u", a[2], &a[2]);
return (0);
}
Output:
a[0],value=11 : address=2358832
a[1],value=22 : address=2358836
a[2],value=33 : address=2358840
2. C Program for Reading and printing Array Elements
#include<stdio.h>
int main()
{
int i, arr[50], num;
printf("\nEnter no of elements :");
scanf("%d", &num);
//Reading values into Array
printf("\nEnter the values :");
for (i = 0; i < num; i++) {
scanf("%d", &arr[i]); }
//Printing of all elements of array
for (i = 0; i < num; i++) {
printf("\narr[%d] = %d", i, arr[i]); }
return (0);
}
Output:
Enter no of elements : 5
Enter the values : 10 20 30 40 50
arr[0] = 10
arr[1] = 20
arr[2] = 30
arr[3] = 40
arr[4] = 50
3. C Program to calculate addition of all elements in an array
#include<stdio.h>
int main() {
int i, arr[50], sum, num;
printf("\nEnter no of elements :");
scanf("%d", &num);
//Reading values into Array
printf("\nEnter the values :");
for (i = 0; i < num; i++)
scanf("%d", &arr[i]);
//Computation of total
sum = 0;
for (i = 0; i < num; i++)
sum = sum + arr[i];
//Printing of all elements of array
for (i = 0; i < num; i++)
printf("\na[%d]=%d", i, arr[i]);
//Printing of total
printf("\nSum=%d", sum);
return (0);
}
Output:
Enter no of elements : 3
Enter the values : 11 22 33
a[0]=11
a[1]=22
a[2]=33
Sum=66
4. C Program to find smallest element in an array
#include<stdio.h>
int main() {
int a[30], i, num, smallest;
printf("\nEnter no of elements :");
scanf("%d", &num);
//Read n elements in an array
for (i = 0; i < num; i++)
scanf("%d", &a[i]);
//Consider first element as smallest
smallest = a[0];
for (i = 0; i < num; i++) {
if (a[i] < smallest) {
smallest = a[i]; } }
// Print out the Result
printf("\nSmallest Element : %d", smallest);
return (0);
}
Output:
Enter no of elements : 5
11 44 22 55 99
Smallest Element : 11
5. C Program to find largest element in an array
#include<stdio.h>
int main() {
int a[30], i, num, largest;
printf("\nEnter no of elements :");
scanf("%d", &num);
//Read n elements in an array
for (i = 0; i < num; i++)
scanf("%d", &a[i]);
//Consider first element as largest
largest = a[0];
for (i = 0; i < num; i++) {
if (a[i] > largest) {
largest = a[i]; } }
// Print out the Result
printf("\nLargest Element : %d", largest);
return (0);
}
Output:
Enter no of elements : 5
11 55 33 77 22
Largest Element : 77
6. C Program to reverse an array elements in an array
#include<stdio.h>
int main() {
int arr[30], i, j, num, temp;
printf("\nEnter no of elements : ");
scanf("%d", &num);
//Read elements in an array
for (i = 0; i < num; i++) {
scanf("%d", &arr[i]); }
j = i - 1; // j will Point to last Element
i = 0; // i will be pointing to first element
while (i < j) {
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++; // increment i
j--; // decrement j
}
//Print out the Result of Insertion
printf("\nResult after reversal : ");
for (i = 0; i < num; i++) {
printf("%d \t", arr[i]); }
return (0);
}
Output:
Enter no of elements : 5
11 22 33 44 55
Result after reversal : 55 44 33 22 11

Multi Dimensional Array:


1. Array having more than one subscript variable is called Multi-Dimensional array.
2. Multi Dimensional Array is also called as Matrix.
Syntax: <data type> <array name> [row subscript][column subscript];

Example: Two Dimensional Arrays


Declaration: Char name[50][20];
Initialization:
int a[3][3] = { 1, 2, 3
5, 6, 7
8, 9, 0};
In the above example we are declaring 2D array which has 2 dimensions. First dimension will
refer the row and 2nd dimension will refer the column.
Example: Three Dimensional Arrays
Declaration: Char name[80][20][40];
The following information are given by the compiler after the declaration

Array Dimension No. of Elements in


Example Type
Name No. Each Dimension

1 integer roll 1 10

2 character name 2 80 and 20

3 character name 3 80 and 20 and 40

Two Dimensional Arrays:


1. Two Dimensional Array requires Two Subscript Variables
2. Two Dimensional Array stores the values in the form of matrix.
3. One Subscript Variable denotes the “Row” of a matrix.
4. Another Subscript Variable denotes the “Column” of a matrix.

Declaration and use of 2D Arrays:


int a[3][4];
for(i=0;i<row,i++)
for(j=0;j<col,j++) {
printf("%d",a[i][j]); }
Meaning of Two Dimensional Arrays:
1. Matrix is having 3 rows ( i takes value from 0 to 2 )
2. Matrix is having 4 Columns ( j takes value from 0 to 3 )
3. Above Matrix 3×4 matrix will have 12 blocks having 3 rows & 4 columns.
4. Name of 2-D array is „a„ and each block is identified by the row & column number.
5. Row number and Column Number Starts from 0.
Two-Dimensional Arrays: Summary with Sample Example:

Summary Point Explanation

No of Subscript Variables Required 2

Declaration a[3][4]

No of Rows 3

No of Columns 4

No of Cells 12

No of for loops required to iterate 2

Memory Representation:
1. 2-D arrays are stored in contiguous memory location row wise.
2. 3 X 3 Array is shown below in the first Diagram.
3. Consider 3×3 Array is stored in Contiguous memory location which starts from 4000.
4. Array element a[0][0] will be stored at address 4000 again a[0][1] will be stored to next
memory location i.e. Elements stored row-wise
5. After Elements of First Row are stored in appropriate memory locations, elements of
next row get their corresponding memory locations.
6. This is integer array so each element requires 2 bytes of memory.
Basic Memory Address Calculation:
a[0][1] = a[0][0] + Size of Data Type

Element Memory Location

a[0][0] 4000

a[0][1] 4002

a[0][2] 4004

a[1][0] 4006

a[1][1] 4008

a[1][2] 4010

a[2][0] 4012

a[2][1] 4014

a[2][2] 4016
Initializing 2D Array

Method 1: Initializing all Elements row wise


For initializing 2D Array we need to assign values to each element of an array using the below
syntax.
int a[3][2] = { {1, 4}, {5, 2}, {6, 5} };
Example Program
#include<stdio.h>
int main()
{
int i, j;
int a[3][2] = { { 1, 4 }, { 5, 2 }, { 6, 5 } };
for (i = 0; i < 3; i++) {
for (j = 0; j < 2; j++) {
printf("%d ", a[i][j]); }
printf("\n"); }
return 0;
}
Output:
1 4
5 2
6 5
We have declared an array of size 3 X 2, it contains overall 6
elements.
Row 1: {1, 4},
Row 2: {5, 2},
Row 3: {6, 5}
We have initialized each row independently
a[0][0] = 1
a[0][1] = 4
Method 2: Combine and Initializing 2D Array
Initialize all Array elements but initialization is much straight forward. All values are assigned
sequentially and row-wise
int a[3][2] = {1 , 4 , 5 , 2 , 6 , 5 };
Example Program:
#include <stdio.h>
int main() {
int i, j;
int a[3][2] = { 1, 4, 5, 2, 6, 5 };
for (i = 0; i < 3; i++) {
for (j = 0; j < 2; j++) {
printf("%d ", a[i][j]); }
printf("\n"); }
return 0;
}
Output:
1 4
5 2
6 5
Method 3: Some Elements could be initialized
int a[3][2] = { { 1 }, { 5 , 2 }, { 6 } };
Now we have again going with the way 1 but we are removing some of the elements from the
array. Uninitialized elements will get default 0 value. In this case we have declared and
initialized 2-D array like this
#include <stdio.h>
int main() {
int i, j;
int a[3][2] = { { 1 }, { 5, 2 }, { 6 }};
for (i = 0; i < 3; i++) {
for (j = 0; j < 2; j++) {
printf("%d ", a[i][j]); }
printf("\n"); }
return 0;
}
Output:
1 0
5 2
6 0
Accessing 2D Array Elements:
1. To access every 2D array we requires 2 Subscript variables.
2. i – Refers the Row number
3. j – Refers Column Number
4. a[1][0] refers element belonging to first row and zeroth column
Example Program: Accept & Print 2×2 Matrix from user
#include<stdio.h>
int main() {
int i, j, a[3][3];
// i : For Counting Rows
// j : For Counting Columns
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
printf("\nEnter the a[%d][%d] = ", i, j);
scanf("%d", &a[i][j]); } }
//Print array elements
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
printf("%d\t", a[i][j]); }
printf("\n"); }
return (0);
}
How it Works?
1. For Every value of row Subscript , the column Subscript incremented from 0 to n-1
columns
2. i.e. For Zeroth row it will accept zeroth, first, second column (a[0][0], a[0][1], a[0][2])
elements
3. In Next Iteration Row number will be incremented by 1 and the column number again
initialized to 0.
4. Accessing 2-D Array: a[i][j]  Element From ith Row and jth Column

Example programs for practice:


1. C Program for addition of two matrices
2. C Program to find inverse of 3 X # Matrix
3. C Program to Multiply two 3 X 3 Matrices
4. C Program to check whether matrix is magic square or not?

1. C Program for addition of two matrices


#include<stdio.h>
int main() {
int i, j, mat1[10][10], mat2[10][10], mat3[10][10];
int row1, col1, row2, col2;
printf("\nEnter the number of Rows of Mat1 : ");
scanf("%d", &row1);
printf("\nEnter the number of Cols of Mat1 : ");
scanf("%d", &col1);
printf("\nEnter the number of Rows of Mat2 : ");
scanf("%d", &row2);
printf("\nEnter the number of Columns of Mat2 : ");
scanf("%d", &col2);
/* before accepting the Elements Check if no of rows and columns of
both matrices is equal */
if (row1 != row2 || col1 != col2) {
printf("\nOrder of two matrices is not same ");
exit(0); }
//Accept the Elements in Matrix 1
for (i = 0; i < row1; i++) {
for (j = 0; j < col1; j++) {
printf("Enter the Element a[%d][%d] : ", i, j);
scanf("%d", &mat1[i][j]); } }
//Accept the Elements in Matrix 2
for (i = 0; i < row2; i++)
for (j = 0; j < col2; j++) {
printf("Enter the Element b[%d][%d] : ", i, j);
scanf("%d", &mat2[i][j]); }
//Addition of two matrices
for (i = 0; i < row1; i++)
for (j = 0; j < col1; j++) {
mat3[i][j] = mat1[i][j] + mat2[i][j];}
//Print out the Resultant Matrix
printf("\nThe Addition of two Matrices is : \n");
for (i = 0; i < row1; i++) {
for (j = 0; j < col1; j++) {
printf("%d\t", mat3[i][j]); }
printf("\n"); }
return (0);
}
Output:
Enter the number of Rows of Mat1 : 3
Enter the number of Columns of Mat1 : 3
Enter the number of Rows of Mat2 : 3
Enter the number of Columns of Mat2 : 3
Enter the Element a[0][0] : 1
Enter the Element a[0][1] : 2
Enter the Element a[0][2] : 3
Enter the Element a[1][0] : 2
Enter the Element a[1][1] : 1
Enter the Element a[1][2] : 1
Enter the Element a[2][0] : 1
Enter the Element a[2][1] : 2
Enter the Element a[2][2] : 1
Enter the Element b[0][0] : 1
Enter the Element b[0][1] : 2
Enter the Element b[0][2] : 3
Enter the Element b[1][0] : 2
Enter the Element b[1][1] : 1
Enter the Element b[1][2] : 1
Enter the Element b[2][0] : 1
Enter the Element b[2][1] : 2
Enter the Element b[2][2] : 1
The Addition of two Matrices is :
2 4 6
4 2 2
2 4 2
2. C Program to find inverse of 3 X 3 Matrix
#include<stdio.h>
void reduction(float a[][6], int size, int pivot, int col) {
int i, j;
float factor;
factor = a[pivot][col];
for (i = 0; i < 2 * size; i++) {
a[pivot][i] /= factor; }
for (i = 0; i < size; i++) {
if (i != pivot) {
factor = a[i][col];
for (j = 0; j < 2 * size; j++) {
a[i][j] = a[i][j] - a[pivot][j] * factor; } } } }
void main() {
float matrix[3][6];
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 6; j++) {
if (j == i + 3) {
matrix[i][j] = 1;}
else {
matrix[i][j] = 0; } } }
printf("\nEnter a 3 X 3 Matrix :");
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
scanf("%f", &matrix[i][j]); } }
for (i = 0; i < 3; i++) {
reduction(matrix, 3, i, i); }
printf("\nInverse Matrix");
for (i = 0; i < 3; i++) {
printf("\n");
for (j = 0; j < 3; j++) {
printf("%8.3f", matrix[i][j + 3]); } } }
Output:
Enter a 3 X 3 Matrix
1 3 1
1 1 2
2 3 4
Inverse Matrix
2.000 9.000 -5.000
0.000 -2.000 1.000
-1.000 -3.000 2.000
3. C Program to Multiply two 3 X 3 Matrices
#include<stdio.h>
int main() {
int a[10][10], b[10][10], c[10][10], i, j, k;
int sum = 0;
printf("\nEnter First Matrix : ");
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
scanf("%d", &a[i][j]); } }
printf("\nEnter Second Matrix :");
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
scanf("%d", &b[i][j]); } }
printf("The First Matrix is : \n");
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
printf(" %d ", a[i][j]); }
printf("\n"); }
printf("The Second Matrix is : \n");
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
printf(" %d ", b[i][j]); }
printf("\n"); }
//Multiplication Logic
for (i = 0; i <= 2; i++) {
for (j = 0; j <= 2; j++) {
sum = 0;
for (k = 0; k <= 2; k++) {
sum = sum + a[i][k] * b[k][j]; }
c[i][j] = sum; } }
printf("\nMultiplication Of Two Matrices : \n");
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
printf(" %d ", c[i][j]); }
printf("\n"); }
return (0);
}
Output:
Enter First Matrix :
1 1 1
1 1 1
1 1 1
Enter Second Matrix :
2 2 2
2 2 2
2 2 2
The First Matrix is :
1 1 1
1 1 1
1 1 1
The Second Matrix is :
2 2 2
2 2 2
2 2 2
Multiplication Of Two Matrices :
6 6 6
6 6 6
6 6 6
Multiplication is possible if and only if
i. No. of Columns of Matrix 1 = No of Columns of Matrix 2
ii. Resultant Matrix will be of Dimension – c [No. of Rows of Mat1][No. of Columns of Mat2]
4. C Program to check whether matrix is magic square or not?
What is Magic Square?
1. A magic square is a simple mathematical game developed during the
1500.
2. Square is divided into equal number of rows and columns.
3. Start filling each square with the number from 1 to num ( where
num = No of Rows X No of Columns )
4. You can only use a number once.
5. Fill each square so that the sum of each row is the same as the
sum of each column.
6. In the example shown here, the sum of each row is 15, and the sum
of each column is also 15.
7. In this Example: The numbers from 1 through 9 is used only once.
This is called a magic square.
#include<stdio.h>
#include<conio.h>
int main() {
int size = 3;
int matrix[3][3]; // = {{4,9,2},{3,5,7},{8,1,6}};
int row, column = 0;
int sum, sum1, sum2;
int flag = 0;
printf("\nEnter matrix : ");
for (row = 0; row < size; row++) {
for (column = 0; column < size; column++)
scanf("%d", &matrix[row][column]); }
printf("Entered matrix is : \n");
for (row = 0; row < size; row++) {
printf("\n");
for (column = 0; column < size; column++) {
printf("\t%d", matrix[row][column]); } }
//For diagonal elements
sum = 0;
for (row = 0; row < size; row++) {
for (column = 0; column < size; column++) {
if (row == column)
sum = sum + matrix[row][column]; } }
//For Rows
for (row = 0; row < size; row++) {
sum1 = 0;
for (column = 0; column < size; column++) {
sum1 = sum1 + matrix[row][column]; }
if (sum == sum1)
flag = 1;
else {
flag = 0;
break; } }
//For Columns
for (row = 0; row < size; row++) {
sum2 = 0;
for (column = 0; column < size; column++) {
sum2 = sum2 + matrix[column][row]; }
if (sum == sum2)
flag = 1;
else {
flag = 0;
break; } }
if (flag == 1)
printf("\nMagic square");
else
printf("\nNo Magic square");
return 0;
}
Output:
Enter matrix : 4 9 2 3 5 7 8 1 6
Entered matrix is :
4 9 2
3 5 7
8 1 6
Magic square
Sum of Row1 = Sum of Row2 [Sum of All Rows must be same]
Sum of Col1 = Sum of Col2 [Sum of All Cols must be same]
Sum of Left Diagonal = Sum of Right Diagonal

Limitations of Arrays:
Array is very useful which stores multiple data under single name with same data type.
Following are some listed limitations of Array in C Programming.
A. Static Data
1. Array is Static data Structure
2. Memory Allocated during Compile time.
3. Once Memory is allocated at Compile Time it cannot be changed during Run-time

B. Can hold data belonging to same Data types


1. Elements belonging to different data types cannot be stored in array because array data
structure can hold data belonging to same data type.
2. Example : Character and Integer values can be stored inside separate array but cannot
be stored in single array
C. Inserting data in an array is difficult
1. Inserting element is very difficult because before inserting element in an array we have
to create empty space by shifting other elements one position ahead.
2. This operation is faster if the array size is smaller, but same operation will be more and
more time consuming and non-efficient in case of array with large size.
D. Deletion Operation is difficult
1. Deletion is not easy because the elements are stored in contiguous memory location.
2. Like insertion operation , we have to delete element from the array and after deletion
empty space will be created and thus we need to fill the space by moving elements up in
the array.
E. Bound Checking
1. If we specify the size of array as „N‟ then we can access elements up to „N-1‟ but in C if
we try to access elements after „N-1‟ i.e. Nth element or N+1th element then we does not
get any error message.
2. Process of checking the extreme limit of array is called Bound Checking and C does not
perform Bound Checking.
3. If the array range exceeds then we will get garbage value as result.
F. Shortage of Memory
1. Array is Static data structure. Memory can be allocated at compile time only Thus if after
executing program we need more space for storing additional information then we cannot
allocate additional space at run time.
2. Shortage of Memory , if we don‟t know the size of memory in advance
G. Wastage of Memory
1. Wastage of Memory, if array of large size is defined

Applications of Arrays:
Array is used for different verities of applications. Array is used to store the data or values of
same data type. Below are the some of the applications of array –
A. Stores Elements of Same Data Type
Array is used to store the number of elements belonging to same data type.
int arr[30];
Above array is used to store the integer numbers in an array.
arr[0] = 10;
arr[1] = 20;
arr[2] = 30;
arr[3] = 40;
arr[4] = 50;
Similarly if we declare the character array then it can hold only character. So in short character
array can store character variables while floating array stores only floating numbers.
B. Array Used for maintaining multiple variable names using single name
Suppose we need to store 5 roll numbers of students then without declaration of array we need
to declare following –
int roll1, roll2, roll3, roll4, roll5;
1. Now in order to get roll number of first student we need to access roll1.
2. Guess if we need to store roll numbers of 100 students then what will be the procedure.
3. Maintaining all the variables and remembering all these things is very difficult.
Consider the Array int roll[5]; Here we are using array which can store multiple values and we
have to remember just single variable name.
C. Array can be used for Sorting Elements
We can store elements to be sorted in an array and then by using different sorting technique we
can sort the elements.
Different Sorting Techniques are:
1. Bubble Sort
2. Insertion Sort
3. Selection Sort
4. Bucket Sort
D. Array can perform Matrix Operation
Matrix operations can be performed using the array. We can use 2-D array to store the matrix.
Matrix can be multi dimensional.
E. Array can be used in CPU Scheduling
CPU Scheduling is generally managed by Queue. Queue can be managed and implemented
using the array. Array may be allocated dynamically i.e at run time. [Animation will Explain more
about Round Robin Scheduling Algorithm | Video Animation]
F. Array can be used in Recursive Function
When the function calls another function or the same function again then the current values are
stores onto the stack and those values will be retrieving when control comes back. This is
similar operation like stack.

Arrays as Function arguments:


Passing array to function:
Array can be passed to function by two ways:
1. Pass Entire array
2. Pass Array element by element
1. Pass Entire array
Here entire array can be passed as a argument to function.
Function gets complete access to the original array.
While passing entire array address of first element is passed to function, any changes made
inside function, directly affects the Original value.
Function Passing method : “Pass by Address“
2. Pass Array element by element
Here individual elements are passed to function as argument.
Duplicate carbon copy of Original variable is passed to function.
So any changes made inside function do not affect the original value.
Function doesn‟t get complete access to the original array element.
Function passing method is “Pass by Value“
Passing entire array to function:
Parameter Passing Scheme : Pass by Reference
Pass name of array as function parameter.
Name contains the base address i.e. ( Address of 0th element )
Array values are updated in function.
Values are reflected inside main function also.
Example Program #1:
#include<stdio.h>
#include<conio.h>
void fun(int arr[ ])
{
int i;
for(i=0;i< 5;i++)
arr[i] = arr[i] + 10;
}
void main( )
{
int arr[5],i;
clrscr();
printf("\nEnter the array elements : ");
for(i=0;i< 5;i++)
scanf("%d",&arr[i]);
printf("\nPassing entire array .....");
fun(arr); // Pass only name of array
for(i=0;i< 5;i++)
printf("\nAfter Function call a[%d] : %d",i,arr[i]);
getch();
}
Output :
Enter the array elements : 1 2 3 4 5
Passing entire array .....
After Function call a[0] : 11
After Function call a[1] : 12
After Function call a[2] : 13
After Function call a[3] : 14
After Function call a[4] : 15
Passing Entire 1-D Array to Function in C Programming:
Array is passed to function completely.
Parameter Passing Method : Pass by Reference
It is Also Called “Pass by Address“
Original Copy is Passed to Function
Function Body can modify Original Value.
Example Program #2:
#include<stdio.h>
#include<conio.h>
void modify(int b[3]);
void main()
{
int arr[3] = {1,2,3};
modify(arr);
for(i=0;i<3;i++)
printf("%d",arr[i]);
getch();
}
void modify(int a[3])
{
int i;
for(i=0;i<3;i++)
a[i] = a[i]*a[i];
}
Output:
1 4 9
Here “arr” is same as “a” because Base Address of Array “arr” is stored in Array “a”
Alternate Way of Writing Function Header:
void modify(int a[3]) OR void modify(int *a)
Passing Entire 2D Array to Function in C Programming:
Example Program #3:
#include<stdio.h>
void Function(int c[2][2]);
int main(){
int c[2][2],i,j;
printf("Enter 4 numbers:\n");
for(i=0;i<2;++i)
for(j=0;j<2;++j){
scanf("%d",&c[i][j]); }
Function(c); /* passing multi-dimensional array to function */
return 0;
}
void Function(int c[2][2])
{
/* Instead to above line, void Function(int c[][2]) is also valid */
int i,j;
printf("Displaying:\n");
for(i=0;i<2;++i)
for(j=0;j<2;++j)
printf("%d\n",c[i][j]);
}
Output:
Enter 4 numbers:
2
3
4
5
Displaying:
2
3
4
5
Passing array element by element to function:
1. Individual element is passed to function using Pass By Value parameter passing scheme
2. An original Array element remains same as Actual Element is never passed to Function.
Thus function body cannot modify Original Value.
3. Suppose we have declared an array „arr[5]‟ then its individual elements are
arr[0],arr[1]…arr[4]. Thus we need 5 function calls to pass complete array to a function.
Consider an array int arr[5] = {11, 22, 33, 44, 55};

Iteration Element Passed to Function Value of Element


1 arr[0] 11
2 arr[1] 22
3 arr[2] 33
4 arr[3] 44
5 arr[4] 55

Example Program #1:


#include< stdio.h>
#include< conio.h>
void fun(int num)
{
printf("\nElement : %d",num);
}
void main() {
int arr[5],i;
clrscr();
printf("\nEnter the array elements : ");
for(i=0;i< 5;i++)
scanf("%d",&arr[i]);
printf("\nPassing array element by element.....");
for(i=0;i< 5;i++)
fun(arr[i]);
getch();
}
Output:
Enter the array elements : 1 2 3 4 5
Passing array element by element.....
Element : 1
Element : 2
Element : 3
Element : 4
Element : 5
Disadvantage of this Scheme:
1. This type of scheme in which we are calling the function again and again but with
different array element is too much time consuming. In this scheme we need to call
function by pushing the current status into the system stack.
2. It is better to pass complete array to the function so that we can save some system time
required for pushing and popping.
3. We can also pass the address of the individual array element to function so that function
can modify the original copy of the parameter directly.
Example Program #2: Passing 1-D Array Element by Element to function
#include<stdio.h>
void show(int b);
void main() {
int arr[3] = {1,2,3};
int i;
for(i=0;i<3;i++)
show(arr[i]);
}
void show(int x)
{
printf("%d ",x);
}
Output:
1 2 3

STRINGS

A string is a sequence of character enclosed with in double quotes (“ ”) but ends with
\0. The compiler puts \0 at the end of string to specify the end of the string.
To get a value of string variable we can use the two different types of formats.
Using scanf() function as: scanf(“%s”, string variable);

Using gets() function as : gets(string variable);

STRING HANDLING FUNCTIONS

C library supports a large number of string handling functions. Those functions are stored under
the header file string.h in the program.

Let us see about some of the string handling functions.


(i) strlen() function
strlen() is used to return the length of the string , that means counts the number
of characters present in a string.
Syntax
integer variable = strlen (string variable);
Example:
#include<stdio.h>
#include<conio.h>
void main()
{
char str[20];
int strlength;
clrscr();
printf(‚Enter String:‛);
gets(str);
strlength=strlen(str);
printf(‚Given String Length Is: %d‛, strlength);
getch();
}
Output:
Enter String
Welcome
Given String Length Is:7

(ii) strcat() function


The strcat() is used to concatenate two strings. The second string will be appended to
the end of the first string. This process is called concatenation.

Syntax
strcat (StringVariable1, StringVariable 2);
Example:
#include<stdio.h>
#include<conio.h>
void main()
{
char str1[20],str2[20];
clrscr();
printf(‚Enter First String:‛);
scanf(‚%s‛,str1);
printf(‚Enter Second String:‛);
scanf(‚%s‛,str2);
printf(‚ Concatenation String is:%s‛, strcat(str1,str2));
getch();
}
Output:
Enter First String
Good
Enter Second String
Morning
Concatenation String is: GoodMorning
(iii) strcmp() function
strcmp() function is used to compare two strings. strcmp() function does a case
sensitive comparison between two strings. The two strings are compared character by
character until there is a mismatch or end of one of the strings is reached (whichever occurs
first). If the two strings are identical, strcmp( ) returns a value zero. If they‟re not, it returns the
numeric difference between the ASCII values of the first non-matching pairs of characters.

Syntax
strcmp(StringVariable1, StringVariable2);
Example:
#include<stdio.h>
#include<conio.h>
void main()
{
char str1[20], str2[20];
int res;
clrscr();
printf(‚Enter First String:‛);
scanf(‚%s‛,str1);
printf(‚Enter Second String:‛);
scanf(‚%s‛,str2);
res = strcmp(str1,str2);
printf(‚ Compare String Result is:%d‛,res);
getch();
}
Output:
Enter First String
Good
Enter Second String
Good
Compare String Result is: 0

(iv) strcmpi() function

strcmpi() function is used to compare two strings. strcmpi() function is not case sensitive.

Syntax
strcmpi(StringVariable1, StringVariable2);
Example:
#include<stdio.h>
#include<conio.h>
void main()
{
char str1[20], str2[20];
int res;
clrscr();
printf(‚Enter First String:‛);
scanf(‚%s‛,str1);
printf(‚Enter Second String:‛);
scanf(‚%s‛,str2);
res = strcmpi(str1,str2);
printf(‚ Compare String Result is:%d‛,res);
getch();
}
Output:
Enter First String
WELCOME
Enter Second String
welcome
Compare String Result is: 0
(v) strcpy() function:

strcpy() function is used to copy one string to another. strcpy() function copy the contents of
second string to first string.

Syntax
strcpy(StringVariable1, StringVariable2);

Example:
#include<stdio.h>
#include<conio.h>
void main()
{
char str1[20], str2[20];
int res;
clrscr();
printf(‚Enter First String:‛);
scanf(‚%s‛,str1);
printf(‚Enter Second String:‛);
scanf(‚%s‛,str2);
strcpy(str1,str2)
printf(‚ First String is:%s‛,str1);
printf(‚ Second String is:%s‛,str2);
getch();
}
Output:
Enter First String
Hello
Enter Second String
welcome
First String is: welcome
Second String is: welcome
(vi) strlwr () function:
This function converts all characters in a given string from uppercase to lowercase letter.

Syntax
strlwr(StringVariable);

Example:

#include<stdio.h>
#include<conio.h>
void main()
{
char str[20];
clrscr();
printf(‚Enter String:‛);
gets(str);
printf(‚Lowercase String : %s‛, strlwr(str));
getch();
}
Output:
Enter String
WELCOME
Lowercase String : welcome
(vii) strrev() function:
strrev() function is used to reverse characters in a given string.

Syntax

strrev(StringVariable);

Example:

#include<stdio.h>
#include<conio.h>
void main()
{
char str[20];
clrscr();
printf(‚Enter String:‛);
gets(str);
printf(‚Reverse String : %s‛, strrev(str));
getch();
}
Output:
Enter String
WELCOME
Reverse String : emoclew
(viii) strupr() function:
strupr() function is used to convert all characters in a given string from lower case to
uppercase letter.

Syntax

strupr(Stringvariable);

Example:

#include<stdio.h>
#include<conio.h>
void main()
{
char str[20];
clrscr();
printf(‚Enter String:‛);
gets(str);
printf(‚Uppercase String : %s‛, strupr(str));
getch();
}
Output:
Enter String
welcome
Uppercase String : WELCOME

STRUCTURES

Arrays are used for storing a group of SIMILAR data items. In order to store a group of
data items, we need structures. Structure is a constructed data type for packing different types
of data that are logically related. The structure is analogous to the “record” of a database.
Structures are used for organizing complex data in a simple and meaningful way.

Example for structures:

Student : regno, student_name, age, address

Book : bookid, bookname, author, price, edition, publisher, year

Employee : employeeid, employee_name, age, sex, dateofbirth, basicpay

Customer : custid, cust_name, cust_address, cust_phone

Structure Definition
Structures are defined first and then it is used for declaring structure variables. Let us
see how to define a structure using simple example given below:

struct book

int bookid;

char bookname[20];

char author[20];

float price;

int year;

int pages;

char publisher[25];

};
The keyword “struct” is used for declaring a structure. In this example, book is the name of the
structure or the structure tag that is defined by the struct keyword. The book structure has six
fields and they are known as structure elements or structure members. Remember each
structure member may be of a different data type. The structure tag name or the structure
name can be used to declare variables of the structure data type.

The syntax for structure definition is given below:

struct tagname

Data_type member1;

Data_type member2;

…………….

……………

};

Note:

1. To mark the completion of the template, semicolon is used at the end of the
template.
2. Each structure member is declared in a separate line.

Declaring Structure Variables

First, the structure format is defined. Then the variables can be declared of that structure type.
A structure can be declared in the same way as the variables are declared. There are two
ways for declaring a structure variable.

1) Declaration of structure variable at the time of defining the structure (i.e structure
definition and structure variable declaration are combined)

struct book
{
int bookid;
char bookname[20];
char author[20];
float price;
int year;
int pages;
char publisher[25];
} b1,b2,b3;

The b1, b2, and b3 are structure variables of type struct book.

2) Declaration of structure variable after defining the structure


struct book
{
int bookid;
char bookname[20];
char author[20];
float price;
int year;
int pages;
char publisher[25];
};

struct book b1, b2, b3;

NOTE:
 Structure tag name is optional.

E.g.

struct
{
int bookid;
char bookname[20];
char author[20];
float price;
int year;
int pages;
char publisher[25];
}b1, b2, b3;

Declaration of structure variable at a later time is not possible with this type of
declaration. It is a drawback in this method. So the second method can be preferred.

 Structure members are not variables. They don‟t occupy memory until they
are associated with a structure variable.

Accessing Structure Members


There are many ways for storing values into structure variables. The members of a
structure can be accessed using a “dot operator” or “period operator”.

E.g. [Link] -> b1 is a structure variable and author is a structure member.

Syntax

STRUCTURE_Variable.STRUCTURE_Members

The different ways for storing values into structure variable is given below:

Method 1: Using Simple Assignment Statement

[Link] = 786;

[Link] = 786.50;

Method 2: Using strcpy function

strcpy([Link], ‚Programming in C‛);

strcpy([Link], ‚John‛);

Method 3: Using scanf function

scanf(‚%s \n‛, [Link]);

scanf(‚%d \n‛, &[Link]);

Example

#include<stdio.h>

#include<conio.h>

struct book

int bookid;
char bookname[20];
char author[20];
float price;
int year;
int pages;
char publisher[25];
};

struct book b1, b2, b3;


main()
{
struct book b1;
clrscr();
printf("Enter the Book Id: ");
scanf("%d", &[Link]);
printf("Enter the Book Name: ");
scanf("%s", [Link]);
printf("Enter the Author Name: ");
scanf("%s", [Link]);
printf("Enter the Price: ");
scanf("%f", &[Link]);
printf("Enter the Year: ");
scanf("%d", &[Link]);
printf("Enter the Total No. of Pages: ");
scanf("%d", &[Link]);
printf("Enter the Publisher Name: ");
scanf("%s", [Link]);
printf("%d %s %d %f %d %d %s", [Link], [Link],
[Link], [Link], [Link], [Link], [Link]);
getch();
}
Output

Enter the Book Id: 786


Enter the Book Name: Programming
Enter the Author Name: John
Enter the Price: 123.50
Enter the Year: 2015
Enter the Total No. of Pages: 649
Enter the Publisher Name: Tata McGraw
786 Programming 2118 123.500000 2015 649 Tata
Structure Initialization

Like variables, structures can also be initialized at the compile time.

Example
main()
{
struct
{
int rollno;
int attendance;
}
s1={786, 98};
}

The above example assigns 786 to the rollno and 98 to the attendance.

Structure variable can be initialized outside the function also.

Example

main()
{
struct student
{
int rollno;
int attendance;
};
struct student s1={786, 98};
struct student s2={123, 97};
}
Note:

Individual structure members cannot be initialized within the template. Initialization is


possible only with the declaration of structure members.

Nested Structures or Structures within Structures

Structures can also be nested. i.e A structure can be defined inside another structure.

Example

struct employee
{
int empid;
char empname[20];
int basicpay;
int da;
int hra;
int cca;
} e1;

In the above structure, salary details can be grouped together and defined as a
separate structure.

Example

struct employee
{
int empid;
char empname[20];
struct
{
int basicpay;
int da;
int hra;
int cca;
} salary;
} e1;
The structure employee contains a member named salary which itself is another
structure that contains four structure members. The members inside salary structure
can be referred as below:

[Link]
[Link];
[Link];
[Link];
However, the inner structure member cannot be accessed without the inner structure
variable.

Example

[Link]
[Link]
[Link]
[Link]
are invalid statements
Moreover, when the inner structure variable is used, it must refer to its inner structure
member. If it doesn‟t refer to the inner structure member then it will be considered as
an error.

Example

[Link] (salary is not referring to any inner structure member. Hence it is wrong)

Note: C permits 15 levels of nesting and C99 permits 63 levels of nesting.

Array of Structures

A Structure variable can hold information of one particular record. For example,
single record of student or employee. Suppose, if multiple records are to be
maintained, it is impractical to create multiple structure variables. It is like the
relationship between a variable and an array. Why do we go for an array? Because we
don‟t want to declare multiple variables and it is practically impossible. Assume that you
want to store 1000 values. Do you declare 1000 variables like a1, a2, a3…. Upto
a1000? Is it easy to maintain such code ? Is it a good coding? No. It is not.
Therefore, we go for Arrays. With a single name, with a single variable, we can store
1000 values. Similarly, to store 1000 records, we cannot declare 1000 structure
variables. But we need “Array of Structures”.

An array of structure is a group of structure elements under the same structure


variables.

struct student s1[1000];

The above code creates 1000 elements of structure type student. Each element
will be structure data type called student. The values can be stored into the array of
structures as follows:

s1[0].student_age = 19;

Example

#include<stdio.h>
#include<conio.h>
struct book
{
int bookid;
char bookname[20];
char author[20];
};

Struct b1[5];

main()
{
int i;
clrscr();
for (i=0;i<5;i++)
{
printf("Enter the Book Id: ");
scanf("%d", &b1[i].bookid);
printf("Enter the Book Name: ");
scanf("%s", b1[i].bookname);
printf("Enter the Author Name: ");
scanf("%s", b1[i].author);
}
for (i=0;i<5;i++)
{
printf("%d \t %s \t %s \n", b1[i].bookid, b1[i].bookname,
b1[i].author);
}
getch();
}

Output:

Enter the Book Id: 786


Enter the Book Name: Programming
Enter the Author Name: Dennis Ritchie
Enter the Book Id: 101
Enter the Book Name: Java Complete Reference
Enter the Author Name: Herbert Schildt
Enter the Book Id: 008
Enter the Book Name: Computer Graphics
Enter the Author Name: Hearn and Baker

786 Programming Dennis Ritchie


101 Java Complete Reference Herbert Schildt

008 Computer Graphics Hearn and Baker

Structure as Function Argument

Example
struct sample
{
int no;
float avg;
} a;
void main( )
{
[Link]=75;
[Link]=90.25;
fun(a);
}

void fun(struct sample p)


{
printf(‚The no is=%d Average is %f‛,[Link] , [Link]);
}

Output

The no is 75 Average is 90.25

Function that returns Structure

The members of a structure can be passed to a function. If a structure is to be passed to a


called function , we can use any one of the following method.

Method 1 :- Individual member of the structure is passed as an actual argument of the function
call. The actual arguments are treated independently. This method is not suitable if a structure
is very large structure.

Method 2:- Entire structure is passed to the called function. Since the structure declared as
the argument of the function, it is local to the function only. The members are valid for the
function only. Hence if any modification done on any member of the structure , it is not reflected
in the original structure.

Method 3 :- Pointers can be used for passing the structure to a user defined function. When
the pointers are used , the address of the structure is copied to the function. Hence if any
modification done on any member of the structure , it is reflected in the original structure.

Return data type function name ( structured variable )

Structured Data type for the structured variable;

{
Local Variable declaration;
Statement 1;
Statement 2;
--------------
-------------
Statement n;
}
Example :
#include <stdio.h>
struct st
{
char name[20];
int no;
int marks;
};
int main( )
{
struct st x ,y;
int res;
printf(‚\n Enter the First Record‛);
scanf(‚%s%d%d‛,[Link],&[Link],&[Link]);
printf(‚\n Enter the Second Record‛);
scanf(‚%s%d%d‛,[Link],&[Link],&[Link]);
res = compare ( x , y );
if (res == 1)
printf(‚\n First student has got the Highest Marks‛);
else
printf(‚\n Second student has got the Highest Marks‛);
}
compare ( struct st st1 , struct st st2)
{
if ([Link] > st2. marks )
return ( 1 );
else
return ( 0 );
}

In the above example , x and y are the structures sent from the main ( ) function as the
actual parameter to the formal parameters st1 and st2 of the function compare ( ).

Example program (1) – passing structure to function

#include<stdio.h>
#include<conio.h>
//-------------------------------------
struct Example
{
int num1;
int num2;
}s[3];
//-------------------------------------
void accept(struct Example *sptr)
{
printf("\nEnter num1 : ");
scanf("%d",&sptr->num1);
printf("\nEnter num2 : ");
scanf("%d",&sptr->num2);
}
//-------------------------------------
void print(struct Example *sptr)
{
printf("\nNum1 : %d",sptr->num1);
printf("\nNum2 : %d",sptr->num2);
}
//-------------------------------------
void main()
{
int i;
clrscr();
for(i=0;i<3;i++)
accept(&s[i]);

for(i=0;i<3;i++)
print(&s[i]);

getch();
}
Output :
Enter num1 : 10
Enter num2 : 20
Enter num1 : 30
Enter num2 : 40
Enter num1 : 50
Enter num2 : 60
Num1 : 10
Num2 : 20
Num1 : 30
Num2 : 40
Num1 : 50
Num2 : 60

Example program (2) – passing structure to function in C by value:


In this program, the whole structure is passed to another function by value. It means the
whole structure is passed to another function with all members and their values. So, this
structure can be accessed from called function. This concept is very useful while writing very big
programs in C.
#include <stdio.h>
#include <string.h>

struct student
{
int id;
char name[20];
float percentage;
};

void func(struct student record);

void main()
{
struct student record;

[Link]=1;
strcpy([Link], "Raju");
[Link] = 86.5;

func(record);
getch();
}

void func(struct student record)


{
printf(" Id is: %d \n", [Link]);
printf(" Name is: %s \n", [Link]);
printf(" Percentage is: %f \n", [Link]);
}
Output:
Id is: 1
Name is: Raju
Percentage is: 86.500000

Example program (3) Passing structure by value

A structure variable can be passed to the function as an argument as normal variable. If


structure is passed by value, change made in structure variable in function definition does not
reflect in original structure variable in calling function.

Write a C program to create a structure student, containing name and roll. Ask user the
name and roll of a student in main function. Pass this structure to a function and display
the information in that function.

#include <stdio.h>
struct student
{
char name[50];
int roll;
};
void Display(struct student stu);
/* function prototype should be below to the structure declaration
otherwise compiler shows error */
int main()
{
struct student s1;
printf("Enter student's name: ");
scanf("%s",&[Link]);
printf("Enter roll number:");
scanf("%d",&[Link]);
Display(s1); // passing structure variable s1 as argument
return 0;
}
void Display(struct student stu){
printf("Output\nName: %s",[Link]);
printf("\nRoll: %d",[Link]);
}

Output
Enter student's name: Kevin Amla
Enter roll number: 149
Output

Example program (4) – Passing structure to function in C by address:


In this program, the whole structure is passed to another function by address. It means
only the address of the structure is passed to another function. The whole structure is not
passed to another function with all members and their values. So, this structure can be
accessed from called function by its address.
#include <stdio.h>
#include <string.h>

struct student
{
int id;
char name[20];
float percentage;
};

void func(struct student *record);

void main()
{
struct student record;

[Link]=1;
strcpy([Link], "Raju");
[Link] = 86.5;

func(&record);
getch();
}

void func(struct student *record)


{
printf(" Id is: %d \n", record->id);
printf(" Name is: %s \n", record->name);
printf(" Percentage is: %f \n", record->percentage);
}
Output:
Id is: 1
Name is: Raju
Percentage is: 86.500000

Example program (5) Passing structure by reference


The address location of structure variable is passed to function while passing it by
reference. If structure is passed by reference, change made in structure variable in function
definition reflects in original structure variable in the calling function.
Write a C program to add two distances(feet-inch system) entered by user. To solve this
program, make a structure. Pass two structure variable (containing distance in feet and
inch) to add function by reference and display the result in main function without
returning it.
#include <stdio.h>
struct distance
{
int feet;
float inch;
};
void Add(struct distance d1,struct distance d2, struct distance *d3);
int main()
{
struct distance dist1, dist2, dist3;
printf("First distance\n");
printf("Enter feet: ");
scanf("%d",&[Link]);
printf("Enter inch: ");
scanf("%f",&[Link]);
printf("Second distance\n");
printf("Enter feet: ");
scanf("%d",&[Link]);
printf("Enter inch: ");
scanf("%f",&[Link]);
Add(dist1, dist2, &dist3);

/*passing structure variables dist1 and dist2 by value whereas passing


structure variable dist3 by reference */
printf("\nSum of distances = %d\'-%.1f\"",[Link], [Link]);
return 0;
}
void Add(struct distance d1,struct distance d2, struct distance *d3)
{
/* Adding distances d1 and d2 and storing it in d3 */
d3->feet=[Link]+[Link];
d3->inch=[Link]+[Link];
if (d3->inch>=12) { /* if inch is greater or equal to 12,
converting it to feet. */
d3->inch-=12;
++d3->feet;
}
}
Output
First distance
Enter feet: 12
Enter inch: 6.8
Second distance
Enter feet: 5
Enter inch: 7.5
Sum of distances = 18'-2.3"

Explanation
In this program, structure variables dist1 and dist2 are passed by value (because value of dist1
and dist2 does not need to be displayed in main function) and dist3 is passed by reference ,i.e,
address of dist3 (&dist3) is passed as an argument. Thus, the structure pointer variable d3
points to the address of dist3. If any change is made in d3 variable, effect of it is seed in dist3
variable in main function.

Example program(6) to declare a structure variable as global in C:

Structure variables also can be declared as global variables as we declare other


variables in C. So, When a structure variable is declared as global, then it is visible to all the
functions in a program. In this scenario, we don‟t need to pass the structure to any function
separately.
#include <stdio.h>
#include <string.h>

struct student
{
int id;
char name[20];
float percentage;
};
struct student record; // Global declaration of structure

void structure_demo();

int main()
{
[Link]=1;
strcpy([Link], "Raju");
[Link] = 86.5;

structure_demo();
return 0;
}

void structure_demo()
{
printf(" Id is: %d \n", [Link]);
printf(" Name is: %s \n", [Link]);
printf(" Percentage is: %f \n", [Link]);
}
Output:
Id is: 1
Name is: Raju
Percentage is: 86.500000

Example program(7)Passing Array of Structure to Function in C Programming

Array of Structure can be passed to function as a [Link] can also return Structure
as return [Link] can be passed as follow

Example :

#include<stdio.h>
#include<conio.h>
//-------------------------------------
struct Example
{
int num1;
int num2;
}s[3];
//-------------------------------------
void accept(struct Example sptr[],int n)
{
int i;
for(i=0;i<n;i++)
{
printf("\nEnter num1 : ");
scanf("%d",&sptr[i].num1);
printf("\nEnter num2 : ");
scanf("%d",&sptr[i].num2);
}
}
//-------------------------------------
void print(struct Example sptr[],int n)
{
int i;
for(i=0;i<n;i++)
{
printf("\nNum1 : %d",sptr[i].num1);
printf("\nNum2 : %d",sptr[i].num2);
}
}
//-------------------------------------
void main()
{
int i;
clrscr();
accept(s,3);
print(s,3);
getch();
}
Output :
Enter num1 : 10
Enter num2 : 20
Enter num1 : 30
Enter num2 : 40
Enter num1 : 50
Enter num2 : 60
Num1 : 10
Num2 : 20
Num1 : 30
Num2 : 40
Num1 : 50
Num2 : 60

Explanation :

Inside main structure and size of structure array is passed. When reference (i.e ampersand) is
not specified in main , so this passing is simple pass by value. Elements can be accessed by
using dot [.] operator

Union
The concept of Union is borrowed from structures and the formats are also same. The
distinction between them is in terms of storage. In structures , each member is stored in its own
location but in Union , all the members are sharing the same location. Though Union consists of
more than one members , only one member can be used at a particular time. The size of the
cell allocated for an Union variable depends upon the size of any member within Union
occupying more no:- of bytes. The syntax is the same as structures but we use the keyword
union instead of struct.

Example:- the employee record is declared and processed as follows


union emp
{
char name[20];
int eno;
float salary;
} employee;

where employee is the union variable which consists of the member name,no
and salary. The compiler allocates only one cell for the union variable as
20 Bytes Length

Employee (only one location)

Location / Cell for name,no and salary

20 bytes cell can be shared by all the members because the member name is occupying the
highest no:- of bytes. At a particular time we can handle only one [Link] access the
members of an union , we have to use the same format of structures.

Example program for C union:


#include <stdio.h>
#include <string.h>

union student
{
char name[20];
char subject[20];
float percentage;
};

int main()
{
union student record1;
union student record2;

// assigning values to record1 union variable


strcpy([Link], "Raju");
strcpy([Link], "Maths");
[Link] = 86.50;

printf("Union record1 values example\n");


printf(" Name : %s \n", [Link]);
printf(" Subject : %s \n", [Link]);
printf(" Percentage : %f \n\n", [Link]);

// assigning values to record2 union variable


printf("Union record2 values example\n");
strcpy([Link], "Mani");
printf(" Name : %s \n", [Link]);

strcpy([Link], "Physics");
printf(" Subject : %s \n", [Link]);
[Link] = 99.50;
printf(" Percentage : %f \n", [Link]);
return 0;
}
Output:
Union record1 values example
Name :
Subject :
Percentage : 86.500000;
Union record2 values example
Name : Mani
Subject : Physics
Percentage : 99.500000
Explanation for above C union program:
There are 2 union variables declared in this program to understand the difference in
accessing values of union members.
Record1 union variable:

“Raju” is assigned to union member “[Link]” . The memory location name is


“[Link]” and the value stored in this location is “Raju”.
Then, “Maths” is assigned to union member “[Link]”. Now, memory location
name is changed to “[Link]” with the value “Maths” (Union can hold only one
member at a time).
Then, “86.50” is assigned to union member “[Link]”. Now, memory location
name is changed to “[Link]” with value “86.50”.
Like this, name and value of union member is replaced every time on the common
storage space.
So, we can always access only one union member for which value is assigned at last.
We can‟t access other member values.
So, only “[Link]” value is displayed in output. “[Link]” and
“[Link]” are empty.

Record2 union variable:

If we want to access all member values using union, we have to access the member
before assigning values to other members as shown in record2 union variable in this
program.
Each union members are accessed in record2 example immediately after assigning
values to them.
If we don‟t access them before assigning values to other member, member name and
value will be over written by other member as all members are using same memory.
We can‟t access all members in union at same time but structure can do that.

Example program – Another way of declaring C union:


In this program, union variable “record” is declared while declaring union itself as shown in
the below program.
#include <stdio.h>
#include <string.h>
union student
{
char name[20];
char subject[20];
float percentage;
}record;

int main()
{

strcpy([Link], "Raju");
strcpy([Link], "Maths");
[Link] = 86.50;

printf(" Name : %s \n", [Link]);


printf(" Subject : %s \n", [Link]);
printf(" Percentage : %f \n", [Link]);
return 0;
}
Output:
Name :
Subject :
Percentage : 86.500000
Note:
We can access only one member of union at a time. We can‟t access all member values at
the same time in union. But, structure can access all member values at the same time. This is
because, Union allocates one common storage space for all its members. Where as Structure
allocates storage space for all its members separately.
Difference between structure and union in C:
[Link] C Structure C Union

Union allocates one common storage space for all its


Structure allocates storage members.
1 space for all its members Union finds that which of its member needs high storage
separately. space over other members and allocates that much space

Structure occupies higher


2 Union occupies lower memory space over structure.
memory space.

We can access all members


3 We can access only one member of union at a time.
of structure at a time.

4 Structure example: Union example:


struct student union student
{ {
int mark; int mark;
char name[6]; char name[6];
double average; double average;
}; };

For above structure, memory


allocation will be like below.
For above union, only 8 bytes of memory will be allocated
int mark – 2B
since double data type will occupy maximum space of
5 char name[6] – 6B
memory over other data types.
double average – 8B
Total memory allocation = 8 Bytes
Total memory allocation =
2+6+8 = 16 Bytes

Assignment Question

1. Create a structure to store the employee number, name, department and basic salary.
Create a array of structure to accept and display the values of 10 employees.

PRACTICE QUESTIONS

Programs for Practice:

1) Write a C program to initialize an array using functions.


2) Write a C program to interchange array elements of two arrays using functions.
3) Write a C program to pass an array containing age of person to a function. This
function should find average age and display the average age in main function.
4) Write a c program to check whether a given string is a palindrome or not
5) What would be the output of the following programs:

main( )
{
char c[2] = "A" ;
printf ( "\n%c", c[0] ) ;
printf ( "\n%s", c ) ;
}
main( )
{
char str1[ ] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ } ;
char str2[ ] = "Hello" ;
printf ( "\n%s", str1 ) ;
printf ( "\n%s", str2 ) ;
}
a) main( )

printf ( 5 + "Good Morning " ) ;

6) Point out the errors,if any,in the following programs

(a) main( )
{
char *str1 = "United" ;
char *str2 = "Front" ;
char *str3 ;
str3 = strcat ( str1, str2 ) ;
printf ( "\n%s", str3 ) ;
}
7) Which is more appropriate for reading in a multi-word string?

` gets( ) printf( ) scanf( ) puts( )

8) If the string "Alice in wonder land" is feed to the following

scanf( ) statement, what will be the contents of the arrays

str1, str2, str3 and str4 ?

scanf ( "%s%s%s%s%s", str1, str2, str3, str4 ) ;


9) Fill in the blanks:
a. "A" is a ___________ while ‟A‟ is a ____________.
b. A string is terminated by a ______ character, which is written

as ______.

c. The array char name [10] can consist of a maximum of ______ characters.

1. Write a C program to initialize an array using functions.


#include<stdio.h>
int main()
int k, c(), d[ ]={c(),c(),c(),c(),c()};
printf(‚\nArray d[] elements are:‛);
for(k=0;k<5;k++)
printf(‚%2d‛,d[k]);
return(0);
}
c()
{
int m,n;
m++;
printf(‚\nEnter number d[%d] : ‛,m);
scanf(‚%d‛,&n);
return(n);
}
Output:
Enter Number d[1] : 20
Enter Number d[2] : 30
Enter Number d[3] : 40
Enter Number d[4] : 50
Enter Number d[5] : 60
Array d[] elements are: 20 30 40 50 60
2. Write a C program to interchange array elements of two arrays using
functions.
#include<stdio.h>
#include<conio.h>
void main()
{
int read();
void change(int*,int*);
int x,a[5],b[5];
clrscr();
printf(‚Enter 10 Numbers :‛);
for(x=0;x<10;x++)
{
if(x<5)
a[x]=read();
else
b[x-5]=read();
}
printf(‚\nArray A & B‛);
for(x=0;x<5;x++)
{
printf(‚\n%7d%8d‛,a[x],b[x]);
change(&a[x],&b[x]);
}
printf(‚\nNow A & B‛);
for(x=0;x<5;x++)
{
printf(‚\n%7d%8d‛,a[x],b[x]);
}
}
int read()
{
int x;
scanf(‚%d‛,&x);
return(x);
}
void change(int *a,int *b)
{
int *k;
*a=*a+*b;
*b=*a-*b;
*a=*a-*b;
}
Output:
Enter 10 Numbers:
0 1 2 3 4 5 6 7 8 9
Array A & B
0 5
1 6
2 7
3 8
4 9
Now A & B
5 0
6 1
7 2
8 3
9 4
3. Write a C program to pass an array containing age of person to a
function. This function should find average age and display the
average age in main function.
#include <stdio.h>
float average(float a[]);
int main(){
float avg, c[]={23.4, 55, 22.6, 3, 40.5, 18};
avg=average(c); /* Only name of array is passed as argument. */
printf("Average age=%.2f",avg);
return 0;
}
float average(float a[])
{
int i;
float avg, sum=0.0;
for(i=0;i<6;++i){
sum+=a[i];
}
avg =(sum/6);
return avg;
}
Output:
Average age=27.08

You might also like