Unit 1: Algorithm and Programming Development

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 23

Unit 1

Algorithm and Programming Development


1. Program Development Life Cycle

The program development life cycle is a set of steps or


phases that are used to develop a program in any
programming language.

Problem Definition
Problem Analysis
Algorithm Development
Coding & Documentation
Testing & Debugging
Maintenance
1. Problem Definition
• In this phase, we define the problem statement and we decide
the boundaries of the problem. In this phase we need to
understand the problem statement, what is our requirement,
what should be the output of the problem solution.

2. Problem Analysis
• In phase 2, we determine the requirements like variables,
functions, etc. to solve the problem. That means we gather
the required resources to solve the problem defined in the
problem definition phase.
3. Algorithm Development
• During this phase, we develop a step by step procedure to
solve the problem using the specification given in the previous
phase. That means we write the solution in step by step
statements.

4. Coding & Documentation


• This phase uses a programming language and construct actual
program. That means we write the program to solve the given
problem using programming languages like C, C++, Java etc.,
5. Testing & Debugging
• During this phase, we check whether the code written in
previous step is solving the specified problem for various input
data values or not.

6. Maintenance
• In this phase, the solution (program) is used by the end user. If
the user encounters any problem or wants any enhancement,
then we need to repeat all the phases from the starting, so
that the encountered problem is solved or enhancement is
added.
2. Flow charts and Algorithm development

• Algorithm and flowchart are two types of tools to explain the


process of a program.

• Algorithm:: To write a logical step-by-step method to solve the


problem is called algorithm, in other words, an algorithm is a
procedure for solving problems. An algorithm includes
calculations, reasoning and data processing. Algorithms can be
presented by natural languages, pseudo code etc.

• Flowchart:: A flowchart is the graphical or pictorial


representation of an algorithm with the help of different
symbols, shapes and arrows in order to demonstrate a process
or a program.
Several standard graphics are applied in a flowchart:
• Terminal Box - Start / End

• Input / Output

• Process / Instruction

• Decision

• Connector / Arrow
• Algorithm Example 1: Write an algorithm to add two nos.
• Step1: start
Step2: Read a, b
Step3: sum = a + b
Step4: write sum
Step5: stop
3. Program Debugging
• Debugging is the routine process of locating and removing
computer program bugs, errors, which is methodically handled by
software programmers via debugging tools.

• Debugging checks, detects and corrects errors or bugs to allow


proper program operation according to set specifications.

• A program may have bugs, or errors, so these bugs must be


removed; a process called debugging.

• Some bugs are easy to remove; others can be difficult. These bugs
may appear at compile time and run time.
Problems
• Write a algorithm for multiplication of 3 numbers.
• Write a algorithm for division of 2 numbers.
• Write a algorithm for finding greatest among 3 numbers.

• Draw a flowchart for multiplication of 3 numbers.


• Draw a flowchart for division of 2 numbers.
• Draw a flowchart for finding greatest among 3 numbers.
Computer languages
Computer languages
• High level language: We generally write a computer program
using a high-level language. A high-level language is one which
is understandable by us humans. It contains words and
phrases from the English (or other) language.

• A program written in high-level language is called a source


code.

• Machine level language:: But a computer does not


understand high-level language. It only understands program
written in 0's and 1's in binary, called the machine code.
• Assembly language:: an assembly language is a low level
language for microprocessors and other programmable
devices.

• It works directly with the microprocessor

• An assembly language is the most basic programming


language available for any processor. With assembly language,
a programmer works only with operations that are
implemented directly on the physical CPU.
Diagrammatic representation
of running a C program
Compiler
• We need to convert the source code into machine code and
this is accomplished by compilers and interpreters.

• A compiler is a program that Translate one language (source


language)to another(target language).

• Takes as input a source program typically written in a high level


language and produces an equivalent target program typically
in machine language.

• As an important part of this translation process, the compiler


report to its user the presence of error in the source program.
Interpreter

• An interpreter is a program which translates statements of a


program into machine code. It translates only one statement
of the program at a time.

• It reads only one statement of program, translates it and


executes it. Then it reads the next statement of the program
again translates it and executes it. In this way it proceeds
further till all the statements are translated and executed.

• If an error occurs, an interpreter stops execution and reports


it.
Assembler

A program which translates an assembly language program into


a machine language program is called an assembler.

An assembler translates assembly language programs into


machine code.

The output of a assembler is called an object file, which contains


a combination of machine instruction as well as the data
required to place these instructions in memory.
Linker
• In high level languages, some built in header files or libraries are
stored.

• These libraries are predefined and these contain basic functions


which are essential for executing the program.

• These functions are linked to the libraries by a program called


Linker.

• If linker does not find a library of a function then it informs to


compiler and then compiler generates an error.

• The compiler automatically invokes the linker as the last step in


compiling a program.
Loader:
• Loader is a program that loads machine codes of a program
into the system memory.

• In Computing, a loader is the part of an Operating System that


is responsible for loading programs. It is one of the essential
stages in the process of starting a program.

• Because it places programs into memory and prepares them


for execution.

• Loading a program involves reading the contents of executable


file into memory.
Compiler Interpreter

1. Compiler takes entire program 1. It takes single instruction as


as input. input.

2. Intermediate object code is 2. No Intermediate object code is


generated. generated

3. Memory requirement is more 3. Memory requirement is less


since object code is generated. because machine codes produced
by interpreter are not saved.
4. A compiler is 5 to 25 times
faster than an interpreter 4. Every time high level language is
because program need not to convert into low level program.
be compiled every time.
5. An interpreter is a small program
5. The machine codes are saved as compared to compiler.
permanently for future
reference.

You might also like