[go: up one dir, main page]

0% found this document useful (0 votes)
25 views47 pages

BPOPS103/203 Module 1 Notes

The document provides an overview of computers, including their definition, characteristics, and the stored program concept introduced by John von Neumann. It outlines the five generations of computers, detailing their features, advantages, and disadvantages, as well as classifications of computers such as supercomputers, mainframe computers, minicomputers, and microcomputers. Additionally, it highlights the evolution of technology from vacuum tubes to microprocessors and the emergence of artificial intelligence in the fifth generation.

Uploaded by

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

BPOPS103/203 Module 1 Notes

The document provides an overview of computers, including their definition, characteristics, and the stored program concept introduced by John von Neumann. It outlines the five generations of computers, detailing their features, advantages, and disadvantages, as well as classifications of computers such as supercomputers, mainframe computers, minicomputers, and microcomputers. Additionally, it highlights the evolution of technology from vacuum tubes to microprocessors and the emergence of artificial intelligence in the fifth generation.

Uploaded by

Hamza Hafeel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Module-1

Introduction to C
Definition of Computer:
A computer, in simple terms, can be defined as an electronic device that is designed to accept data, perform
the required mathematical and logical operations at high speed, and output the result
OR
Computer is an electronic device which takes input from the user in the form of data and instructions and the
data is processed according to instruction given by the user and gives result as output.
A computer performs the following tasks:
a) Input: Sending the data and command to the computer is known as input.
b) Processing: Work done by the computer with the help of hardware and software to produce results is
known as processing.
c) Output: The result displayed by the computer is known as output.
d) Storage: A place to save result inside or outside the computer is known as storage.

Characteristics of Computer: Following are the characteristics of computer.


• Speed
• Accuracy
• Memory
• No IQ
• Economical
• Automation
• Diligence
• Versatility

Speed: Computers can perform millions of operations per second .The speed of computers is usually given in
nanoseconds and picoseconds, where 1 nanosecond = 1 × 10-9 seconds and 1 picosecond = 1 × 10 -12 seconds.
Accuracy: A computer is a very fast, reliable, and robust electronic device. It always gives accurate results,
provided the correct data and set of instructions are input to it.
Memory: Computer can stored large amount of data and programs in the secondary storage space like (CD,
Floppy, DVD, Hard Disk and pen drives). When data and programs have to be used, they are copied from the
secondary memory into the internal memory, often known as random access memory (RAM).

Notes Prepared by Sayeesh, Dept. of CSE, YIT


No IQ: Computers do not have any decision-making abilities of their own. They need guidance to perform
various tasks.
Economical: Computer reduces manpower requirements and leads to an elegant and efficient way of
performing various tasks and computers save time, energy, and money. When compared to other systems,
computers can do more work in lesser time.
Automation: Computer apart from being very fast and accurate, computers are automatable devices that can
perform a task without any user intervention. The user just needs to assign the task to the computer, after
which it automatically controls different devices attached to it and executes the program instructions.
Diligence: Unlike humans, computers never get tired of a repetitive task. It can continually work for hours
without creating errors. Even if a large number of executions need to be executed, each and every execution
requires the same duration, and is executed with the same accuracy.
Versatility: Computers are versatile devices as they can perform multiple tasks of different nature at the
same time. Example the PC that we use at home can be used to play a game, compose and send e-mail and
listen to the music.

Stored Program Concept: Sir John von Neumann in late 1940s introduced the stroed program concept.
The following are the key characteristic features of this concept:
• Before any data is processed, instructions are read into memory.
• Instructions are stored in the computer‟s memory for execution.
• Instructions are stored in binary form (using binary numbers - 0s and 1s).
• Processing starts with the first instruction in the program, which is copied into a control unit circuit.
The control unit executes the instructions.
• Instructions written by the users are performed sequentially until there is a break in the current flow.
• Input/ Output and processing operations are performed simultaneously. While data is being read/
written, the central processing unit (CPU) executes another program in the memory that is ready for
execution.

Following are the types of Stored Program Computers based on Von Neumann architecture
1. Shared memory for instructions and data

• Shared Memory for instructions and data: In this type of machine instructions and data are selected
one at a time. Data and instructions are transferred to and from memory through a shared data bus.
Since there is a single bus to carry data and instructions, process execution becomes slower.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


2. Separate memory for instructions and data

• Separate Memory for instructions and data: In this type of machine Instructions are selected serially
from the instruction memory and executed in the processor. When an instruction needs data, it is
selected from the data memory. Since there are separate memories, execution becomes faster.

Computer Generations:
Five Generations of Modern Computer:
The five generations of modern computers can be classified as follows:
Generation Period Based on Other features
First 1941-1956 Vacuum Tubes Magnetic drums for memory
Second 1956-1963 Transistors Magnetic cores, disks, punched cards and
printouts
Third 1964-1971 Integrated Circuits (ICs) Keyboard, monitor and operating system
Fourth 1972- 2010 Microprocessors Networking
Fifth 2010-Present ULSI Nano Technology Mainly unclear

First Generation of Computer (1941-1956):


➢ Each computer contains a different binary- coded program known as machine language that‟s
helps the computer to operate. Program input was provided by punched cards and output was
obtained on paper.
➢ Due to this the computer performance limited its versatility and speed.
➢ The first generation computers used thousands of vacuum tubes for computation.
➢ Because of vacuum tubes, first generations computers took up a lot of space and also they
consumed huge amount of power and generated lot of heat.
➢ Magnetic drums were used for the purpose of data storage.
➢ The major contribution in the first generation computer was the invention of Electronic Numerical
Integrator and Calculator (ENIAC). The ENIAC used 18,000 vacuum tubes occupied 1800 square
feet of room space and consumed 180 KW of power.
➢ Then comes the Electronic Discrete Variable Automatic Computer (EDVAC) developed by John
Von Neumann that contains memory to hold both stored program and data. The stored memory
and the conditional control transfer technique provided versatility in computer programming that
allows the computer to be stopped and then resumed.
➢ Machines of this generation were prohibitively expensive to buy and maintain. So that these
machines were only used for scientific work and were not deployed commercially.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Advantage:
• They were the fastest calculating devices of their time.
Disadvantages:
• They generated a lot of heat.
• They consumed a lot of electricity.
• They were very bulky in size.
• Vacuum tubes used filaments that had limited life. Since every computer used thousands
of vacuum tubes, there computers were frequently down due to hardware failure.
• These computers needed constant maintenance because of the low meant time between
failures.
• These computers had limited commercial use because they were difficult to program.
• They were very expensive.

Second Generation Computer (1956 – 1963):


➢ In second generation of computers use of transistor replaces vacuum tubes. Due to use of
transistors, the computers became small, fast and precise in making calculations and consume less
electricity.
➢ Second generation computers also comprised of printers, primary memory, storage media to save
documents and retrieve later on and operating system.
➢ Computers of second generations were programmed with assembly language instead of machine
language.
➢ The commercially successful second generation computers were used in business and universities.
➢ The use of stored program and programming language transferred computer as flexible, cost
effective and productive for business use. The stored program refers to instruction that run on a
computer for a specific function or program is stored inside the computer‟s memory.
➢ The languages such as COBOL, FORTRAN, ALGOL and SNOBOL came into use during second
generation.
Advantages:
• They consumed less electricity and thus generated less heat as compared to the first-
generation computers.
• They were faster, cheaper, smaller and more reliable than their first generation counterparts.
• They could be programmed using assembly language and high-level language.
• These computers had faster primary memory and a larger secondary memory.
Disadvantage:
• Second-generation computers were manufactured using transistors, which had to be assembled
manually. This made commercial production of computers difficult and expensive.

Third Generation Computer (1964-1971):


➢ Integrated Circuit (IC) was developed in third generation of computer. Computer speed and
efficiency got a sharp boost with the development of IC.
➢ By virtue of contraction, computers consequently got smaller, cheaper and energy efficient.
For these reasons, they could be seen in several medium sized organizations.
➢ This generation adopted a keyboard and monitor to interact with the user.
➢ Memory capacity increased substantially and the magnetic hard disk was used for secondary
storage.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


➢ The 3rd generation computer made use of an operating system. It allowed machines to run
different programs simultaneously with a central program that monitor programs.
➢ By virtue of a feature known as time sharing, the computer could run programs invoked by
multiple users.
➢ On the software front, high-level programming languages such as COBOL and FORTRAN
were standardized by the American National Standard Institute (ANSI) and were known as
ANSI COBOL and ANSI FORTRAN respectively. Standardization helped these languages to
run on any computer that had their respective compiler.
➢ In addition to this, some more high-level programming languages such as PL/I, PASCAL and
BASIC were introduced at this time.

Advantages:
• They were faster than second-generation computers and could perform one million
transactions per second.
• They were smaller, cheaper and more reliable than their predecessors.
• These computers had faster and larger primary memory and secondary storage.
• Third-generation computers were widely used for scientific as well as business applications.
• During this generation of computers, standardization of existing high-level languages and
invention of new high-level languages happened.
• Third-generation computers could run time sharing operating systems, which allowed
interactive use of a computer by one or more users simultaneously, thereby improving the
productivity of the users.
Disadvantages:
• These computers were difficult to maintain.
• They got heated very quickly.

Fourth Generation Computer (1972 –2010):


➢ The major contribution by the 4th generation of computers came up in 1971, when Intel a
major chip manufacturer came up with its own chip known as 4004. This chip was step ahead
of IC as it brings central processing unit, memory and input and output controls a single chip.
At present, one microprocessor could be programmed to meet any number of requirements.
➢ Microprocessors have invaded our homes to drive desktops, laptops, smartphones, microwave
ovens and washing machines.
➢ In 1981, IBM launched Personal Computer (PC) to use in homes, offices and schools and
other hand Macintosh computer introduced an operating system to help users to move screen
icons instead of typing instructions.
➢ Laptops and smartphones offer gigabytes (GB) of memory compared to a few megabytes
(MB) that were available in the early days of this generation.
➢ Operating systems have moved from basic MS-DOS to a mouse based Graphical User
Interface (GUI) like Windows. More advanced systems like Linux are now available for
desktops and laptops and a variant of it (Android) powers most of our smartphones.
➢ There have been other sweeping changes in this generation. Laptops and smartphones offer
fourth generations languages (4GLs), which resemble natural languages, have also come into
being.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


