CP Unit 1 Notes

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

Dr.

Mahalingam College of Engineering and Technology, Pollachi – 642003


19CSSC2001 C Programming
Unit-1 – INTRODUCTION

The term computer is derived from the word compute. The word
compute means to calculate. A computer is an electronic machine that
accepts data from the user, processes the data by performing calculations
and operations on it, and generates the desired output results.

Digital Computer uses distinct values to represent the data internally.


All information is represented using the digits 0s and 1s.
Analog computer is another kind of a computer that represents data as
variable across a continuous range of values.

Characteristics of Computer:

Speed: The computer can process data very fast, at the rate of millions of
instructions per second.

Accuracy: Level of accuracy depends on the instructions and type of


machine being used. Faulty instruction for data processing may lead to
faulty results.

Diligence: When used for a longer period of time, It can perform long and
complex calculations with the same speed and accuracy from the start till
the end.
Reliability: It is measurement of performance of a computer, which is
measured against pre determined standards for operation without any
failure.

Storage Capability: Large volumes of data and information can be stored


in the computer and also retrieved whenever required.
A limited amount of data can be stored, temporarily, in the primary
memory.
Secondary storage devices like floppy disk and compact disk can store a
large amount of data permanently.

Versatility: Computer is versatile in nature. It can perform multiple tasks


simultaneously.
Resource sharing: computers are capable to connect with each other.

GENERATION OF COMPUTERS

The computer has evolved from a large—sized simple calculating machine


to a smaller but much more powerful machine. The evolution of computer
to the current state is defined in terms of the generations of computer.
Each generation of computer is designed based on a new technological
development, resulting in better, cheaper and smaller computers that are
more powerful, faster and efficient than their predecessors. Currently,
there are five generations of computer.

• 1st Generation(1940-1956) : Vacuum Tubes

• 2nd Generation(1956 -1963) : Transistors

• 3rd Generation(1964 to Early 1970s) : Integrated Circuits

• 4th Generation(Early 1970s Till Date) : Microprocessors

• 5th Generation(Present & Beyond) : Artificial Intelligence

First Generation:

Hardware Technology The first generation of computers used vacuum


tubes for circuitry and magnetic drums for memory. The input to the
computer was through punched cards and paper tapes. The output was
displayed as printouts.

Software Technology The instructions were written in machine


language. Machine language uses 0s and 1s for coding of the instructions.
The first generation computers could solve one problem at a time.

Computing Characteristics The computation time was in milliseconds.

Physical Appearance These computers were enormous in size and


required a large room for installation.

Application They were used for scientific applications as they were the
fastest computing device of their time.

Examples UNIVersal Automatic Computer (UNIVAC), Electronic


Numerical Integrator and Calculator (ENIAC), and Electronic Discrete
Variable Automatic Computer (EDVAC).

The first generation computers used a large number of vacuum tubes and
thus generated a lot of heat. They consumed a great deal of electricity and
were expensive to operate. The machines were prone to frequent
malfunctioning and required constant maintenance. Since first generation
computers used machine language, they were difficult to program.

Second Generation:

Hardware Technology Transistors replaced the vacuum tubes of the


first generation of computers. Transistors allowed computers to become
smaller, faster, cheaper, energy efficient and reliable. The second
generation computers used magnetic core technology for primary memory.
They used magnetic tapes and magnetic disks for secondary storage. The
input was still through punched cards and the output using printouts.
They used the concept of a stored program, where instructions were stored
in the memory of computer.

Software Technology The instructions were written using the assembly


language. Assembly language uses mnemonics like ADD for addition and
SUB for subtraction for coding of the instructions. High-level
programming languages, such as early versions of COBOL and
FORTRAN were also developed during this period.

Computing Characteristics The computation time was in microseconds.

Physical Appearance Transistors are smaller in size compared to


vacuum tubes, thus, the size of the computer was also reduced.

Application The cost of commercial production of these computers was


very high, though less than the first generation computers. The transistors
had to be assembled manually in second generation computers.

Examples PDP-8, IBM 1401 and CDC 1604.

Second generation computers generated a lot of heat but much less than
the first generation computers. They required less maintenance than the
first generation computers.

Third Generation:
Hardware Technology The third generation computers used the
Integrated Circuit (IC) chips. Consist of single chip with many
components such as transistors, resistors & capacitors fabricated on it.
Punched cards & printouts are replaced by keyboards & monitors &
interfaced with operating system. Magnetic disks were used for secondary
storage.

Software Technology The keyboard and the monitor were interfaced


through the operating system. Operating system allowed different
applications to run at the same time. High-level languages were used
extensively for programming, instead of machine language and assembly
language.

Computing Characteristics The computation time was in nanoseconds.

Physical Appearance The size of these computers was quite small


compared to the second generation computers.

Application Computers became accessible to mass audience. Computers


were produced commercially, and were smaller and cheaper than their
predecessors.

Examples IBM 370, PDP 11.

The third generation computers used less power and generated less heat
than the second generation computers. The cost of the computer reduced
significantly, as individual components of the computer were not required
to be assembled manually. The maintenance cost of the computers was also
less compared to their predecessors.
Fourth Generation:

Hardware Technology
 They use the Large Scale Integration (LSI) and the Very Large Scale
Integration (VLSI) technology. Thousands of transistors are integrated on
a small silicon chip using LSI technology. VLSI allows hundreds of
thousands of components to be integrated in a small chip. ULSI increased
that number into millions.
 Uses an extension of third generation technology of this generation is
