Overview of Computer Programming Languages
Overview of Computer Programming Languages
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
• 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
• 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
#include<stdio.h>
int main( )
{
}
Preprocessor Statements:
#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.
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;
#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)
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.
++x is equivalent to x = x + 1
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;
The statement y = x++; means first the value of x is assigned to y and then
x is incremented.
x is 4 and value of y is 3.
Post Increment/decrement in the context of equation - First use the value inthe
equation and then increment the value
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
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 )
x=8
y=5
max = a > b ? a : b;
Precedence And Associatively of operators
2+3*5
+ 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.
c = 4,
.
What if Two operators are of same precedence
For example-5
+ 16 / 2 * 4
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
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.
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.
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
Artificial Intelligence
Fifth Generation Present - Future
Based
Vacuum Tube
Characteristics Components
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.
Transistor
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 Components
Characteristics Components
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 Components
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
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
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
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.
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
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
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.
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
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
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.
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.
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
Hard discs are discs that are permanently attached and cannot be removed by
a single user.
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
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.
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
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.
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.
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
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.
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.
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 Keyboard
Generally, there are three types of keyboard and they are:
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
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.
Display Tablet (Pen Display Tablet): A tablet with a screen where you draw
directly, seeing the image under the stylus, precise but costly.
Smart Graphic Tablet: A tablet with advanced features like touch gestures
and apps, can work as a standalone computer for drawing or other tasks.
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.
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
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.
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
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
Disadvantages
I. Large in Size
II. Carries high weight
III. A lot of power consumption
IV. Produces heat
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.
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.
Types of plotters
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
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.
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.
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
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.
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.
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.
Types of speakers:
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.
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
Projector: -
Types of projector
Some common types of projectors are as follows –
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:
1. Light Source:
2. Sensor:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office
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.
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
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.
data entry from printed paper data records into electronic editable text which
can be easily searched, stored etc.
S.
OMR OCR
No.
It is hard to implement as
3. It is easy to implement.
compared to OMR.
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.
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
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.
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
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
What is 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.
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.
certain types of security access cards. The compatibility of a card reader depends
on its design and specifications.
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.
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
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.
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.
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.
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.
Digital camera
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:
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
1985 - 1994
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.
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.
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.
Command Description
cd Change directory
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.
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.
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.
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.
Character Map: -
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.
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
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.
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.
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
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.
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.
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.
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.
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
Microsoft Excel
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.
Microsoft OneNote
notes. It should be said that this is the most used application in Microsoft Office
after MS word, excel, and PowerPoint.
Microsoft Outlook
Microsoft Access
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
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
1. Ease to Use
2. Cost
3. Online Support
4. Security
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.
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.
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
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.
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.
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.
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
Menu Bar Contains File,Edit, View, Insert, Format, Tools, Table, Window and
Help menus
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.
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:
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.
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.
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.
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:
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.
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
Function:
Example: In Word, the Task Pane may display formatting options or clipboard
history when dealing with design tasks or copy-paste operations.
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
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.
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.
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
Shortcut Description
Ctrl + scroll
Zoom in and zoom out
mouse
Open Zoom Menu (no native shortcut exists for zoom in/
Alt + W, Q zoom out)
Shortcut Description
Shortcut Description
Shortcut Description
Shortcut Description
Space or
When in ribbon, open or activate the selected item
Enter
Tab / Shift
In Navigation Pane: Move through Navigation Pane options
+ Tab
Shortcut Description
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
Arrow keys, Page up / Page Move around the preview pages (with focus on
Down preview page)
1. Editing Text
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:
Steps:
4. Saving a Document
Steps:
Shortcuts:
Ctrl + S → Save
F12 → Save As
5. Printing a Document
Steps:
MAHARISHI MARKANDESHWAR (DEEMED TO BE
UNIVERSITY),
MULLANA (AMBALA)
Programme: BCA (Sem 1 st )
Course: BCA-102: Computer Fundamentals & MS Office
6. Editing Files
Editing files involves opening, modifying, and saving existing Word documents.
It can include:
Shortcut:
7. Formatting Text
Examples:
Common hotkeys:
Ctrl + B → Bold
Ctrl + I → Italic
Ctrl + U → Underline
Ctrl + E → Center align
Ctrl + L → Left align
Ctrl + R → Right align
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:
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.
You can:
Shortcut:
Definition:
Columns divide the text of a document into two or more vertical sections —
similar to newspaper or magazine layouts.
Number of columns.
Width and spacing of columns.
Apply to part of a document or the whole page.
Shortcut:
Definition:
Spell Check is a built-in feature that checks for spelling and grammar
mistakes in your document and suggests corrections.
Shortcuts:
Indicators:
Shortcut:
Press Shift + F7 after selecting a word to open the Thesaurus directly.
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.
2. Restrict Editing
➤ To allow people to read but not edit (or only edit certain parts):
3. Mark as Final
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 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.
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
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.
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]
4. if..else ladder
5. switch statement
CONDITIONAL STATEMENT
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.
#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:
#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:
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;
else
False statements;
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf(“Enter two value”);
scanf(“%d%d”,&a,&b);
if(a>b)
Output:
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;
return 0;
}
Output:
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.
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:
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;
#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
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;
……….
}
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:
#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:
LOOPING STATEMENTS
A loop statement allows us to execute certain block of code repeatedly until test condition is
false.
1. for loop
2. while loop
3. do...while loop
for loop:
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
#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
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(i=0;i<5;i++)
printf("sathyabama");
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.
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.
for(i=0,j=0;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
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();
}
#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
#include<stdio.h>
void main()
{
while(1)
printf("Hello");
}
Output :
#include<stdio.h>
void main()
{
int num=20;
while(num>10) {
printf("Hello");
}
}
Output :
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 :
DO..WHILE
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.
#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();
#include<stdio.h>
#include<stdio.h>
#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 */
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;
}
C Header Files
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.
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:
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.
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:
Functions
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
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.
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:
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.
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 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:
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;
}
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
Output:
1 factorial is 1
2 factorial is 2
3 factorial is 6
4 factorial is 24
5 factorial is 120
Recursion
#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)
=120
Example :
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 ) ;
}
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
3 5
7 11 13
17 19 23 29
31 37 41 43 47
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
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.
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.
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
int add();
{
void main()
{ int a,b,sum;
result=add( ); 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
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);
}
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.
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);
}
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.
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.
e.g
#include<stdio.h>
main()
{
int m=1000;
func2();
printf(“%d\n”,m);
}
func1()
{
int m=10;
printf(“%d\n”,m);
}
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
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));
}
output :
enter number:5
The factorial of a number is:120
Fibonacci Sequence:
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
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];
Types of Array
1. Single Dimensional Array / One Dimensional Array
2. Multi Dimensional Array
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:
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
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
1 integer roll 1 10
Declaration a[3][4]
No of Rows 3
No of Columns 4
No of Cells 12
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
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
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
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.
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);
C library supports a large number of string handling functions. Those functions are stored under
the header file string.h in the program.
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
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.
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.
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.
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.
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.
Syntax
STRUCTURE_Variable.STRUCTURE_Members
The different ways for storing values into structure variable is given below:
[Link] = 786;
[Link] = 786.50;
strcpy([Link], ‚John‛);
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];
};
Example
main()
{
struct
{
int rollno;
int attendance;
}
s1={786, 98};
}
The above example assigns 786 to the rollno and 98 to the attendance.
Example
main()
{
struct student
{
int rollno;
int attendance;
};
struct student s1={786, 98};
struct student s2={123, 97};
}
Note:
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)
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”.
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:
Example
struct sample
{
int no;
float avg;
} a;
void main( )
{
[Link]=75;
[Link]=90.25;
fun(a);
}
Output
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.
{
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 ( ).
#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
struct student
{
int id;
char name[20];
float percentage;
};
void main()
{
struct student record;
[Link]=1;
strcpy([Link], "Raju");
[Link] = 86.5;
func(record);
getch();
}
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
struct student
{
int id;
char name[20];
float percentage;
};
void main()
{
struct student record;
[Link]=1;
strcpy([Link], "Raju");
[Link] = 86.5;
func(&record);
getch();
}
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.
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
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.
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
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.
union student
{
char name[20];
char subject[20];
float percentage;
};
int main()
{
union student record1;
union student record2;
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:
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.
int main()
{
strcpy([Link], "Raju");
strcpy([Link], "Maths");
[Link] = 86.50;
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
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( )
(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?
as ______.
c. The array char name [10] can consist of a maximum of ______ characters.