➢ This generation has also made a rapid strides in networking technology, sharing of
information, became possible by connecting computers in a network using TCP/IP
technology.

Advantages:
• These computers were smaller, cheaper, faster and more reliable than their predecessors.
• They consumed less electricity and generated less heat.
• They had faster and larger primary memory and secondary storage.
• They could be used as general-purpose computers.
• GUIs enabled people to learn to work with computers very easily. Hence, the use of
computers both in offices and at homes became widespread.
• Networks allowed sharing of resources, thereby enabling efficient utilization of computer
hardware and software.
Disadvantage:
• They were not intelligent systems.

Fifth Generation (2010-Present):


➢ Fifth generation computers are difficult to define as they are only in the minds of advance
research scientists and being tested out in laboratories.
➢ The major contribution was of the 5th generation is artificial intelligence.
➢ The computers of fifth generations are capable of recognizing speech, translate foreign
language, assist doctors in making diagnoses by applying the problem solving steps which a
doctor might use in assessing the patient‟s needs, etc.
➢ The fifth generation represents a vision of the computers of the future. The conventional
parameters of computing (speed, size, energy consumption, VLSI to ULSI etc.) would
continue to improve path-breaking changes in the way we use computers are also expected.
➢ This generation computer should be capable of producing human like behaviour. These
systems expected to interact with users in natural language and learn from experience. Speech
recognition and speech output should also be possible with these systems.
➢ Computer speeds need to make an exponential jump, a feat that would be possible using
quantum computers. Google‟s D-Wave 2X quantum computer is 100 million times faster than
today‟s machines.
➢ Computers must be able to perform parallel processing so that multiple processors
concurrently handle different aspects of a problem.
➢ Neural networks and expert systems have to be deployed. These applications would be able to
make decisions and advise humans by analysing data using human like intelligence but
without using the services of expert.
➢ Other possibly disruptive technologies like molecular computing that could take reduction to
molecular level.
Classification of Computers:
Computers can be broadly classified into four categories based on their speed, amount of data they
can hold and price. These categories are as follows:
• Supercomputers
• Mainframe computers
• Minicomputers
• Microcomputers

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Classification of computers

Supercomputers Mainframe computers Minicomputers Microcomputers

Dumb terminals Intelligent terminals Desktop PC Laptops Handheld devices

Workstations Network

Supercomputers:
➢ Among the four categories, the supercomputer is the fastest, most powerful and most expensive
computer.
➢ Supercomputers were first developed in the 1980s to process large amounts of data and to solve
complex scientific problems.
➢ Super computers use multiple CPUs for parallel processing technology and can perform more than
one trillion calculations in a second.
➢ A single supercomputer can support thousands of users at the same time. Such computers are mainly
used for weather forecasting, nuclear energy research, aircraft design, automotive design, online
banking, controlling industrial units etc. They are also used to solve complex scientific problems.
➢ Supercomputers have enormous storage, with huge amounts of power and generate a lot of heat.
➢ Because of their exorbitant cost, they are mainly used by government agencies.
➢ Some examples of supercomputers are CRAY-1, CRAY-2, Control Data CYBER 205, and ETAA-10.

Mainframe Computers:
➢ Mainframe computers are large-scale computes (but smaller than supercomputers)
➢ These are very expensive and need a very large clean room with air conditioning, thereby making
them very costly to deploy.
➢ As with supercomputers, mainframes can also support multiple processors. They are multi-user
machines that can support hundreds or thousands of users using the features of time sharing supported
by systems like Linux. For example, the IBM S/390 mainframe can support 50,000 users at the same
time.
➢ Users interact with this system using terminal and keyboard, which is akin to the way we use PCs.
➢ Mainframes can concurrently run multiple programs even with a single CPU.
➢ The processor speed in a mainframe is measured in MIP (Million Instructions per Second).
➢ Mainframes are generally used to handle data and applications related to the organization as whole.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


➢ The mainframes are employed to handle online transactions( for example- stock exchange
transactions)
➢ The capability to handle large amounts of data makes the mainframe suitable for use in government,
bank and financial institutions and large corporations.
➢ Mainframe computers are typically used as servers on the World Wide Web. They are also used in
large organizations such as banks, airline companies and universities where a large number of users
frequently access the data stored in their databases.
➢ IBM is the major manufacturer of mainframe computers. Some example of mainframe computers
includes IBM S/390, Control Data CYBER 176, Amdahl 580 etc.
➢ Users can access mainframes by either using terminals or via PCs. There are basically two types of
terminals that can be used with mainframe systems. These are:
• Dumb Terminals:
Dumb terminals consist of only a monitor and a keyboard (or mouse). They do not have their
own CPU and memory and use mainframe system‟s CPU and storage devices.
• Intelligent Terminals:
In contrast to dumb terminals, intelligent terminals have their own processor and thus can
perform some processing operations. However, just like the dumb terminals, they do not have
their own storage space. Usually, PCs can be used as intelligent terminals to facilitate data
access and other services from the mainframe system.
Minicomputers:
➢ As the name suggests, minicomputers are smaller, cheaper, and slower than mainframes. They are
called minicomputers because they were the smallest computer of their time.
➢ Also known as midrange computers, the capabilities of minicomputers fall between mainframe and
PCs.
➢ Minicomputers are widely used in business, education, hospitals, government organizations etc.
➢ While some minicomputers can be used only by a single user, others are specifically designed to
handle multiple users simultaneously.
➢ Usually, single-user minicomputers are used for performing complex design tasks.
➢ As with mainframes, minicomputers can also be used as servers in a network environment and
hundreds of PCs can be connected to it.
➢ The first minicomputer was introduced by Digital Equipment Corporation (DEC) in the mid-1960s.
Other manufacturers of minicomputers include IBM Corporation (AS/400 computers), Data General
Corporation and Prime Computer.

Microcomputers:
➢ Microcomputers, commonly known as PCs, are very small and cheap.
➢ The first microcomputer was designed by IBM in 1981 and was name IBM-PC. Later on, many
computer hardware companies copied this design and termed their microcomputers as PC-compatible,
which refers to any PC that is based on the original IBM PC design.
➢ Another type of popular PC is designed by Apple. PCs designed by IBM and other PC-compatible
computers have a different architecture from that of Apple computers. Moreover, PCs and PC-
compatible computers commonly use the Windows operating system, while Apple computers use the
Macintosh operating system (MacOS). However, IBM and IBM-compatible PC are more popular
than their Apple counterparts.
➢ This computer is a single-user machine powered by a single microprocessor. Today‟s PCs are very
powerful machines having gigabytes or terabytes of memory or two of disk storage.
➢ They are used both in the standalone mode (at home) and in a network (office).

Notes Prepared by Sayeesh, Dept. of CSE, YIT


➢ Business and individuals use the PC for word processing, spread sheet handling and desktop
publishing. PCs also support Internet browsing software like Firefox and Google Chrome.
➢ All PCs are multimedia ready, they can handle images, audio and video files.
➢ PCs can be classified into the following categories:
• Desktop PCs
• Laptops
• Handheld Computers
• Workstations
• Network Computers

Desktop PCs:
A desktop PC is the most popular model of PCs. The system unit of the desktop PC can be placed flat
on a desk or table. It is widely used in homes and offices.

Laptops:
Laptops are small microcomputers that can easily fit inside a briefcase. They are very handy and can
easily be carried from one place to another. They may also be placed on the user‟s lap (thus the name).
Hence, laptops are very useful, especially when going on long journeys. Laptops operate on a special battery
and do not always have to be plugged in like desktop computers.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Handheld Computers:
• The mid-1990s witnessed a range of small personal computing devices that are commonly known as
handheld computers, or mobile computers.
• These computers are called handheld computers because they can fit in one hand, while users can use
the other hand to operate them.
• Handheld computers are very small in size, and hence they have small-sized screens and keyboards.
• These computers are preferred by business travellers and mobile employees whose jobs require them
to move from place to place.
• Some examples of handheld computers are as follows:
• Smartphones
• Tablet PCs
Smartphones:
• These days, cellular phones are web-enabled telephones. Such phones are also known as
smartphones because, in addition to basic phone capabilities, they also facilitate the users to access
the Internet and send e-mails, edit Word documents, generate an Excel sheet, create a presentation
and lots more.
• Smartphones run an advanced mobile operating system that enables it to run various applications.
• The four major mobile operating systems are iOS, Android, BlackBerryOS, and Windows Mobile.
• Smartphones also have a CPU, more storage space, more memory, and a larger screen than a regular
cell phone. In a nutshell, smartphone refers to a multi-functional mobile phone handset that packs in
varied functionalities from a camera to a web browser to a high-density display.

Tablet PCs:
• A tablet PC is a computing device that is smaller than a laptop, but bigger than a smartphone.
• Features such as user-friendly interface, portability, and touch screen have made them very popular
in the last few years.
• These days, a wide range of high-performance tablets are available in the market. While all of them
look similar from outside, they may differ in features such as operating system, speed of data

Notes Prepared by Sayeesh, Dept. of CSE, YIT


connectivity, camera specifications, size of the screen, processing power, battery life, and storage
capability.
• Some operating systems that are used in tablets are Android Jellybean (an open-source operating
system built by Google), Windows 8, and iOS (developed by Apple).
• Each operating system has its own advantages and disadvantages and a proprietary app store, from
which users can download applications, extending the tablet‟s functionality. These apps range from
games to specialized word processors and even instruments.
• While users can easily type directly on the surface of a tablet, some users prefer a wireless or
Bluetooth-connected keyboard. These days, tablets also offer an optional docking station with
keyboards that transforms the tablet into a full-featured netbook.
Uses:
The following are the uses of Tablet PCs:
• View presentations
• Videoconferencing
• Reading e-books, e-newspaper
• Watching movies
• Playing games
• Sharing pictures, video, songs, documents, etc.
• Browsing the Internet
• Keeping in touch with friends and family on popular social networks, sending emails
• Business people use them to perform tasks such as editing a document, exchanging documents, taking
notes, and giving presentations
• Tablets are best used in crowded places such as airports and coffee shops, where size and portability
become more important.