based on IC But these have been made readily available because of
development of the microprocessor (Circuit containing millions of
transistors).
 Magnetic core memories were substituted by semiconductor memories
resulted in RAM.
 Secondary memories –hard disk became economical, smaller & bigger in
capacity.

Software Technology Development of Graphical User Interface (GUIs),


mouse, hand held devices happened

Computing Characteristics The computation time is in picoseconds.

Physical Appearance They are smaller than the computers of the


previous generation. Some can even fit into the palm of the hand.

Application They became widely available for commercial purposes.


Personal computers became available to the home user.

Examples The Intel 4004 chip was the first microprocessor

The microprocessor has resulted in the fourth generation computers being


smaller and cheaper than their predecessors. The fourth generation
computers are also portable and more reliable.
They generate much lesser heat and require less maintenance compared to
their predecessors.GUI (Graphical User Interface) and pointing devices
facilitate easy use and learning on the computer. Networking has resulted
in resource sharing and communication among different computers.
Fifth Generation (Present and Next):

 The goal of fifth generation computing is to develop computers that are


capable of learning and self-organization. The fifth generation computers
use Super Large Scale Integrated (SLSI) chips that are able to store
millions of components on a single chip.
 These computers have large memory requirements.
 This generation of computers uses parallel processing that allows
several instructions to be executed in parallel, instead of serial execution.
Parallel processing results in faster processing speed. The Intel dual core
microprocessor uses parallel processing.
 The fifth generation computers are based on Artificial Intelligence (AI).
They try to simulate the human way of thinking and reasoning. Artificial
Intelligence includes areas like Expert System (ES), Natural Language
Processing (NLP), speech recognition, voice recognition, robotics, etc.

CLASSIFICATION OF COMPUTER

Based on operating principles/Type:

Analog computers: represent data in the form of continuous electrical


signals having a specific magnitude.
Digital computers: store and process data in the digital form.
Hybrid computers: A combination of analog computer and digital
computer because it encompasses the best features of both.

Based on applications:
General purpose computers: can work in all environments.
Special purpose computers: can perform only a specified task.

Based on size and capability:


Microcomputers: Designed to be used by individuals.
Mini Computers: Can handle more data and more input and output than
micro computers.
Mainframe Computers: A very large computer.
Super Computers: The fastest type of computer that can perform
complex operations at a very high speed.
Classification by
Size & capability

Micro Mini Mainframe Super

Desktop Laptop Hand-held

Micro-computer

 It is defined as a computer that has microprocessor as its CPU.

 Microcomputers are small, low-cost and single-user digital computer.


They consist of CPU, Input unit, output unit, storage unit and the
software.
 PCs today are powered by three types of operating systems—
Windows (7, 8 or 10), Mac OS X (Apple) and Linux.

Desktop Computer or Personal Computer (PC):


 It consists of three units—keyboard, monitor, and a system unit
containing the CPU, memory, hard disk drive, etc.
 Used at home
 Used in Educations Institutions and Organizations as nodes
 Can perform typical activities like documentation, playing games,
surfing web to more complex activities as programming, design, DTP
etc.

Laptops (Notebook):
 Same as PCs in functionality
 More Compact, Portable
 Less Power requirement, operated on battery/s
 Less capacity compared to PCs
 Maintenance and actually are costlier compared to PCs
 Theft prone
Netbook:
 These are smaller notebooks optimized for low weight and low cost,
and are designed for accessing web-based applications.

Tablet Computer:
 It has features of the notebook computer but it can accept input from
a stylus or a pen instead of the keyboard or mouse.
 It is a portable computer.

Handheld Computer or Personal Digital Assistant (PDA)


 It is a small computer that can be held on the top of the palm.
 It is small in size.
 Instead of the keyboard, PDA uses a pen or a stylus for input.
 They have a limited memory and are less powerful.
 PDAs can be connected to the Internet via a wireless connection
 PDAs have merged into mobile phones to create smart phones.

Minicomputers

 It is a medium sized computer they have high processing speed , high


storage capacity and more powerful than microcomputer
 Minicomputer is usually designed to serve multiple users
simultaneously. It can support 4–200 users simultaneously.
 Minicomputers lie between mainframe and microcomputers.
 They are also called midrange computers and users can access the
minicomputer through their PCs or terminal.
 They are maintained by some organization
 Ex. PDP – 11, IBM (8000 series)

Mainframe Computer
 Mainframe computers are multi-user, multi-programming and high
performance computers.
 They operate at a very high speed, have very large storage capacity
and can handle the workload of many users.
 Mainframe computers are large and powerful systems generally used
in centralized databases.
 It can support hundreds or thousands of users using the feature of
time sharing supported by systems like Linux.
 Mainframes can concurrently run multiple programs even with a
single CPU. The processor speed in a mainframe is measured in
MIPS (million instructions per second).
 The user accesses the mainframe computer via a terminal that may
be a dumb terminal, an intelligent terminal or a PC. A dumb
terminal cannot store data or do processing of its own. It has the
input and output device only. An intelligent terminal has the input
and output device, can do processing, but, cannot store data of its
own. The dumb and the intelligent terminal use the processing power
and the storage facility of the mainframe computer.
 Mainframe computers are used in organizations like banks or
companies, where many people require frequent access to the same
data, on-line processing of large number of transactions & require
computer systems which have massive data storage & processing
capabilities.
 Some examples of mainframes are CDC 6600 and IBM ES000 series.

Super Computers
 Supercomputers are the fastest and the most expensive machines.
 They have high processing speed compared to other computers.
 The speed of a supercomputer is generally measured in FLOPS
