0% found this document useful (0 votes)
138 views6 pages

Algorithm: - It Is A Finite Set of Instructions That Represent The Step by Step Logical Procedures For

An algorithm is a set of steps to solve a problem. It must be definite, finite, and effective. Algorithms can be expressed in pseudocode using English-like sentences. This document provides examples of algorithms to calculate the average of 3 numbers, sum of n numbers, factorial of a number, and reverse of a number. It also defines a flowchart as a pictorial representation of an algorithm using standardized symbols like terminals, inputs/outputs, processing, flow lines, decisions, connectors, predefined processes, and annotations to show the sequence of steps without errors. Examples of drawing flowcharts for adding two numbers, finding the largest of three numbers, finding the roots of a quadratic equation, and the Fibonacci series are given.

Uploaded by

Pawan Nani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
138 views6 pages

Algorithm: - It Is A Finite Set of Instructions That Represent The Step by Step Logical Procedures For

An algorithm is a set of steps to solve a problem. It must be definite, finite, and effective. Algorithms can be expressed in pseudocode using English-like sentences. This document provides examples of algorithms to calculate the average of 3 numbers, sum of n numbers, factorial of a number, and reverse of a number. It also defines a flowchart as a pictorial representation of an algorithm using standardized symbols like terminals, inputs/outputs, processing, flow lines, decisions, connectors, predefined processes, and annotations to show the sequence of steps without errors. Examples of drawing flowcharts for adding two numbers, finding the largest of three numbers, finding the roots of a quadratic equation, and the Fibonacci series are given.

Uploaded by

Pawan Nani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 6

Algorithm: - it is a finite set of instructions that represent the step by step logical procedures for

solving a problem

Properties of Algorithms:-
(1) input:- zero or more inputs
(2) output – at least one quantity is produced
(3) Definiteness – each instruction is clean and unambiguous.
(4) Finiteness – the algorithm should terminate after a finite number of steps. It should not
enter into infinite loop.
(5) Effectiveness: - each operation must be simple and should complete in a finite time.
Algorithm can be written in English like sentences. Algorithm written in English like language is
called pseudo code.

 Write an algorithm for finding average of given 3 numbers?


(A) step -1 : Read values
Read A,B and C
Step -2: Compute
Sum = A + B + C.
Avg = Sum/3.
Step -3: Display O/P.
Print Avg.
Step – 4: Stop.

(2) Write an algorithm for finding sum of given ‘n’ numbers.


(A) step -1 : Read values
Read N.
Step -2: Initialization.
Count=1; Sum = 0;
Step -3: Perform the Loop
Repeat through step -4 while count <=n
Step – 4: Read and Compute
Read x
Sum=Sum+x;
Count=Count+1;
Step -5: Display O/P.
Print Sum.
Step – 6: Stop.
(3) Write an algorithm for factorial of a given number.
(A) Step -1: Read values
Read N.
Step -2: Initialization.
Count=1; Fact = 1;
Step -3: Perform the Loop
Repeat through step -4 while count <=n
Step – 4: Compute
Fact = Fact * Count
Count=Count+1;
Step -5: Display O/P.
Print Fact.
Step – 6: Stop.
(4) Write an algorithm for finding the reverse of a given number
(A) Step -1: Read values
Read N.
Step -2: Initialization.
Rev = 0;
Step -3: Perform the Loop
Repeat through step -4 while n>0.
Step – 4: Compute
Rev = Rev * 10 + N mod 10
N = N /10;
Step -5: Display O/P.
Print Rev.
Step – 6: Stop.

Flowchart:-
A Flowchart is a practical representation of an algorithm that uses boxes of different
shapes to denote different types of instructions.

à A flowchart shows the flow of operations in pictorial form, any error in the logic of the problem
can be detected very easily.
Flowchart symbols:-
A few symbols are needed to indicate the necessary operations in a flowchart. These symbols
have been standardized by the ANSI(American National Standard Institute).

I. Terminal:- The terminal (oval) symbol as the name implies is used to indicate the
beginning <START>, ending <STOP> and pause <HALT> in the program logic flow.

It is the first and last symbol in the program logic.

II. Input/Output:- The input/output(parallelogram) symbol is used to denote any function of an


Input/output device in the program.

III. Processing:- A processing symbol (Rectangle) is used in a flowchart to represent


arithmetic and data movement instructions.

IV. Flow lines:- Flow lines with arrow Heads are used to indicate the flow operations i.e. the
exact sequence in which the instructions are to be executed.
V. Decision :- The decision <Diamond> symbol is used in a Flowchart to indicate a point at
which a decision has to be made and a branch to one of two or more alternate points is
possible.

VI. Connectors: - if a flowchart becomes very long the flow lines start crises crossing at many
places that cause confusion and reduce understandability of the flowchart.

VII. Predefined Process:- the predefined process(Double sided rectangle) symbol is used in
flowcharts to indicate modules or subroutines are specified.

VIII. Annotation: - The annotation (Bracket with broken line) symbol is used in flowcharts to
indicate the descriptive comments or explanation of the instruction.

----------------

Some Examples of Drawing flowcharts:

Draw a flowchart to add two numbers entered by user.


Draw flowchart to find the largest among three different numbers entered by user.
Draw a flowchart to find all the roots of a quadratic equation ax 2+bx+c=0
Draw a flowchart to find the Fibonacci series till term≤1000.

You might also like