Workstations:
• Workstations are single-user computers that have the same features as PCs, but their processing
speed matches that of a minicomputer or mainframe computer.
• Workstation computers have advanced processors, more RAM and storage capacity than PCs.
Therefore, they are more expensive and powerful than a normal desktop computer.
• Although workstation computers are widely used as powerful single-user computers by scientists,
engineers, architects, and graphic designers, they can also be used as servers in a networked
environment.
Network Computers:
• Network computers have less processing power, memory, and storage than a desktop computer.
These are specially designed to be used as terminals in a networked environment. For example,

Notes Prepared by Sayeesh, Dept. of CSE, YIT


some network computers are specifically designed to access data stored on a network (including
the Internet and intranet).
• Some network computers do not have any storage space and merely rely on the network‟s server
for data storage and processing tasks. The concept of network computers had become popular in
the mid-1990s when several variations of computers such as Windows terminals, NetPCs, and
diskless workstations were widely used.
• Network computers that are specifically designed to access only the Internet or intranet are often
known as Internet PCs or Internet boxes. Some network computers used in homes do not even
have a monitor.
• Such computers may be connected to a television, which serves as the output device. The most
common example of a home-based network computer is Web TV, which enables the user to
connect a television to the Internet.
• The Web TV is equipped with a special set-top box that is used to connect to the Internet. The
set-top box also provides controls to enable the user to navigate the Internet, send and receive e-
mails, and to perform other tasks on the network while watching television.
• The other reason for the popularity of network computers is that they are cheaper to purchase and
maintain than PCs.

Applications of Computers:
Computers are used in various fields:
• Word processing: This software enables users to read and write the documents and insert the
images, tables and graphs for illustrating the concepts.
• Internet: The Internet is a network of networks that connects computers all over the world. It
gives the user access to an enormous amount of information, much more than available in any
library.
• Digital video or audio composition: Computers make audio or video composition and editing
very simple. This has drastically reduced the cost of equipment to compose music or make a film.
• Desktop Publishing: Desktop publishing software enables us to create page layouts for entire
books.
• E-Business: e-Business or electronic business is the process of conducting business via the
Internet. This may include buying and selling of goods and services using computers and the
Internet.
• Health Care: In Health care system computers are used to store the records, surgical procedures
and for Better diagnosis and treatment.
• Geographic's and Information System and Remote Sensing: A geographic information
system (GIS) is a computer- based tool for mapping and analyzing earth‟s features. It integrates
database operations and statistical analysis to be used with maps. GIS manages location- based
information and provides tools for display and analysis of statistics such as population count,
types of vegetation, and economic development opportunities. Remote sensing is the science of
taking measurements of the earth using sensors on airplanes or satellites. These sensors collect
data in the form of images, which are then analyzed to derive useful information.
• Multimedia and Animation : Using animation software, we can reproduce real- world
phenomena such as fire, smoke, fluids, movement of chemicals through the air and ground, and
the respiratory system to name a few.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


• Education System: A computer is a powerful teaching aid and can act as another teacher in the
classroom. Teachers use computers to develop instructional material. Teachers may use pictures,
graphs, and graphical presentations to easily illustrate an otherwise difficult concept.
• Retail System: Computers are used in retail shops to enter orders, calculate
costs, and print receipts. They are also used to keep an inventory of the products available and
their complete descriptions.
• Travel and Tourism: Computers are used to prepare tickets, monitor the train‟s
or airplane‟s route, and guide the plane to a safe landing. They are also used to research about
hotels in an area, reserve rooms, or to rent a car.
• Decision Support System: Computers help managers to analyses their organization‟s data to
understand the present scenario of their business, view the trends in the market, and predict the
future of their products.
Basic Organization of a Computer:
A computer is an electronic device that performs five major operations:
• Accepting data or instructions (input)
• Storing data
• Processing data
• Displaying results (output)
• Controlling and coordinating all operations inside a computer

The following figure shows the interaction between the different units of a computer system:

Input: This is the process of entering data and instructions (also known as programs) into the computer
system. The data and instructions can be entered by using different input devices such as keyboard, mouse,
scanner, and trackball. Note that computers understand binary language, which consists of only two symbols
(0 and 1), so it is the responsibility of the input devices to convert the input data into binary codes.
Storage: Storage is the process of saving data and instructions permanently in the computer so that they can
be used for processing. The computer storage space not only stores the data and programs that operate on that
data but also stores the intermediate results and the final results of processing.
A computer has two types of storage areas:

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Primary storage: Primary storage, also known as the main memory, is the storage area that is directly
accessible by the CPU at very high speeds. It is used to store the data and parts of programs, the intermediate
results of processing, and the recently generated results of jobs that are currently being worked on by the
computer. Primary storage space is very expensive and therefore limited in capacity. Another drawback of
main memory is that it is volatile in nature; that is, as soon as the computer is switched off, the information
stored gets erased. Hence, it cannot be used as a permanent storage of useful data and programs for future
use. An example of primary storage is random access memory (RAM).
Secondary storage: Also known as auxiliary memory, this memory is just the opposite of primary memory.
It overcomes all the drawbacks of the primary storage area. It is cheaper, non-volatile, and used to
permanently store data and programs of those jobs that are not being currently executed by the CPU.
Secondary memory supplements the limited storage capacity of the primary memory. An example is the
magnetic disk used to store data, such as C and D drives, for future use.
Output: Output is the process of giving the result of data processing to the outside world (external to the
computer system). The results are given through output devices such as monitor, and printer. Since the
computer accepts data only in binary form and the result of processing is also in binary form, the result
cannot be directly given to the user.
The output devices, therefore, convert the results available in binary codes into a human-readable language
before displaying it to the user.
Control: The control unit (CU) is the central nervous system of the entire computer system. It manages and
controls all the components of the computer system. It is the CU that decides the manner in which
instructions will be executed and operations performed. It takes care of the step-by-step processing of all
operations that are performed in the computer. Note that the CPU is a combination of the arithmetic logic
unit (ALU) and the CU. The CPU is better known as the brain of the computer system because the entire
processing of data is done in the ALU, and the CU activates and monitors the operations of other units (such
as input, output, and storage) of the computer system.
Processing: The process of performing operations on the data as per the instructions specified by the user
(program) is called processing. Data and instructions are taken from the primary memory and transferred to
the ALU, which performs all sorts of calculations. The intermediate results of processing may be stored in
the main memory, as they might be required again. When the processing completes, the final result is then
transferred to the main memory. Hence, the data may move from main memory to the ALU multiple times
before the processing is over.

Inside the Computer:

Notes Prepared by Sayeesh, Dept. of CSE, YIT


The following are some of the major parts of the computer:
CPU: The CPU is the brain of the computer. It performs all calculations and controls the devices connected
to the computer system. The faster the CPU, the quicker programs can process the instructions.
RAM: A fast CPU is of no use if the computer does not have sufficient RAM. As discussed earlier, RAM is
the computer‟s memory which stores information used by applications that are currently being executed by
the CPU. More memory means more applications can be executed at the same time without degrading the
system‟s performance.
Hard disk drive (HDD): The HDD of the computer is the secondary memory of the computer system where
information is stored permanently. All types of data, documents, and programs are stored on the hard disk.
The larger the hard disk, the more the amount of data that can be stored on the drive. Though the size of the
HDD does not affect the speed of execution of the program, it does affect the speed at which the user can
access his/her files.
Video card: The video card is a board that plugs into the motherboard of the computer and generates images
for display. Many video cards these days have their own RAM and processor to enhance the speed of the
graphics display. Many computers come with an in-built video chip. In such a computer, a separate video
card is used only if the computer has to be used for high-end multimedia work or to play video games.
Sound card: As with video cards, sound cards are expansion boards that are used to enable a computer to
manipulate sound. For example, sound cards allow the users to plug in speakers and a microphone. Some
sound cards also provide the jacks for hooking your computer up to a common stereo. These days, many
computers come with a built-in sound chip, which makes it unnecessary to buy a separate card unless a
higher quality of sound is needed.
Modem: A modem (modulator–demodulator) is a device that enables the computer to use a telephone line to
communicate and connect to the Internet.
Network card: A network card is used to connect the computer either to other computers or to the Internet
(in case you are using a fast Internet connection such as cable or DSL).
Fans: There are one or more fans inside the computer to keep the air moving and the computer cool.
Cables: There are multiple wires inside the computer that are flat, ribbon-like cables. They are used to
provide power and communication to the various parts inside the computer.