(Floating point Operations per Second).
 Some of the faster supercomputers can perform trillions of
calculations per second. A supercomputer uses multiple CPUs for
parallel data processing, which means portions of the same program
are handled independently by multiple processors.
 Supercomputers are used for highly calculation-intensive tasks, such
as, weather forecasting, Analysis of geological data, climate research
(global warming), molecular research, biological research, nuclear
research and aircraft design.
 They are also used in major universities, military agencies and
scientific research laboratories.
 Some examples of supercomputers are IBM Roadrunner, IBM Blue
gene and Intel ASCI red.
 PARAM is a series of supercomputer assembled in India by C-DAC
(Center for Development of Advanced Computing), in Pune. PARAM
Padma is the latest machine in this series. The peak computing
power of PARAM Padma is 1 Tera FLOP (TFLOP).

BASIC ORAGANIZATION OF A COMPUTER

The computer system

Computer is an electronic device that accepts data as input, processes the


input data by performing mathematical and logical operations on it, and
gives the desired output.
 Hardware consists of the mechanical parts that make up the
computer as a machine. The hardware consists of physical devices
the computer. The devices are required for input, output, storage and
processing of the data. Keyboard, monitor, hard disk drive, floppy
disk drive, printer, processor and motherboard are some of the
hardware devices.
 Software is a set of instructions that tells the computer about the
tasks to be performed and how these tasks are to be performed.
Program is a set of instructions, written in a language understood by
the computer, to perform a specific task.
A set of programs and documents are collectively called software. The
hardware needs to be instructed about the task to be performed.
Software instructs the computer about the task to be performed. The
hardware carries out these tasks.
 Data are isolated values or raw facts, which by themselves have no
much significance. The data is provided as input to the computer,
which is processed to generate some meaningful information.
 Users are people who write computer programs or interact with the
computer.
Components of computer hardware
The computer system hardware comprises of three main components:
1. Input/output (I/O) Unit,
2. Central Processing Unit (CPU), and
3. Memory Unit.
The I/O unit consists of the input unit and the output unit. CPU performs
calculations and processing on the input data, to generate the output. The
memory unit is used to store the data, the instructions and the output
information.
(1). Input/output Unit:
Input unit

 The user interacts with the computer via the I/O unit. The Input unit
accepts data from the user, into a form that is understandable by the
computer. Input devices are classified as follows
 Human data entry devices
Input devices that require data to be entered manually to the computer are
identified as human data entry devices.
 Keyboard
 Pointing devices—mouse, trackball, joystick, digitizing tablet
 Pick devices—light pen, touch screen
 Source data entry devices
Source data entry devices do not require data to be typed-in, keyed-in or
pointed to a particular location.
 Audio input—speech recognition
 Video input—digital camera
 Scanner—hand-held scanner, flat-bed scanner
 Optical Scanner—OCR, OMR, MICR, barcode reader
Output unit
 Output devices provide output to the user, which is generated after
processing the input data.
 The processed data, presented to the user via the output devices
could be text, graphics, audio or video.
 Output devices are classified as follows
 Hard Copy Devices
The output obtained in a tangible form on a paper or any surface is called
hard copy output.
 Printer
 Plotter
 Computer Output on Microfilm (microfiche)
 Soft Copy Devices
The output obtained in an intangible form on a visual display, audio unit or
video unit is called soft copy output.
 Monitor
 Visual Display Terminal
 Video Output
 Audio Response

(2). Central Processing Unit


 Central Processing Unit (CPU) or the processor is also often
called the brain of computer. The CPU is fabricated as a single
Integrated Circuit (IC) chip, and is also known as the
microprocessor.
 CPU consists of Arithmetic Logic Unit (ALU) and Control Unit (CU).
In addition, CPU also has a set of registers which are temporary
storage areas for holding data, and instructions.
 CPU executes the stored program instructions, i.e. instructions and
data are stored in memory before execution. For processing, CPU gets
data and instructions from the memory. It interprets the program
instructions and performs the arithmetic and logic operations
required for the processing of data. Then, it sends the processed data
or result to the memory.
Arithmetic Logic Unit
ALU consists of two units—arithmetic unit and logic unit.
 The arithmetic unit performs arithmetic operations on the data that
is made available to it. Some of the arithmetic operations supported
by the arithmetic unit are—addition, subtraction, multiplication and
division.
 Logic unit performs comparisons of numbers, letters and special
characters. Logic operations include testing for greater than, less than
or equal to condition.
Control Unit
 It acts as a supervisor and, controls and coordinates the activity of the
other units of computer. CU is responsible for organizing the
processing of data and instructions.
 CU coordinates the input and output devices of a computer. It directs
the computer to carry out stored program instructions by
communicating with the ALU and the registers.
 CU tells when to fetch the data and instructions, what to do, where to
store the results, the sequencing of events during processing etc.
 CU uses the instructions in the Instruction Register (IR) to decide
which circuit needs to be activated. When a program is run, the
Program Counter (PC) register keeps track of the program instruction
to be executed next.
 CU also holds the CPU’s Instruction Set, which is a list of all
operations that the CPU can perform.
Registers
 Registers store data, instructions, addresses and intermediate results
of processing.
 Registers are high-speed storage areas within the CPU, but have the
least storage capacity. Registers are not referenced by their address,
but are directly accessed and manipulated by the CPU during
instruction execution.
 Registers store data, instructions, addresses and intermediate results
of processing. Registers are often referred to as the CPU’s working
memory.
 The data and instructions that require processing must be brought in