Motherboard:
The motherboard, also known as the mainboard or the parent board is the primary component of a computer.
It is used to connect all the components of the computer. The motherboard is a printed circuit that has
connectors for expansion cards, memory modules, the processor, etc.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Characteristics of a Motherboard
A motherboard can be classified depending on the following characteristics:
• Form factor
• Chipset
• Type of processor socket used
• Input–Output connectors
Form factor: Form factor refers to the motherboard‟s geometry, dimensions, arrangement, and electrical
requirements. The industry has defined a few standards for the form factors, so that they can be used in
different brands of cases.
Integrated components: Some of the motherboard‟s components are integrated into its printed circuitry.
These include the following:
• The chipset is a circuit that controls the majority of the computer‟s resources such as the bus interface with
the processor, cache memory, RAM, and expansion cards.
• CMOS clock and battery
• BIOS
• System bus and expansion bus
In addition to these, the latest motherboards also have a number of onboard multimedia and networking
devices (which can be disabled), such as integrated network card, integrated graphics card, integrated sound
card, and upgraded hard drive controllers.
Chipset: The chipset is an electronic circuit that basically coordinates data transfers between the different
components of the computer (such as the processor and memory). In order to enhance the computer‟s
upgradeability, one must choose a motherboard that has the latest chipset integrated in it. Some chipsets may
include a graphics or audio chip, which makes it unnecessary to install a separate graphics card or sound
card. However, in case you need very high quality of audio and visual capabilities, then you must disable the
graphics/audio chip in the BIOS setup and install high-quality expansion cards in the appropriate slots.
CMOS clock and battery: The real-time clock (or RTC) is a circuit that is used to synchronize the
computer‟s signals. When the computer is switched off, the power supply stops providing electricity to the
motherboard. You must have observed that when we turn on the system, it always displays the correct time.
This is because an electronic circuit, called the complementary metal oxide semiconductor (CMOS) chip,
saves some system information, such as the time, date, and other essential system settings. The CMOS chip is
powered by a battery located on the motherboard. Information on the hardware installed in the computer
(such as the number of tracks or sectors on each hard drive) is stored in the CMOS chip. Since the CMOS
chip is quite slow, some systems prefer to copy the CMOS chip‟s content into the RAM, which is a
comparatively faster storage. This process of copying data into RAM is better known as memory shadow.
Have you noticed that, at times, the system time gets reset automatically, or the clock runs late? This
indicates that you need to change the battery.
BIOS: The basic input/output system (BIOS) is an interface between the operating system and the
motherboard.
The BIOS is stored in the read-only memory (ROM), which cannot be rewritten. The BIOS uses data stored
in the CMOS chip to know about the system‟s hardware configuration. To configure the BIOS, the user can
use an interface known as BIOS setup, which can be accessed when the computer is booting. To enter BIOS
setup, the user must press the DEL key. F1 and F2 keys can also be used.
Processor socket: The processor (also called the microprocessor) is the brain of the computer. The processor
is characterized by its speed or frequency, which is the rate at which it executes instructions. For example, an
800-MHz processor can perform 800 million operations per second. The slot on the motherboard into which
the processor is inserted is called the processor socket or slot . Irrespective of whether you use a slot or a
socket, you must gently insert the processor; so that none of its pins are bent (it has hundreds of them).

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Usually, a concept called zero insertion force (ZIF) is used. The ZIF sockets allow the processor to be
inserted very gently and easily.
When the computer is on, the processor is working and it releases heat, which must be dissipated to keep the
circuits from melting. Therefore, the processor is generally mounted on a cooler that is made of metal (such
as copper or aluminum), which conducts heat well. In addition to the cooler, there is also a fan to improve air
circulation around it and to improve the heat transfer. The fan vents hot air from the case and lets fresh air
come in from outside.
RAM connectors: RAM is the primary storage area that stores data while the computer is running. However,
its contents are erased when the computer is turned off or restarted. While the hard disk can store data
permanently, we still need RAM because it is extremely fast when compared to mass storage devices such as
hard drives. Therefore, the fast processor accesses data from RAM and not from the hard disk. The data is
transferred from the hard disk to the RAM, from where it is used by the processor. RAM is available in the
form of modules that plug into motherboard connectors.
Expansion slots: Expansion slots are compartments into which expansion cards can be inserted. Such cards
render new features or enhance the computer‟s performance. For example, the AGP slot (also known as
Accelerated Graphic Port) is a fast port used for graphics cards.

I/O connectors: The motherboard has a number of input–output sockets on its rear panel, some of which
include:
• A serial port to connect some old peripherals
• A parallel port to connect old printers
• USB ports to connect more recent peripherals such as mouse and pen drive.
• RJ45 connector (also known as LAN or Ethernet port) to connect the computer to a network. It corresponds
to a network card integrated into the motherboard.
• Video graphics array (VGA) connector to connect a monitor. This connector interfaces with the built-in
graphics card.
• Audio plugs that include the line in, line out, and microphone to connect sound speakers, hi-fi system, or
microphone. This connector interfaces with the built-in sound card.

Input Devices
Keyboard: A keyboard looks like a typewriter. The keyboard that we use is also known as QWERT
keyboard. Various keys present on the keyboard are:
1. Typewriter keys: Includes letters, numbers and punctuation symbols
2. Function Keys: Includes keys labeled F1 to F12 located at the top end of the keyboard. The
functions they perform depend on the software that they use.
3. Cursor control keys: Appears as left , right, down, Up arrows keys which allows you to move the
cursor to the left, right , down and up in the screen.
Notes Prepared by Sayeesh, Dept. of CSE, YIT
4. Numeric keys: Appears just below the function keys along with special characters printed on the
topside. Also the right hand side of the keyboard contains the numeric key pad. When NUM-LOCK key
is ON, the key „7‟ prints 7. When it is OFF, key „7‟ acts like Home key.
5. Page Up and Page Down keys: Allows you to move to the preceding and next pages of the document,
respectively.
6. Home and End keys: Allows you to move cursor to the top and end of the document line or window
respectively.
7. Caps Lock key: Allows you to type text in upper case.
8. Shift key: Allows you to type text in uppercase. Holding the shift down and pressing a letter key
creates an upper case letter. However if caps lock is ON, then this effect is reversed.
9. Ctrl and Alt keys: Select a text, press ctrl + c does copy action. This is example for ctrl + alt
10. Enter Key: Allows you to start processing the data.
11. Tab key: It lets you indent paragraphs and helps you to move from one option to another in a menu.
12. Esc (Escape) Key: Allows you to cancel or ignore the entry or command that you have just entered in
an application.
13. Delete and Backspace keys: Delete key erases a space or character that is placed to the right side of
the blinking cursor. Backspace key erases the character to the left side of the blinking cursor.

Pointing Device- Mouse:


A mouse is a basic input device of a computer that controls the moment of the cursor or pointer on the
display screen. The mouse is particularly useful in a Graphical User Interface (GUI) where you can point to
an option or object on the screen and click the appropriate mouse button. We can draw picture or objects on
the screen by using the mouse as a pencil or paintbrush. A mouse contains two or three buttons. Each of these
three buttons performs a different function. Nowadays, the mouse also contains a scroll button, which allows
you to scroll up or down a document, thereby allowing you to read lengthy document easily.
Using a Mouse: Before we use a mouse, ensure that it is placed on a flat surface so that we can move it
easily. We can get a firm grip of the mouse by keeping it on a rectangular pad. This also allows us to move
the smoothly. The rectangular pad is known as a mouse pad. The left mouse button is the primary button of
the mouse. It performs two of the most important actions:
❑ Click: Pressing the left mouse button
❑ Double- click: Pressing the left mouse button two times consecutively.
A single click is used to highlight or click the icons or menu options, while a double-click is used to open
programs and icons. The mouse button on the right is used to open short cut menu.
Types of mouse devices:
There are different types of mouse devices available in the market.
The following are some of the most common once:
• Mechanical mouse
• Optomechanical mouse

Notes Prepared by Sayeesh, Dept. of CSE, YIT


• Optical mouse
• Wireless mouse
• TrackBall mouse
• Touchpad

The Scanner: The scanner is a device that can transfer types or handwritten texts, graphs, diagrams and
paragraphs to the computer. Scanner can be used to store photographs and important documents in the
original form.

Inputting Data in other ways:


1. Pen-based systems
2. Data scanning devices
3. Game controllers
4. Voice recognition devices
5. Microphone
6. Visual input devices
Pen based Systems: Pen based systems are normally used by people who do not like to type and who are
frequently on the move. Personal digital Assistants such as Apple Newton acts like notepad, calculator and
calendar. Example: if you write call Jane and wish happy birthday, then Newton adds a line to our To Do list
and links Jane‟s phone number from our telephone directory.
A light pen is used by engineers and architects. It uses a photoelectric (light – sensitive) cell to indicate a
position on the computer screen. We operate it by touching it on screen. Usage is in computer aided
applications (CAD).

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Data scanning Devices:
These systems enable the computer to read data by scanning printed text for recognizable patterns.
Magnetic link character recognition: The “Magnetic ink character recognition” (MICR) is used in banks.
The bank, branch, account number and check number are encoded on the check before it is issued to the
customer. After customer has used the check it comes back to the bank. All that bank needs to manually enter
now is amount.

Bar code reader: Many retail and grocery stores use some form of bar code reader to determine the item
being sold and to retrieve the item price from the computer. The bar code reader reads the Universal Product
Code. Federal Express, a courier delivery company uses a unique bar code to identify and track each
package.

Mark Sense Character Recognition system: In this a OMR (Optical mark reader) which contains bubble
canton form is filled with correct responses in #2 lead pencil. #2 pencil works best because of the number of
magnetic particles in the lead of the pencil. The OMR senses the magnetized marks, enabling the reader to
determine which responses are marked.

Optical Character recognition: This system can even scan types documents, pictures, graphics or even
handwriting into the computer.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Game controllers: While playing a racing video game, a user needs to move the vehicle quickly across the
screen. Although this can be done by pressing the arrow keys on the keyboard, this way is hardly convenient
or comfortable for small children. This type of action can be performed better with the help of joystick

Voice recognition devices: Voice recognition devices are capable of recognizing human voice and used to
execute command. The speech from the user with some keyword is well enough to execute the command.
With development in the field of computer, voice recognition system can be used for security purpose. Voice
recognition system can be digitized to work only when it listens to voice of authorized user or owner of the
system.
Microphone: A microphone is an input device used to record voices and transform the recorded voice into
digital data so that the user can play back or edit the digitized data as required. To convert the voice into
digital data, you need additional hardware known as sound card.

Visual Input Device: Video can be recorded and can be converted into digital data with the help of
computers. Example: digital camera. Digital camera has viewfinder, a lens to focus the image
light sensitive device and a method to store and remove images. Digital photography uses a combination of
advanced image sensor technology and memory storage which allows image to capture in digital format. The
captured images are instantly available to print with no need for a development process.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Output Devices:
Softcopy Devices:
Monitor:
A Computer monitor is an output device that displays the computer‟s user interface and the information
requested by the user. In other words, a monitor is the TV-like part of a computer that displays information.
The term monitor is often used synonymously with the computer screen or display as it displays the
programs, allowing the user to interact with the software.
Types of Monitors: Different types of monitors available in the market. They are classified based on the
technology they use to display both images and text. The following are the two types of monitors:
• Cathode Ray Tube (CRT)
• Liquid Crystal Display (LCD)
CRT Monitor: The CRT monitor is heavy, thick and has a picture tube. It is an economical monitor that is
used in most computers. In the CRT monitor, a beam of electrons strikes the CRT and the collision of
electrons with phosphorus produce light. This type of monitor is useful for displaying images and working
with graphics and photographs in which colours play an important role. CRT monitors are generally available
in flat and curved shapes.