the registers of CPU before they can be processed.
Central Processing Unit

Control Arithmeti
Unit c Logic
Unit

Registers

 Accumulator (ACC) stores the result of arithmetic and logic


operations.
 Instruction Register (IR) contains the current instruction most
recently fetched.
 Program Counter (PC) contains the address of next instruction to be
processed.
 Memory Address Register (MAR) contains the address of next location
in the Memory to be accessed.
 Memory Buffer Register (MBR) temporarily stores data from memory
or the data to be sent to memory.
 Data Register (DR) stores the operands and any other data.
The number of registers and the size of each (number of bits) register in a
CPU help to determine the power and the speed of a CPU. The size of
register, also called word size, indicates the amount of data with which the
computer can work at any given time. The size of a register may be 8, 16,
32 or 64 bits. 32-bit processor and 64-bit processor are the terms used to
refer to the size of the registers.

(3). Memory Unit


The memory unit consists of cache memory, primary memory and
secondary memory.
Primary memory or main memory of the computer is used to store the data
and instructions during execution of the instructions. Random Access
Memory (RAM) and Read Only Memory (ROM) are the primary memory.
In addition to the main memory, there is another kind of storage device
known as the secondary memory. Secondary memory is non-volatile and is
used for permanent storage of data and programs. A program or data that
has to be executed is brought into the RAM from the secondary memory.
Cache Memory
 The time taken to move the data between RAM and CPU registers is
large. This affects the speed of processing of computer, and results in
decreasing the performance of CPU.
 Cache memory is a very high speed memory placed in between RAM
and CPU.
 Cache memory is a storage buffer that stores the data that is used
more often, temporarily, and makes them available to CPU at a fast
rate.
 The computer also supports cache memory to hold those portions of a
program that are frequently used by the CPU. This fast but small
memory is available as a buffer between the CPU and RAM. When
executing a program, the CPU first looks for the instruction and data
in the cache. If it finds them there (cache hit), access of the slower
RAM is avoided. If the data is not found in the cache (cache miss), the
operating system places it there.
 Cache memory is very expensive, so it is smaller in size. Generally,
computers have cache memory of sizes 256 KB to 2 MB.

Primary Memory
 Primary memory is the main memory of computer. It is used to store
data and instructions during the processing of data. Primary memory
is semiconductor memory.
 Primary memory is of two kinds—Random Access Memory (RAM) and
Read Only Memory (ROM).
 RAM is volatile. It stores data when the computer is on. The
information stored in RAM gets erased when the computer is turned
off. RAM provides temporary storage for data and instructions.
 ROM is non-volatile memory, but is a read only memory. The storage
in ROM is permanent in nature, and is used for storing standard
processing programs that permanently reside in the computer. ROM
comes programmed by the manufacturer.
 RAM stores data and instructions during the execution of instructions.
The data and instructions that require processing are brought into the
RAM from the storage devices like hard disk. CPU accesses the data
and the instructions from RAM, as it can access it at a fast speed than
the storage devices connected to the input and output unit.
 The input data that is entered using the input unit is stored in RAM,
to be made available during the processing of data. Similarly, the
output data generated after processing is stored in RAM before being
sent to the output device. Any intermediate results generated during
the processing of program are stored in RAM.
 RAM provides a limited storage capacity, due to its high cost.

Secondary Memory
 The secondary memory stores data and instructions permanently. The
information can be stored in secondary memory for a long time
(years), and is generally permanent in nature unless erased by the
user. It is a non-volatile memory.
 It provides back-up storage for data and instructions. Hard disk drive,
floppy drive and optical disk drives are some examples of storage
devices.
 The data and instructions that are currently not being used by CPU,
but may be required later for processing, are stored in secondary
memory.
 Secondary memory has a high storage capacity than the primary
memory.
 Secondary memory is also cheaper than the primary memory.
 It takes longer time to access the data and instructions stored in
secondary memory than in primary memory.
 Magnetic tape drives, disk drives and optical disk drives are the
different types of storage devices.
Instruction
 A computer program is a set of instructions that describe the steps to
be performed for carrying out a computational task. The program and
the data, on which the program operates, are stored in main memory,
waiting to be processed by the processor. This is also called the stored
program concept.
 A processor has a set of instructions that it understands, called as
instruction set.
 The primary responsibility of a computer processor is to execute a
sequential set of instructions that constitute a program. CPU executes
each instruction in a series of steps, called instruction cycle.
Fetching: The processor fetches the instruction from the memory.
The fetched instruction is placed in the Instruction Register.
Program Counter holds the address of next instruction to be
fetched and is incremented after each fetch.
Decoding: The instruction that is fetched is broken down into
parts or decoded. The instruction is translated into commands so
that they correspond to those in the CPU’s instruction set. The
instruction set architecture of the CPU defines the way in which
an instruction is decoded.
Executing: The decoded instruction or the command is executed.
CPU performs the operation implied by the program instruction.
For example, if it is an ADD instruction, addition is performed.
Storing: CPU writes back the results of execution, to the
computer’s memory.
 A CPU performance is measured by the number of instructions it
executes in a second, i.e., MIPS (million instructions per second), or
BIPS (billion instructions per second).
 Part of the computer that are responsible for processing or converting
data into meaningful information.
 Processor
 Buses
 System Clock
Processor
 CPU referred to as a Processor Performs processing and control
activities performed by different parts of computer.
Buses
 Electrical pathway that transfer data and instructions among
different parts of computer.
 Main memory is directly/indirectly connected to the processor via a