LCD Monitor: An LCD monitor is one of the most widely used flat panel monitors. It is more popular as a
display device compared to a CRT because of its economic power consumption, thinness, and high
resolution. Due to this, it is widely used in digital television, laptops, computers and digital cameras. LCD
monitors take up less desk space and are lighter than CRT monitors.
Nowadays, LCD monitors use the Thin Film Transistor (TFT) technology to display image on the monitor
screen.
TFT is a part of LCD. The main difference between LCD and TFT monitors is that TFT monitor uses a tiny
transistor for each pixel on the display. This allows electrical current illuminating the display to be turned on
and off quickly, which makes the display brighter and the movements smoother. These transistors are used in
the TFT panel.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Data projectors: A projector is an electronic device that is used to display text and images of monitor in
large size on wall. Projectors are ideal in situations where you want to display or share information such as
business conference and while giving lectures to students. The modern data projector uses LCD technology
to display text and images.

Hardcopy Devices:
Printer: A device that prints images, numbers, alphabets and graphs on a sheet of paper is known as printer.
After creating a document on a computer you can send it to a printer for printing its hard copy which is
generally called printout. The speed of the printer is rated by either number of pages per minute or characters
per minute.
Different Types of printers
1. Daisy wheel printer
2. Dot matrix printer
3. Line printer
4. Inkjet printer
5. Laser printer
Understanding Impact and Non-Impact Printer: Impact printers are those printers in which a physical
contact is established between the print head, the cartridge and the media paper.
In non-impact printer, no physical connection is established between the print head and cartridge. Examples
are inkjet and laser printer.
Dot Matrix Printer: The dot matrix printer uses metal pins in its print head to create text and graphics in the
form of dots. An ink soaked ribbon is placed between the paper and the print head
The print head strikes against the ribbon with considerable force and the impact causes an impression of the
text on the paper. Dot matrix printers are ideal for printing multipart documents such as invoices and receipts.
The number of metal pins in the print head of the dot matrix determines the quality of the printout. The

Notes Prepared by Sayeesh, Dept. of CSE, YIT


number of metal pins normally varies from 9 to 24. .Dot matrix printer can be monochrome or color printer.
These types of printers are normally connected to parallel port.

Inkjet Printer: The inkjet printer is more efficient than matrix printer. It has several tiny nozzles that spray
ink onto the paper. Each nozzle is thinner than hair. The print head of the inkjet printer is known print
cartridge. The print cartridge contains nozzle and ink. That‟s why when no more ink is left; entire cartridge
needs to be replaced. An inkjet cartridge has 50 or more nozzles.

Laser printer: The laser printer uses a beam of laser for printing. Laser printer works on the principal of
electro-photography used in a photocopy machine. During the printing process, a laser printer converts the
entire text or image into a raster image which is then processed by raster image processor. This processor
scans the entire page, line by line and stores a bitmap of the page in the memory. The drum inside the laser
printer is then charged negatively and the bitmap is then written on the photosensitive drum by a laser beam.
The toner particles are charged positively. The toner particles will not stick on those regions of the drum
which are not discharged by the laser. The toner contains a plastic powder that is attract to the parts of the
drum where the laser beam hits. Finally, plastic powder is fused at 200 degree Celsius to bind the toner
particles with the paper producing the final printouts.

Plotters: A plotter similar to a printer produces hard copy output. Plotters, which produce high quality color
graphics, are usually categorized based on whether they use pens or electrostatic charges to create images.
Continuous curve plotters are used to draw maps from stored data. Plotters are ideal for engineering, drafting
and many other applications that require intricate graphics.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Sound card and speaker:
Sound cards allow us to listen sound on computer. It also enables you to record sound if you have a
microphone. Speakers are your personal choice. While buying them make sure that they have built amplifier
and are adequately magnetic shielded so that they do not interfere with monitor picture quality. Another type
speaker available is headphone. These are small speakers placed over the ears of the user. Headphones are
connected to the computer through the port present on the front or back of the computer. Nowadays head
phones come with a built in mike. By using mike you can do voices based chatting over internet and hear the
voice as well as speak to your friend simultaneously. A head phone with mike is referred to as headset.

Programming Paradigms:
Monolithic Programming: If, we write an entire program in a single function that is in main function then,
you call it as a monolithic type of programming. But, it is not a good style of writing entire logic in a single
function.
Disadvantages:
The disadvantages of monolithic programming include −
• Program seems to be very large and complex.
• Debugging, testing and maintenance of a program are very difficult.

Procedural Programming: Procedural Programming can be defined as a programming model which is


derived from structured programming, based upon the concept of calling procedure. Procedures, also
known as routines, subroutines or functions, simply consist of a series of computational steps to be carried
out. During a program‟s execution, any given procedure might be called at any point, including by other
procedures or itself.
Languages used in Procedural Programming: FORTRAN, ALGOL, COBOL, BASIC, PASCAL and C
Structured Programming: Structured programming (sometimes known as modular programming) is a
programming paradigm that facilitates the creation of programs with readable code and reusable components.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


All modern programming languages support structured programming, but the mechanisms of support, like
the syntax of the programming languages, varies.
Structured programming encourages dividing an application program into a hierarchy of modules or
autonomous elements, which may, in turn, contain other such elements. Within each element, code may be
further structured using blocks of related logic designed to improve readability and maintainability. These
may include case, which tests a variable against a set of values; Repeat, while and for, which construct loops
that continue until a condition is met. In all structured programming languages, an unconditional transfer of
control, or goto statement, is deprecated and sometimes not even available.
Object-Oriented Programming: Object-oriented programming can be defined as a programming model
which is based upon the concept of objects. Objects contain data in the form of attributes and code in the
form of methods. In object-oriented programming, computer programs are designed using the concept of
objects that interact with the real world. Object-oriented programming languages are various but the most
popular ones are class-based, meaning that objects are instances of classes, which also determine their
types.
Languages used in Object-Oriented Programming: Java, C++, C#, Python, PHP, JavaScript, Ruby, Perl,
Objective-C, Dart, Swift, Scala.

Design and Implementation of Efficient Programs:


The design and development of correct, efficient, and maintainable programs depends on the approach
adopted by the programmer to perform various activities that need to be performed during the development
process. The entire program or software (collection of programs) development process is divided into a
number of phases where each phase performs a well-defined task. Moreover, the output of one phase
provides the input for its subsequent phase. The phases in software development process can be summarized
as below:

Requirements Analysis: In this phase, users‟ expectations are gathered to know why the program/software
has to be built. Then all the gathered requirements are analysed to pen down the scope or the objective of the
overall software product. The last activity in this phase includes documenting every identified requirement of
the users in order to avoid any doubts or uncertainty regarding the functionality of the programs. The
functionality, capability, performance, availability of hardware and software components are all analysed in
this phase.

Design: The requirements documented in the previous phase acts as an input to the design phase. In the
design phase, a plan of actions is made before the actual development process could start. This plan will be

Notes Prepared by Sayeesh, Dept. of CSE, YIT


followed throughout the development process. Moreover, in the design phase the core structure of the
software/program is broken down into modules. The solution of the program is then specified for each
module in the form of algorithms, flowcharts, or pseudocodes. The design phase, therefore, specifies how the
program/software will be built.
Implementation: In this phase, the designed algorithms are converted into program code using any of the
high level languages. The particular choice of language will depend on the type of program like whether it is
a system or an application program. While C is preferred for writing system programs, Visual Basic might be
preferred for writing an application program. The program codes are tested by the programmer to ensure their
correctness. This phase is also called construction or code generation phase as the code of the software is
generated in this phase. While constructing the code, the development team checks whether the software is
compatible with the available hardware and other software components that were mentioned in the
Requirements Specification Document created in the first phase

Testing: In this phase, all the modules are tested together to ensure that the overall system works well as a
whole product. Although individual pieces of codes are already tested by the programmers in the
implementation phase, there is always a chance for bugs to creep in the program when the individual
modules are integrated to form the overall program structure. In this phase, the software is tested using a
large number of varied inputs also known as test data to ensure that the software is working as expected by
the users‟ requirements that were identified in the requirements analysis phase

Software Deployment, Training, and Support: After the code is tested and the software or the program has
been approved by the users, it is then installed or deployed in the production environment. Software Training
and Support is a crucial phase which is often ignored by most of the developers. Program designers and
developers spend a lot of time to create software but if nobody in an organization knows how to use it or fix
up certain problems, then no one would like to use it. Moreover, people are often resistant to change and
avoid venturing into an unfamiliar area, so as a part of the deployment phase, it has become very crucial to
have training classes for the users of the software.

Maintenance: Maintenance and enhancements are ongoing activities which are done to cope with newly
discovered problems or new requirements. Such activities may take a long time to complete as the
requirement may call for addition of new code that does not fit the original design or an extra piece of code
required to fix an unforeseen problem. As a general rule, if the cost of the maintenance phase exceeds 25% of
the prior-phases cost then it clearly indicates that the overall quality of at least one prior phase is poor. In
such cases, it is better to re-build the software (or some modules) before maintenance cost is out of control

Program Design Tools: Algorithms, Flowcharts, Pseudocodes:


Algorithms: In general terms, an algorithm provides a blueprint to writing a program to solve a particular
problem. It is considered to be an effective procedure for solving a problem in a finite number of steps. That
is, a well-defined algorithm always provides an answer, and is guaranteed to terminate. Algorithms are
mainly used to achieve software reuse. Once we have an idea or a blueprint of a solution, we can implement
it in any high-level language, such as C, C++, Java, and so on. In order to qualify as an algorithm, a sequence
of instructions must possess the following characteristics:
• Be precise
• Be unambiguous
• Not even a single instruction must be repeated infinitely
• After the algorithm gets terminated, the desired result must be obtained

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Control Structures used in Algorithms: An algorithm has a finite number of steps and some steps may
involve decision-making and repetition. Broadly speaking, an algorithm can employ any of the three control
structures, namely, sequence, decision, and repetition.
Sequence: Sequence means that each step of the algorithm is executed in the specified order. An algorithm
to add two numbers is given below. This algorithm performs the steps in a purely sequential order
Step 1: START
Step 2: Input two numbers as A and B
Step 3: Calculate sum of two numbers
SUM=A+B
Step 4: PRINT SUM
Step 5: END