bus.
 Data Bus - Data bus is Bidirectional because the Microprocessor
can read data from memory or write data to the memory.
 Address Bus - Address bus is Unidirectional because the
microprocessor is addressing a specific memory location.
 Control Bus – Control the activities all the software's and
hardware’s
System Clock – Clock used to synchronizing the activities performed by
the computer.
Factors that affect the performance of the computer
Registers - The bigger the size, the more quickly it can process data.
RAM - Larger the RAM size when the computer is switched on, the
operating system, device drivers, the active files and running programs are
loaded into RAM is very fast.
System Clock- Higher clock frequencies mean more clock ticks per
second. A CPUs performance is measured by the number of instructions it
executes in a second
Bus - The data bus width affects the speed of computer.
Cache memory – Size (amount of cache memory) and level L1, L2 and L3.
Larger the size of cache, the better it is. PCs nowadays have a L1 cache of
256KB and L2 cache of 1MB.

Computer Language
Low-Level Languages:
• Supports low level tasks such as transferring data from memory to
disk, or rendering text onto a display.
• Low level language is machine dependent i.e. a program written for
one type of computer does not work on other computers.
Machine Language –
• First Generation Language Instructions are represented by
combinations of 0’s and 1’s.
• Machine languages are the only languages understood by computers.
Assembly Language –
• Second Generation Language. Machine language instructions are
replaced with simple pneumonic abbreviations (e.g. ADD, MUL, DIV
etc…).
• Computer can’t execute it directly. Programs need to translate into
machine language to run. Assembler translates assembly language
into Machine codes.

High-Level Languages:
• Any language that is independent of the machine such as C, C++,
and Java.
• High level languages uses English like statements and mathematical
notations.
SOFTWARE

Set of computer programs which include instructions, used for performing


a particular task using hardware.
 Software tells hardware: what to do? How to do?
 Software is a collection of code that drives a computer to perform a
related group of tasks.
 It comprises one or more programs, supported by libraries and
configuration files that programs need to access. Software may reside
in a ROM, RAM, secondary storage (the hard disk) or may be loaded
from a network.
Computer software can be broadly divided into two types:
 System software - This is the software run by the computer to
manage the hardware connected to it. Users don’t have much control
over its functioning, but their own programs (application software)
use the services offered by system software whenever required.
 Application software - Software of this type relates to a specific
application, say, and one that makes hotel bookings or creates special
effects in movies. The vast majority of programmers are engaged in
developing application software.

System Software
 System software is "Background" software that helps the computer
manage its own internal resources.
 It enables the application software to interact with the computer
hardware. E.g. Operating System, Device Drivers, Utility Software,
and Translators etc...
 Most system software is run by the computer on startup, first from a
ROM and then from the hard disk. The others are invoked when
programs need them, say, for printing a report. In some cases, a user
may also directly use a program of this type. System software
includes but is not restricted to the following:

 Basic Input Output System (BIOS) - This is a small program that


checks the hardware devices and peripherals at boot time and then
loads the operating system.
 Operating system - This is the central system software that
manages both the hardware and programs running on the computer.
Because all programs need its services, the operating system remains
in memory as long as the computer is up. MS-DOS, MS-Windows,
UNIX, Linux, Mac OS etc…
 Device driver - Every hardware needs special software that knows
how to handle it. Programs access a device driver by making a call to
the operating system.
 Compilers and associated programs - This category of system
software is special because it is invoked by users. A programmer
invokes a compiler program to convert the source code written by
them to machine code.
 Utility Software - Used to analyze, configure and maintain the
computer system. (Antivirus software, backup software and disk
cleaners, clean up tools, defragmentation tool etc…)
When a program run by a user (application software) needs to access
hardware (say, a printer), it makes a call to system software to get the job
done. For this reason, the BIOS and operating system are loaded into
memory before users can run their programs.

Application Software

It is Collection of programs written to specific applications. The


Smartphone industry even has a smart name for it; they call it “apps.”
 Office software - Word processing, spreadsheet and presentations.
 Database software - This software package, commonly known as
Data Base Management System (DBMS), allows data having a
uniform structure to be stored in a database.
 Communications software - Computer networking led to the
development of software that allowed users to communicate with one
another. E.g. Email, Skype and Whatsapp.
 Entertainment software - Gaming software remains extremely
popular and challenging for software developers. The VideoLAN
(VLC) software serves as a one-stop shop for playing most audio and
video formats.
 Anti-virus software - A virus is a small program designed by a
person with malicious intent. Antivirus software essential to protect
from malicious software’s or virus.
 Special-purpose software - desktop publishing, computer-aided
design/manufacturing (CAD/CAM) and distance learning.

Software Development Life Cycle:

Software Development Life Cycle (SDLC) is a process used by the software


industry to design, develop and test high quality software's.
The SDLC aims to produce high-quality software that meets or exceeds
customer expectations, reaches completion within times and cost
estimates.
• It offers a basis for project planning, scheduling, and estimating.
• Provides a framework for a standard set of activities and deliverables
• It is a mechanism for project tracking and control.
• Increases visibility of project planning to all involved stakeholders of
the development process
• Increased and enhance development speed. Improved client relations.
• Helps you to decrease project risk and project management plan
overhead.
Stage1: planning and requirement analysis
 Requirement Analysis is the most important and fundamental stage
in SDLC.
 Getting input from all stakeholders, including customers,
salespeople, industry experts, and programmers.
 Learn the strengths and weaknesses of the current system with
improvement as the goal.
Stage 2: defining
 The team determines the cost and resources required for
implementing the analyzed requirements.
 It also details the risks involved and provides sub-plans for softening
those risks.
Stage 3: designing
 All stakeholders then review this plan and offer feedback and
suggestions.
Stage 4: coding
 At this stage, the actual development starts.
 It’s important that every developer sticks to the agreed blueprint.
 Proper guidelines in place about the code style and practices.
Stage 5: testing
 In this stage, we test for defects and deficiencies. We fix those issues
until the product meets the original specifications.
 Verify if the code meets the defined requirements.
Software deployment
 Deploy the software to the production environment so users can start
using the product.
 Testing or staging environment - This allows any stakeholders to
safely play with the product before releasing it to the market.
Maintenance
 Bug fixing - bugs are reported because of some scenarios which are
not tested at all
 Upgrade - Upgrading the application to the newer versions of the
Software
 Enhancement - Adding some new features into the existing software
PROBLEM SOLVING

In order to solve a problem by the computer, one has to pass though


certain stages or steps. They are
1) Understanding the problem
2) Analyzing the problem
3) Developing the solution
4) Coding and implementation.
To design a program, a programmer must determine three basic
steps
 The instructions to be performed.
 The sequence in which those instructions are to be performed.
 The data required to perform those instructions.

A program is set of instructions to instruct the computer to perform a task.


The instructions are three types,
1) Instructions to accept the data.
2) Instructions that will process the data.
3) Instructions to provide the output to user.
Problem development lifecycle
1) Problem analysis - Understand the problem to be solved.
Determines the various ways in which the problem can be solved,
and decides upon a single solution which will be followed to solve a
problem.
2) Program design – The selected solution represented in three forms
 An algorithm – English like explanation of the solution.
 A flowchart – Diagrammatic representation of the solution.
 A pseudo code – Pseudo code uses the structured programming
constructs called keyword statements.
3) Program Development
 The Pseudo code is coded using suitable programming
language. Like C, C++, and java.
 The coded program is compiled for any syntax errors then
errors removed during compilation.
 The successfully complied program is now ready for solution.
 The executed program generates the output which may be
correct or incorrect. The program is tested with various inputs,
to see that it generates the desired results. The semantic errors
are removed to get the correct results.
 The successfully tested program is ready for use.
4) Program Documentation and Maintenance
 The program is properly documented, The program may
require updating, fixing of errors etc, during the maintenance
phase.

Properties of a good program

Integrity: Integrity refers to the accuracy of the calculations.


Clarity: Overall readability of the program.
Simplicity: The clarity and accuracy of the program are usually enhanced
by keeping things as simple as possible.
Efficiency: Concerned with execution speed and efficient memory
utilization.
Modularity: Large program broken into series of identifiable small
subtask or module. It enhances the accuracy and clarity of the program.
Generality: Program should be general. It should read the values of
certain key parameters rather than fixed values.

Program Logic
• Logic is a just an idea or a blue print for a part of a program which
consists of set of instructions to solve the given problem.
• Logic of the program consists of the statements which will be then
converted into programming language statements that will be
executed by the computer in order to solve the problem.
Problem formulation:
Top down analysis: Subdivide the large problem into several small tasks
or parts for ease of analysis.
Two essential ideas in top down analysis:
Subdivision of a problem
Hierarchy of tasks
Four steps in top down analysis:
Step 1: Define the complete scope of the problem to determine the basic
requirement for its solutions.
Input: what data is required to be processed by the program?
Process: What must be done with the input data? What type of processing
is required?
Output: What information should the program produce? In what form
should it be presented?
Step 2: Based on the definition of the problem, divide the problem into two
or more parts/tasks.
Step 3: Define the scope of ease of these tasks and subdivide them further
if necessary, divide into two or more smaller tasks.
Step 4: Repeat step 3 at lowest level describes a simple tasks, which
cannot be broken further.

Algorithms
An algorithm is a
 well organized,
 Set of step-by-step instructions that perform a specific task or
operation
 Natural language NOT programming language
It helps the programmer in breaking down the solution of a problem into a
number of sequential steps.
Features:
 Finiteness. An algorithm must always terminate after a finite
number of steps.
 Definiteness. Each step of an algorithm must be precisely defined;
the actions to be carried out must be rigorously and unambiguously
specified for each case.
 Input. An algorithm has zero or more inputs, i.e., quantities which
are given to it initially before the algorithm begins.
 Output. An algorithm has one or more outputs i.e, quantities which
have a specified relation to the inputs.
 Effectiveness. An algorithm is also generally expected to be
effective. This means that all of the operations to be performed in the
algorithm must be sufficiently basic that they can in principle be done
exactly and in a finite length of time.
Properties of an algorithm:
 No ambiguity
 No uncertainty about which instruction to be executed next(written
in sequence)
 Conclude after a finite number of steps(algorithm will terminate)
 General enough to deal with any contingency
Factors used to measure the algorithm:
 Time
 Memory
 Accuracy
 Sequence etc,.
Flowcharts:
 It is the pictorial representation of an algorithm in which steps are
drawn in the form of different shapes of boxes and the logical flow is
indicated by interconnecting arrows.
 Boxes represent operations
 Arrows represent sequence in which operations are implemented
 Primary purpose : help programmer in understanding the logic
 Flowchart=Blue print of building

Flowchart Symbols:

 Terminal symbol
It is used to represent the start, end of the program logic.

 Input/output
It is used for input or output.

 Process Symbol
It is used to represent the calculations, data movements,
initialization ope rations etc,.

 Decision Symbol