Decision: Decision statements are used when the outcome of the process depends on some condition. For
example, if x=y, then print “EQUAL”. Hence, the general form of the if construct can be given as if
condition then process An algorithm to check the equality of two numbers is given below:
Step 1: START
Step 2: Input two numbers as A and B
Step 3: IF A=B Then
PRINT "EQUAL"
ELSE
PRINT "NOT EQUAL"
Step 4: END
Repetition: Repetition, which involves executing one or more steps for a number of times, can be
implemented using constructs such as while, do-while, and for loops. These loops execute one or more steps
until some condition is true. The following algorithm prints the first 10 natural numbers.
Step 1: START
Step 2: Initialization SET I = 0, N = 10
Step 3: Repeat Step while I<=N
PRINT I
I=I+1
Step 4: END
Flowcharts: A flowchart is a graphical or symbolic representation of a process. It is basically used to design
and document virtually complex processes to help the viewers to visualize the logic of the process, so that
they can gain a better understanding of the process and find flaws bottlenecks, and other less obvious features
within it. When designing a flowchart, each step in the process is depicted by a different symbol and is
associated with a short description. The symbols in the flowchart are linked together with arrows to show the
flow of logic in the process.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Symbols of Flowchart
The symbols of a flowchart include:
• Start and end symbols are also known as the terminal symbols and are represented as circles, ovals, or
rounded rectangles. Terminal symbols are always the first and the last symbols in a flowchart.
• Arrows depict the flow of control of the program. They illustrate the exact sequence in which the
instructions are executed.
• Generic processing step, also called as an activity, is represented using a rectangle. Activities include
instructions such as add a to b, save the result. Therefore, a processing symbol represents arithmetic and data
movement instructions. When more than one process has to be executed simultaneously, they can be placed
in the same processing box. However, their execution will be carried out in the order of their appearance.
• Input/output symbols are represented using a parallelogram and are used to get inputs from the users or
display the results to them.
• A conditional or decision symbol is represented using a diamond. It is basically used to depict a Yes/No
question or a True/False test. The two arrows coming out of it, one from the bottom vertex and the other from
the right vertex, correspond to Yes or True, and No or False, respectively. The arrows should always be
labelled. A decision symbol in a flowchart can have more than two arrows, which indicate that a complex
decision is being taken.
• Labelled connectors are represented by an identifying label inside a circle and are used in complex or
multi-sheet diagrams to substitute for arrows. For each label, the „outflow‟ connector must have one or more
„inflow‟ connectors. A pair of identically labelled connectors issued to indicate a continued flow when the
use of lines becomes confusing.
Example for flowchart:

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Pseudocodes: Pseudocode is a compact and informal high-level description of an algorithm that uses the
structural conventions of a programming language. It is basically meant for human reading rather than
machine reading, so it omits the details that are not essential for humans. Such details include variable
declarations, system-specific code, and sub-routines. Pseudocodes are an outline of a program that can be
easily converted into programming statements. They consist of short English phrases that explain specific
tasks within a program‟s algorithm. They should not include keywords in any specific computer language.
The sole purpose of pseudocodes is to enhance human understandability of the solution. They are commonly
used in textbooks and scientific publications for documenting algorithms, and for sketching out the program
structure before the actual coding is done. This helps even non-programmers to understand the logic of the
designed solution. There are no standards defined for writing a pseudocode, because a pseudocode is not an
executable program. Flowcharts can be considered as graphical alternatives to pseudocodes, but require more
space on paper,
Example: Write a pseudocode to find sum of three numbers.
1. Read a ,b, c
2. sum=a+b+c
3. Print sum
4. End
Variables: a, b, c, sum

Types of Errors:
While writing programs, very often we get errors in our program. These errors if not removed will either give
erroneous output or will not let the compiler to compile the program. These errors are broadly classified
under four groups:
• Run-time errors
• Compile-time errors
• Linker errors
• Logical errors
Run-time Errors: As the name suggests, run-time errors occur when the program is being run executed.
Such errors occur when the program performs some illegal operations like
• Dividing a number by zero
• Opening a file that already exists
• Lack of free memory space
• Finding square or logarithm of negative numbers
Run-time errors may terminate program execution, so the code must be written in such a way that it handles
all sorts of unexpected errors rather terminating it unexpectedly. This ability to continue operation of a
program despite of run-time errors is called robustness.
Compile-time Errors: Again as the name implies, compile errors occur at the time of compilation of the
program. Such errors can be further classified as follows:
Syntax Errors: Syntax error is generated when rules of C programming language are violated. For example,
if we write int a: then a syntax error will occur since the correct statement should be int a;
Semantic Error: Semantic errors are those errors which may comply with rules of the programming
language but are not meaningful to the compiler. For example, if we write, a * b = c; it does not seem correct.
Rather, if written like c = a * b would have been more meaningful.
Logical Errors: Logical errors are errors in the program code that result in unexpected and undesirable
output which is obviously not correct. Such errors are not detected by the compiler, and programmers must
Notes Prepared by Sayeesh, Dept. of CSE, YIT
check their code line by line or use a debugger to locate and rectify the errors. Logical errors occur due to
incorrect statements. For example, if you meant to perform c = a + b; and by mistake you typed c = a * b;
then though this statement is syntactically correct, it is logically wrong.
Linker Errors: These errors occur when the linker is not able to find the function definition for a given
prototype. For example, if we write sqrt function but do not include math.h then a linker error will be shown.
Similarly, even if we have defined a function display_data() but while calling if we mistakenly write
displaydata() then again a linker error will be generated

Testing and Debugging Approaches:


Testing is an activity that is performed to verify correct behaviour of a program. It is specifically carried out
with intent to find errors. Ideally testing should be conducted at all stages of program development. However,
in the implementation stage, three types of tests can be conducted:
• Unit Tests: Unit testing is applied only on a single unit or module to ensure whether it exhibits the
expected behavior.
• Integration Tests: These tests are a logical extension of unit tests. In this test, two units that have
already been tested are combined into a component and the interface between them is tested. The
guiding principle is to test combinations of pieces and then gradually expanding the component to
include other modules as well. This process is repeated until all the modules are tested together. The
main focus of integration testing is to identify errors that occur when the units are combined.
• System Tests: System testing checks the entire system. For example, if our program code consists of
three modules then each of the module is tested individually using unit tests and then system test is
applied to test this entire system as one system.
Debugging, on the other hand, is an activity that includes execution testing and code correction. The main
aim of debugging is locating errors in the program code. Once the errors are located, they are then isolated
and fixed to produce an error-free code. Different approaches applied for debugging a code includes:
• Brute-Force Method: In this technique, a printout of CPU registers and relevant memory locations
is taken, studied, and documented. It is the least efficient way of debugging a program and is
generally done when all the other methods fail.
• Backtracking Method: It is a popular technique that is widely used to debug small applications. It
works by locating the first symptom of error and then trace backward across the entire source code
until the real cause of error is detected. However, the main drawback of this approach is that with
increase in number of source code lines, the possible backward paths become too large to manage.
• Cause Elimination: In this approach, a list of all possible causes of an error is developed. Then
relevant tests are carried out to eliminate each of them. If some tests indicate that a particular cause
may be responsible for an error then the data are refined to isolate the error.

Files used in C Programming: A C program uses four types of files as follows:


• Source File
• Header File
• Object File
• Executable File
Source Code File:
• This file includes the source code of the program.
• The extension for these kind of files are '.c'. It defines the main and many more functions written in C.
• main() is the starting point of the program. It may also contain other source code files.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Header Files
They have an extension '.h'. They contain the C function declarations and macro definitions that are shared
between various source files.
Advantages of header files:
1. At times the programmer may want to use the same subroutines for different programs. To do this, he
would just compile the code of the subroutine once and link to the resulting object file in any file in which
the functionalities of this subroutine are required.
2. At times the programmer may want to change or add the subroutines and reflect those changes in all the
programs. For doing this, he will have to only change the source file for the subroutines, recompile the source
code and then recompile and re-link the program.
This tells us that including a header file will make it easier at all levels of the program. If we need to modify
anything then changes are made only in the subroutines after which all the changes will be reflected.
Standard header files
C provides us with some standard header files which are available easily.
Common standard header files are:
i) string.h – used for handling string functions.
ii) stdlib.h – used for some miscellaneous functions.
iii) stdio.h – used for giving standardized input and output.
iv) math.h – used for mathematical functions.
v) alloc.h – used for dynamic memory allocation.
vi) conio.h – used for clearing the screen.
The header files are added at the start of the source code so that they can be used by more than one function
of the same file.
Object files
• They are the files that are generated by the compiler as the source code file is processed.
• These files generally contain the binary code of the function definitions.
• The object file is used by the linker for producing an executable file for combining the object files together.
It has a '.o' extension.
Executable file
• This file is generated by the linker.
• Various object files are linked by the linker for producing a binary file which will be executed directly.
• They have an '.exe' extension.
Compiler:
A compiler is system software which translates the whole High level language program into its equivalent
machine level language program.
Compilers convert the program instructions from human understandable form to the machine understandable
form and the translated program instruction is called object code. Compiler is nothing but a language
translator used to translate the entire program of the high level language into machine language. Every
programming language requires its own compiler to translate the program. For example, the programming
language PASCAL requires PASCAL compiler and C uses C compiler.

High level Compiler Machine


language Language

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Overview of C
C was evolved from ALGOL, BCPL and B by Dennis Ritchie at the Bell Laboratories of AT &T
(American Telephone & Telegraph), USA in 1972. C uses many concepts from these languages
and added the concept of data types and other powerful features. Dennis Ritchie is known as
the founder of the c language.

Since it was developed along with the UNIX operating system, it is strongly associated with
UNIX. This operating system, which was also developed at Bell Laboratories of AT &T, was
coded almost entirely in C.

Basic Structure of C program:


The basic structure of a C program is shown below:

Documentation Section

Link Section

Definition Section

Global Declaration Section


/ Function Declaration
main() Function Section
{

Declaration Part

Executable Part
}

Subprogram section
Function 1

Function 2 (User defined functions)


.
.
.
Function n

• The Documentation Section consists of a set of comment lines giving the name of the
program, the name author and other details which the programmer would like to use later.
• The Link Section provides instructions to the compiler to link functions from the system
library.

Notes Prepared by Sayeesh, Dept. of CSE, YIT