It is used to denote a decision to be made at that point
 Flow lines
It is used to connect the symbols

 Connectors
It is used to connect the flow lines.

 Loop
It is used to denote loops involved in the process.

Guidelines for preparing flowcharts:


 It should be clear and easy to follow
 Standard symbols should be used.
 The flow lines should not intersect each others.
 In case of complex flowcharts use the connectors symbols.
 Direction of flow of procedure is from left to right or top to bottom
 It must have one logical start and end.
 Only one flow line should enter the process symbol and only one flow
line should come out from a process symbol.

 Only one flow line used with the terminal symbol.


 Only one flow line should enter the decision symbol and two or three
flow lines may leave from the decision symbol.

Benefits of Flowcharts:
 Makes logic clear
 Communication: Flowcharts are better way of communicating the
logic of a system
 Effective analysis: Problem can be analyzed in more effective way.
 Proper documentation: Flowcharts serve as a good program
documentation
 Efficient Coding: Flowcharts act as a guide or blueprint during the
systems analysis and program development phase.
 Proper testing and Debugging: Flowchart helps in debugging
process.
 Efficient Program Maintenance: The maintenance of operating
program becomes easy with the help of flowchart.

Limitations of Using Flowcharts:


 Complex logic: Sometimes, the program logic is quite complicated.
In that case, flowchart becomes complex and clumsy.
 Difficult to modify: Alterations and Modifications- If alterations
are required the flowchart may require re-drawing completely.
 No update: Programs are updated regularly
Pseudo code
 Pseudo means imitation and code means instruction.
 It is formal design tool.
 It is an outline of a program ,written in a form that can be easily
converted in a real programming statements
 It is also called PDL-Program Design Language(Uses plain
English statements to represent computer programs)
Keywords used:
 Input : READ,OBTAIN,GET and PROMPT
 Output :PRINT,DISPLAY and SHOW
 Compute: COMPUTE,CALCULATE and DETERMINE
 Initialize :SET and INITIALIZE
 Add one : INCREMENT

Guideline for writing Pseudo code:


 Simple English
 Understandable
 Concise
 Each instruction in separate line & each statement express one
action
 Capitalize the keyword.
 Top to bottom, with on entry and one exit
 Easy transition from design to coding in programming language

BUILDING BLOCKS OF ALGORITHM


 Algorithm can be constructed from basic building blocks namely
Statements
State
control flow
functions
 Statement is a single action in a computer.
In a computer statements might include some of the following actions
Input data-information given to the program
Process data-perform operation on a given input
Output data-processed result
 State - Transition from one process to another process under
specified condition within a time is called state.
 Control Flow –
The process of executing the individual statements in a given order is
called control flow.
The control can be executed in three ways
Sequence
Selection
Iteration

Sequence

All the instructions are executed one after another is called sequence
execution.
Example: Add two numbers
Step 1: Start
Step 2: get a,b
Step 3: Calculate c=a+b
Step 4: Display c
Step 5: Stop

Selection

 A selection statement causes the program control to be transferred to


a specific part of the program based upon the condition.
 If the conditional test is true, one part of the program will be
executed, otherwise it will execute the other part of the program.

Example: Greatest among two numbers


Step 1: Start
Step 2: Read a, b . /* a, b two numbers */
Step 3: If a>b then /*Checking */
Display “a is the largest number”.
Else
Display “b is the largest number”.
Step 4: Stop.
Iteration
In some programs, certain set of statements are executed again and
again based upon conditional test. i.e. executed more than one time.
This type of execution is called looping or repetition or iteration.

Example: Write an algorithm to print all natural numbers up


to n
Step 1: Start
Step 2: get n value.
Step 3: initialize i=1
Step 4: if (i<=n) go to step 5 else go to step 7
Step5: Print i value and increment i value by 1
Step 6: go to step 4
Step 7: Stop
 Functions
 Function is a subprogram which consists of block of code (set of
instructions) that performs a particular task.
 For complex problems, the problem is been divided into smaller and
simpler tasks during algorithm design.

Mainfunction()

Step 1: Start
Step 2: Call the function add()
Step 3: Stop

Sub function add()

Step1:Function start
Step2:Get a,b Values
Step 3: add c=a+b
Step 4: Print c
Step 5: Return
Examples:
Algorithm Flowchart Pseudocode
Addition of two numbers
Step1: Start READ a,b
Step2: Read two C=a+b
numbers say a, b WRITE C
Step3: Add the value of STOP
a with b and store the
result in c.
Step4: Display the
value of c
Step5: Stop

Odd or even
Step 1:Start START
Step 2: read a Number READ number
Step 3:if (Number%2) IF number MOD 2=0 THEN
is 0,Print/Show as DISPLAY “ Even Number”
even number else ELSE
show as odd number DISPLAY “Odd Number”
Step 4: Stop END IF
STOP
Largest number among 3 numbers
Step1: Start READ a, b, c
Step2: Read the IF (a>b) and (a>c) THEN
value of a, b, c WRITE a is largest
Step3: Check if ELSE IF (b>c) THEN
(a>b) and (a>c) WRITE b is largest
then, print a is ELSE
largest WRITE c is largest
else check if (b>c) ENDIF
then, print b is STOP
largest
else
print c is largest
Step4: Stop

Finding the area of a circle