• The Definition Section defines all symbolic constants.
• The Global Declaration Section defines global variables that are used in more than one
function and this section also declares all user-defined functions.
• Every C program must have one main( ) function section. This section contains two parts:
➢ Declaration Part: The declaration part declares all the variables used in the
executable part.
➢ Executable Part: There should be at least one statement in the executable part.
These two parts must appear between the opening and the closing braces. The program
execution begins at the opening brace and ends at the closing brace. The closing brace of the main
function section is logical end of the program. All statements in the declaration and executable
parts end with a semicolon.
• The Subprogram Section contains all the user-defined functions that are called in the main
function. User-defined functions are generally placed immediately after the main
function, although they may appear in any order.

NOTE: All the sections, except the main function section may be absent when they are not
required.

Example: Write a program to print area and circumference of a circle for the given radius
value.

#include<stdio.h> Link Section

void main( )
{
float r, A, C; Declaration Part
printf(“Enter the radius value”);
scanf(“%f”,&r);
A=3.142*r*r;
C=2*3.142*r; main function Section
printf(“Area of the circle is %f\n”,A);
printf(“Circumference of the circle is %f”,C); Executable Part
}

Notes Prepared by Sayeesh, Dept. of CSE, YIT


/* File Name: circle.c
Author: xyz
Date: 22-12-2021 Documentation Section
Description: Program to find the area and circumference of a circle
for the given radius value.
*/

#include<stdio.h> Link Section

void main( )
{
float r, A, C; Declaration Part
printf(“Enter the radius value”);
scanf(“%f”,&r);
A=3.142*r*r;
C=2*3.142*r; main function Section
printf(“Area of the circle is %f\n”,A);
printf(“Circumference of the circle is %f”,C); Executable Part
}

/* File Name: circle.c


Author: xyz
Date: 22-12-2021 Documentation Section
Description: Program to find the area and circumference of a circle
for the given radius value.
*/

#include<stdio.h> Link Section

#define PI 3.142 Definition Section

void main( )
{
float r, A, C; Declaration Part
printf(“Enter the radius value”);
scanf(“%f”,&r);
A=PI*r*r;
C=2*PI*r; main function Section
printf(“Area of the circle is %f\n”,A);
printf(“Circumference of the circle is %f”,C); Executable Part
}

Notes Prepared by Sayeesh, Dept. of CSE, YIT


C Tokens:
TOKEN is the smallest unit in a 'C' program. It is each and every word and punctuation that you
come across in your C program. The compiler breaks a program into the smallest possible units
(tokens) and proceeds to the various stages of the compilation. A token is divided into six different
types, viz, Keywords, Operators, Strings, Constants, Special Characters, and Identifiers.

Tokens in C
Keywords:
Keywords are preserved words that have special meaning in C language. The meaning of C
language keywords has already been described to the C compiler. These meaning cannot be
changed. Thus, keywords cannot be used as variable names because that would try to change the
existing meaning of the keyword, which is not allowed. These serve as basic building blocks for
program statements. All keywords must be written in lowercase. There are total 32 keywords in
ANSI C.
ANSI C Keywords

auto double int struct

break else long switch

case enum register typedef

const extern return union

char float short unsigned

continue for signed volatile

default goto sizeof void

do if static while

Notes Prepared by Sayeesh, Dept. of CSE, YIT


Identifiers:
In C language identifiers are the names given to variables, constants, functions and user-define data.
These identifiers are defined against a set of rules.

Rules for writing identifiers:


1. An Identifier can only have alphanumeric characters (a-z, A-Z, 0-9) and underscore ( _ ).
2. The first character of an identifier can only contain alphabet (a-z, A-Z) or underscore ( _ )
3. Identifiers are also case sensitive in C. For example name and Name are two different
identifiers in C.
4. Keywords are not allowed to be used as Identifiers.
5. No special characters, such as semicolon, period, whitespaces, slash or comma are
permitted to be used in or as Identifier.

The following table gives illegal identifiers and explains why they are illegal.
Identifier Reasons for invalidity
For It is a keyword

3_factorial Should not start with digit

Sum,1 Comma should not be there

Sum-of-digits Minus sign should not be there

White spaces (Blank Spaces) are not allowed


sum 1
Special symbol ($) is not allowed
Sum$
Symbol ! is not allowed.
Sum!

Variables:
A variable is a data name that may be used to store a data value. Unlike the constants that remain
unchanged during the execution of a program, a variable may take different values at different times
during execution.
A variable is a name of the memory location. It is used to store data. Its value can be changed, and it
can be reused many times.
A variable name can be chosen by the programmer in a meaningful way so as to reflect its
function or nature in the program. Some examples are given below.
Average Height
Total Counter_1
Rules for writing Variables:
1. A variable can only have alphanumeric characters (a-z, A-Z, 0-9) and underscore ( _ )
2. The first character of a variable can only contain alphabet (a-z, A-Z) or underscore ( _ ).
3. Variables are also case sensitive in C. For example, name and Name are two
differentvariables in C.
4. Keywords are not allowed to be used as variables.

Notes prepared by Sayeesh, Dept. of CSE YIT


5. No special characters, such as semicolon, period, whitespaces, slash or comma are
permitted to be used in or as variable.

Numeric variables
Numeric variables can be used to store either integer values or floating point values. While an
integer value is a whole number without decimal point, a floating point value can have a decimal
point
Character variables
Character variables are single character enclosed with single quotes. It can either be ’A’ or ‘a’ or
special characters ‘&’. Here 2 is considered as integer and ‘2’ is considered as character not
integers.

Declaration of variables:
A variable declaration provides assurance to the compiler that there exists a variable with the given type
and name so that the compiler can proceed for further compilation without requiring the complete
detail about the variable. A variable definition has its meaning at the time of compilation only, the
compiler needs actual variable definition at the time of linking the program.
Identifiers which are used as variable names should be prefixed as integer or float by the following
declaration should appear at the beginning of a program before the variable names are used.

data_type variable_name1, variable_name2,……variable_nameN;

The data_type is always a reserved word. The data_type available for variable names storing numbers are
int for integers and float for floating point numbers.
Valid examples are given below:
int n, height ,count ,digit;
float rate, average , y_coordinate,p1;
When a variable name is declared then a memory location is identified and given this name.
The following declarations of variables are invalid:
float, a ,b ,c ; (comma after float is not valid) int :x;
(: is not valid)
real x, y;(real is not the correct type_name)

Notes prepared by Sayeesh, Dept. of CSE YIT


Data types:
C language has varieties of data types. Storage representations and machine instructions differ from
machine to machine. The variety of data types available allows the programmer to select the
appropriate to the needs of the application as well as the machine.
Data Types

Standard (Built-in) User-defined

int float char array structure union

unsigned signed short int long


float double

The fundamental or primary data types are integer (int), character (char), floating point (float), and
double-precision floating point (double). Many of them also has extended data types such as long,
double, short, unsigned and signed. The ranges of basic four types are given below:

Data types Byte size


char 1 byte
short 2 bytes
long 8 bytes
int 4 bytes
float 4 bytes
double 8 bytes

char, int, float and double are all keywords and therefore their use is reserved.
They may not be used as names of variables. Char stands for “character” and int stands for “integer”.
The keywords short int, long int and unsigned int may be and usually are, shortened to just short, long,
and unsigned, respectively. Also, double and long float are equivalent, but double is the keyword
usually used.

Notes prepared by Sayeesh, Dept. of CSE YIT


Integer Types:
Integers are whole numbers with a range of values supported by a particular machine. C has three
classes of integer storage, namely short int, int, and long int in both unsigned and signed forms. For
example, short int represents fairly small integer.
Values and requires half the amount of storage as a regular int number uses. Unlike signed integers,
unsigned integers use all the bits for the magnitude of the number and are always positive. We declare
long and unsigned integers to increase the range of values.

Floating point types:


Floating point (or real) numbers are stored in 32 bits (on all 16 bit and 32 bit machines), with 6 digits
of precision. Floating point numbers are defined in C by the keyword float. The type double can be used
when the accuracy provided by a float number is not sufficient. A double data type number uses 64 bits
giving a precision of 14 digits. These are known as double precision numbers.
Character types:
A single character can be defined as a character (char) type data. Characters are usually stored in 8 bits
(one byte) of internal storage. The qualifier signed or unsigned may be explicitly applied to char. While
unsigned chars have values between 0 and 255, signed chars have values from -128 to 127.

Character Set
The characters that can be used to form words, numbers and expressions depend upon the
computer on which the program is run. The characters in C are grouped into the following categories.
1. Letters
2. Digits
3. Special characters
4. White Spaces

Letters Digits

Uppercase A…Z All decimal digits 0…9


Lowercase a….z

Special characters

Notes prepared by Sayeesh, Dept. of CSE YIT


, comma & ampersand
. period ^ carat
; semicolon *asterisk
: colon -minus sign
? question mark + sign
„ apostrophe < opening angle bracket
! exclamation mark (or less than sign)
| vertical bar > closing angle bracket
/ slash (or greater than sign)
\ backslash ( left parenthesis
~ tilde ) right parenthesis
_ underscore [ left bracket
$ dollar sign ] right bracket
% percent sign { left brace
# number sign } right brace

White Spaces
Blank Space
Horizontal tab
Carriage return New
line
Form feed

Constant:
Constants are data values that cannot be changed during the execution of a program. Constants are
also called as literals.
Constant

Numeric Constants Character Constants


Numeric Constants:
Integer Constants:
An integer constant refers to a sequence of digits. Integers consist of a set of digits 0
through 9, preceded by an optional – or + sign. Some examples of integer constants are
123
-431
0
34567
+678
Spaces, commas, and non-digit characters are not permitted between digits.
For example
15 750
20,000
Rs 1000
are illegal numbers.
An integer constant refers to a sequence of digits. There are three types of integers, namely decimal,
octal and hexadecimal.
Notes prepared by Sayeesh, Dept. of CSE YIT
Decimal integers consist of a set of digits 0 through 9, preceded by an optional – or + sign. Some
examples of decimal integer constants are
123
-431
0
34567
+678
Spaces, commas, and non-digit characters are not permitted between digits.
For example
15 750
20,000
Rs 1000
are illegal numbers.

An octal integer constant consists of any combination of digits from the set 0 through 7 with a leading
0.
Some examples are: 037
0
0435
0567

A sequence of digits preceded by 0x is considered as hexadecimal integer. They may also include
alphabets A through F or a through f. The letters A through F represent the numbers 10 through
15. The examples for hexadecimal integers are:

0x2 0x9F
0xbcd 0x

Floating-point constants:
Integer numbers are inadequate to represent quantities that vary continuously, such as
distances, heights, temperatures, prices and so on. These quantities are represented by numbers
containing fractional parts like 23.78. Such numbers are called floating-point constants or real
constants. Examples for floating-point constants are given below.
213.00
0 .95
-0.71
+0.5
A real number may also be expressed in exponential (or specific notation). For example the value
213.45 may be written as 2.1345e2 in exponential notation. e2 means multiply by 102. The general form
is
mantissa e exponent

Character Constants:
A character constant contains a single character enclosed within a pair of single quote
marks. Examples of character constants are:
„5‟ „X‟ „;‟ „ „

Notes prepared by Sayeesh, Dept. of CSE YIT


Note that the character constant „5‟ is not the same as the number 5. The last constant is a
blank space.
Character constants have integer values known as ASCII values. For Example, the
statement
printf (“%d”, „A‟);
would print the number 65,the ASCII value of the letter a. Similarly, the statement printf(“%c”,
65)

would give the output as letter „A‟


It is also possible to perform arithmetic operations on character constants.
String constants:
A string constant is a sequence of characters enclosed in double quotes. The letters may
be numbers, special characters and blank space.
Examples are given below
“THANK YOU”
“2345”
“? .... ”
“7+8-9” “X”

Remember that a character constant „X‟ is not equivalent to the single character string constant (“X”).
A single character string constant does not have an equivalent integer value as a single character
constant. These type of constants are used in programs to build meaningful programs.

Defining Constants
There are two simple ways in C to define constants −
• Using #define preprocessor.
• Using const keyword.
The #define Preprocessor
Given below is the form to use #define preprocessor to define a constant −

#define identifier value

Example: #define PI 3.142 The


const Keyword
You can use const prefix to declare constants with a specific type as follows −

const data_type variable = value;

Example: const float PI=3.142;


Comment:
Comment is program self-explanation, which is ignored by the compiler. It is helpful if the person
who writes the code places some comments in the code to help the reader. To identify a comment, C
Notes prepared by Sayeesh, Dept. of CSE YIT
uses two different formats: block comments and line comments.

Single Line Comment (Line Comment): The second format, the line comment, uses two slashes (//) to
identify a comment. This format does not require an end of comment token; the end of the line
automatically ends the comment. Programmers generally use this format for short comments. The line
comment token can start anywhere on the line.
Example: // This is a line comment.

Multiple Line Comment (Block Comment): A block comment is used when the comment will span
several lines. We call this comment format block comment. It uses opening and closing comment
tokens. Each comment token is made of two characters that, taken together, form the token; there can
be no space between them. The opening token is /* and the closing token is */. Everything between the
opening and closing comment tokens is ignored by the compiler. The tokens can start in any column,
and they do not have to be on the same line. The only requirement is that the opening token must
precede the closing token.
Example: /* This is a block comment that
covers two lines */
Input and Output Statements in C:
In C, data is input to and output from a stream. A stream is a source of or destination for data. It isassociated
with a physical device, such as a terminal, or with a file stored in auxiliary memory.
Reading data, processing it and writing the processed data known as information or a result of a program
are the essential functions of a program. The C is a functional language. It provides a number of macros and
functions to enable the programmer to effectively carry out these inputs andoutput operations. The data is
entered by the user through the standard input device (i.e. keyboard)and processed data is displayed on the
standard output device (i.e. monitor).
I/O functions are grouped into two categories:
• Unformatted I/O functions.
• Formatted I/O functions.
The formatted I/O functions allow programmers to specify the type of data and the way in which it
should be read in or written out. On the other hand, unformatted I/O functions do not specify the type of
data and the way is should be read or written. scanf ( ) and printf( ) are formattedI/O functions.
The following table lists the formatted and unformatted I/O functions:
Function Formatted Unformatted
Input scanf( ) getchar( ), gets( )
Output printf( ) putchar( ), puts( )

Formatted Input Function:


scanf functions:-
The function scanf() is used to read data into variables from the standard input,namely a
keyboard. The general format is:

scanf(format-string, &var1,&var2,………&varn);
Where format-string gives information to the computer on the type of data to be stored in the list of
variables var1,var2……varn and in how many columns they will be found

For example, in the statement:

Notes prepared by Sayeesh, Dept. of CSE YIT


scanf(“%d %d”, &p, &q);
The two variables in which numbers are used to be stored are p and q. The data to be stored are integers.
The integers will be separated by a blank in the data typed on the keyboard.
A sample data line may thus be:456 18578
Observe that the symbol &(called ampersand) should precede each variable name. Ampersandis used to
indicate that the address of the variable name should be found to store a value in it. The manner in
which data is read by a scanf statement may be explained by assuming an arrowto be positioned above
the first data value. The arrow moves to the next data value after storingthe first data value in the storage
location corresponding to the first variable name in the list. A blank character should separate the data
values.
The scanf statement causes data to be read from one or more lines till numbers are stored in allthe
specified variable names.
Note that no blanks should be left between characters in the format-string. The symbol & isvery
essential in front of the variable name.
If some of the variables in the list of variables in the list of variables in scanf are of type integerand some
are float, appropriate descriptions should be used in the format-string.

For example:
scanf(“%d %f %e”, &a , &b, &c);
Specifies that an integer is to be stored in a, float is to be stored in b and a float written usingthe
exponent format in c. The appropriate sample data line is:
485 498.762 6.845e-12
Formatted Output Function:
printf function:
The general format of an output function is

printf(format-string, var1,var2…..varn);
Where format-string gives information on how many variables to expect, what type ofarguments they
are, how many columns are to be reserved for displaying them and any character string to be printed.
The printf() function may sometimes display only a message andnot any variable value. In the following
example:
printf(“Answers are given below”); The
format-string is:
Answers are given below
And there are no variables. This statement displays the format-string on the video display andthere are
no variables. After displaying, the cursor on the screen will remain at the end of thestring. If we want it
to move to the next line to display information on the next line, we shouldhave the format-string:
printf(“Answers are given below\n”);
In this string the symbol \n commands that the cursor should advance to the beginning of the next line.
In the following example:
printf(“Answer x= %d \n”, x);
%d specifies how the value of x is to be displayed. It indicates the x is to be displayed as a decimal
integer. The variable x is of type int. %d is called the conversion specification and d the conversion
character. In the example:
printf(“a= %d, b=%f\n”, a, b);
the variable a is of type int and b of type float or double. % d specifies that a is to be displayed as an
integer and %f specifies that, b is to be displayed as a decimal fraction. In this example
%d and %f are conversion specifications and d, f are conversion characters.
Notes prepared by Sayeesh, Dept. of CSE YIT
Formatted input and output using format specifiers:
The function scanf is the input analog of printf, providing many of the same conversionfacilities
in the opposite direction.
Conversion characters are shown in the table below:
CHARACTER DESCRIPTION

%d Represents signed integers


%u Represents unsigned integers in decimal form.
%sd Represents short integers.
%ld Represents long integers.
%c Represents character
%s Represents strings
%f Represents floating point
%e Represents double data type.
%o Represents octal integer
%x Represents Hexadecimal integer

Review Questions
1. Define computer. Explain the stored program concepts and its types. (6 Marks)
2. List out and explain the characteristics of computer (8 Marks)
3. Explain the different generations of computer. (10 Marks)
4. Discuss the different types of computers (10 Marks)
5. Explain the different types of microcomputers. (8 Marks)
6. List out and explain the different types of input and output devices. (10 Marks)
7. Distinguish between dumb terminals and intelligent terminals in mainframe computer. (4 Marks)
8. Explain the basic organization of computer with neat a block diagram. (10 Marks)
9. Discuss the various components inside a computer. (6 Marks)
10. What is motherboard? Explain the characteristics of motherboard. (8 Marks)
11. Differentiate primary memory and secondary memory. (4 Marks)
12. List out and explain the applications of computer (8 Marks)
13. List out and explain the different types of programming paradigm, (8 Marks)
14. Discuss the different phases of software development with the help of diagram. (10 Marks)
15. What is algorithm? Explain the control structures used in algorithm with examples. (8 Marks)
16. What is a pseudocode? Explain with example. (5 Marks)
17. Write an algorithm and draw a flowchart to compute area and circumference of the circle for the given
radius value. (6 Marks)
18. Write an algorithm and draw a flowchart to find area of the triangle for the given three sides. (6 Marks)
19. What is flowchart? List out and explain the purpose of different symbols used in flowchart. (6 Marks)
20. Write an algorithm and draw a flowchart to compute simple interest for the given principal amount, rate of
interest and number of years. (6 Marks)
21. What is compiler? Explain the function of compiler. (4 Marks)
22. List out and explain the different types of errors with examples. (8 Marks)
23. What is testing? Explain the different types of testing. (6 Marks)
24. What is debugging? Explain the different approaches applied for debugging a code. (6 Marks)
25. List out and explain the different types of files used in C program. (8 Marks)
26. Explain the basic structure of C program with an example. (8 Marks)
27. Give the character set of C. (4 Marks)

Notes prepared by Sayeesh, Dept. of CSE YIT


28. What is identifier? What are the rules for writing an identifier in C? (5 Marks)
29. What are keywords? Give some examples for keywords. (3 Marks)
30. Check the following identifiers are valid or invalid. If it is invalid give the reason for invalidity. (4 Marks)

a. Sum100
b. sum+3
c. int
d. ab_cd
e. X Y
f. 2product
g. m-n
31. What are constants? How they differ from variables? (4 Marks)
32. List the various types of constants with examples. (4 Marks)
33. Explain the various data types supported by C. (5 Marks)
34. What is variable? How to declare variable in C program? Explain with examples. (6 marks)
35. Explain input and output statements used in C program with examples. (6 Marks)
36. Write a C program to find area of the triangle for the given base and height. (5 Marks)
37. Write a C program to find area of the triangle for the given three sides. (5 Marks)
38. Write a C program to compute simple interest. (5 Marks)
39. Write a C program to find area and circumference of the circle for the given radius value (5 Marks)
40. Write a C program to swap two given numbers without using third variable (5 Marks)

Notes prepared by Sayeesh, Dept. of CSE YIT

You might also like