Step1: Start Begin
Step2: Read the READ r
value of r COMPUTE area=3.14*r*r
Step3: Calculate PRINT area
area stop
Step4: Print area
Step5: Stop
Finding the year is leap year or not
Step1: Start READ year
Step2: Read the IF year % 4 ==0 THEN
value of year WRITE It is a Leap year
Step3: ELSE
IF year % 4 ==0 WRITE It is not a Leap
THEN year
print It is a Leap ENDIF
year Stop
ELSE
print It is not a
Leap year
Step4: Stop

Finding the Sum of the digits


Step1: Start READ the value of n and
Step2: set i =0, sum=0
Read the value of n WHILE (n>0) do
and set sum = 0 r=n%10
Step3: sum=sum + r
While n>0 do n=n/10
r=n%10 ENDWHILE
sum=sum + r Repeat the loop until
n=n/10 condition fails
else Goto step5 WRITE sum
Step4: Goto step 3 Stop
Step5: Print the
value of sum
Step6: Stop
Finding the Reverse of a Number
Step1: Start READ the value of n and
Step2: Read the value set i =0, sum=0
of n and set sum = 0 WHILE (n>0) do
Step3: While n>0 do r=n%10
r=n%10 sum=sum *10 + r
sum=sum *10 + r n=n/10
n=n/10 ENDWHILE
else Goto step5 Repeat the loop until
Step4: Goto step 3 condition fails
Step5: print the value WRITE sum
of sum stop
Step6: Stop

Finding the Armstrong Number


Step1: Start READ the value of n and
Step2: Read the value set a =n, sum=0
of n ,set a = n,sum = 0 WHILE (n>0) do
Step3: While n>0 do r=n%10
r=n%10 sum=sum + r*r*r
sum=sum + r*r*r n=n/10
n=n/10 ENDWHILE
else Goto step5 Repeat the loop until
Step4: Goto step 3 condition fails
Step5: If a = sum then IF a=sum THEN
Print Armstrong WRITE Armstrong
Number Number
Else ELSE
Print It is Not an WRITE It is not an
Armstrong Number Armstrong Number
Endif ENDIF
Step6: Stop Stop
Finding the Fibonacci series
Step1: Start READ the value of n and
Step2: Read the value set f=0 ,f1=-1, f2=1
of n and set f=0,f1=- WHILE (f<n) do
1, f2=1 f=f1+f2
Step3: While (f<n) do f1=f2
f=f1+f2 f2=f
f1=f2 WRITE f
f2=f ENDWHILE
Print f Repeat the loop until
else Goto step5 condition fails
Step4: Goto step 3 stop
Step5: Stop

Finding the Sum of odd number between 1 to n


Step1: Start READ the value of n and
Step2: Read the value set sum=0,i=1
of n and set WHILE (i<=n) do
sum=0,i=1 sum=sum+i
Step3: While (i<=n) i=i+2
do ENDWHILE
sum=sum+i Repeat the loop until
i=i+2 condition fails
else Goto step5 WRITE sum
Step4: Goto step 3 stop
Step5: Print sum
Step6: Stop
Finding the Sum of even number between 1 to n
Step1: Start READ the value of n and
Step2: Read the value set sum=0,i=0
of n and set WHILE (i<=n) do
sum=0,i=0
Step3: While (i<=n) sum=sum+i
do i=i+2
sum=sum+i ENDWHILE
i=i+2 Repeat the loop until
else Goto step 5 condition fails
Step4: Goto step 3 WRITE sum
Step5: Print sum stop
Step6: Stop

Conversion of Binary number to Decimal


Step1: Start READ the value of n and
Step2: Read the value set i =0, sum=0
of n & set i = 0, sum = 0 WHILE (n>0) do
Step3: While n>0 do r=n%10
r=n%10 sum=sum + r*pow(2,i)
sum=sum + r*pow(2,i) n=n/10
n=n/10 i=i+1
i=i+1 ENDWHILE
else Goto step5 Repeat the loop until
Step4: Goto step 3 condition fails
Step5: print the value WRITE sum
of sum stop
Step6: Stop
Conversion of Celsius to Fahrenheit
Step1: Start Set Fahrenheit
Step2: Read the value READ the Celsius
of Celsius COMPUTE Fahrenheit =
Step3: Fahrenheit = (1.8* Celsius) + 32
(1.8* Celsius) + 32 PRINT Fahrenheit
Step4: Print stop
Fahrenheit
Step5: Stop

Conversion of Fahrenheit to Celsius


Step1: Start Set Celsius
Step2: Read the value READ the Fahrenheit
of Fahrenheit COMPUTE Celsius
Step3:Calculate Celsius =(Fahrenheit – 32)/1.8
=(Fahrenheit – 32)/1.8 PRINT Celsius
Step4: Print Celsius stop
Step5: Stop

Finding the Factorial


Step1: Start READ the value of n and
Step2: Read the value set i =1
of n and set i =1 WHILE (i <= n) do
Step3: While i <= n do fact =fact * i
fact =fact * i i=i+1
i=i+1 ENDWHILE
else Goto step5 Repeat the loop until
Step4: Goto step 3 condition fails
Step5: print the value WRITE fact
of fact stop
Step6: Stop
Swapping two variables
Step1: Start READ the value of a, b
Step2: Read the value To swap use
of a, b c=a
Step3: c = a a=b
a=b b=c
b=c WRITE a, b
Step4: Print the value stop
of a and b
Step5: Stop

Swapping two variables without using another variable


Step1: Start READ the value of a, b
Step2: Read the value To swap use
of a, b a=a+b
Step3: a = a + b b=a-b
b=a-b a=a-b
a=a-b WRITE a, b
Step4: Print the value stop
of a and b
Step5: Stop

You might also like