0% found this document useful (0 votes)
3 views8 pages

Algorithm

The document provides an overview of algorithms, defining them as step-by-step procedures for problem-solving, and introduces pseudo code as a written form of algorithms. It outlines five essential properties of algorithms and presents several examples, including algorithms for adding numbers, finding the largest number, calculating factorials, checking for prime numbers, and generating Fibonacci series. Additionally, the document explains flowcharts as graphical representations of algorithms, detailing various symbols used in flowcharts and providing examples of flowcharts for different scenarios.

Uploaded by

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

Algorithm

The document provides an overview of algorithms, defining them as step-by-step procedures for problem-solving, and introduces pseudo code as a written form of algorithms. It outlines five essential properties of algorithms and presents several examples, including algorithms for adding numbers, finding the largest number, calculating factorials, checking for prime numbers, and generating Fibonacci series. Additionally, the document explains flowcharts as graphical representations of algorithms, detailing various symbols used in flowcharts and providing examples of flowcharts for different scenarios.

Uploaded by

srujansamala07
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Algorithm

Algorithm is a step – by – step procedure which is helpful in solving a problem. If, it is written in
English like sentences then, it is called as ‘PSEUDO CODE’.

Properties of an Algorithm
An algorithm must possess the following five properties −

 Input
 Output
 Finiteness
 Definiteness
 Effectiveness
Algorithm 1: Add two numbers entered by the user
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 5: Display sum
Step 6: Stop
Algorithm 2: Find the largest number among three numbers
Step 1: Start
Step 2: Declare variables a,b and c.
Step 3: Read variables a,b and c.
Step 4: If a > b
If a > c
Display a is the largest number.
Else
Display c is the largest number.
Else
If b > c
Display b is the largest number.
Else
Display c is the greatest number.
Step 5: Stop

Algorithm 3: Find the factorial of a number


Step 1: Start
Step 2: Declare variables n, factorial and i.
Step 3: Initialize variables
factorial ← 1
i←1
Step 4: Read value of n
Step 5: Repeat the steps until i = n
5.1: factorial ← factorial*i
5.2: i ← i+1
Step 6: Display factorial
Step 7: Stop

Algorithm 4: Check whether a number is prime or not


Step 1: Start
Step 2: Declare variables n, i, flag.
Step 3: Initialize variables
flag ← 1
i←2
Step 4: Read n from the user.
Step 5: Repeat the steps until i=(n/2)
5.1 If remainder of n÷i equals 0
flag ← 0
Go to step 6
5.2 i ← i+1
Step 6: If flag = 0
Display n is not prime
else
Display n is prime
Step 7: Stop

Algorithm 5: Find the Fibonacci series till the term less than 1000
Step 1: Start
Step 2: Declare variables first_term,second_term and temp.
Step 3: Initialize variables first_term ← 0 second_term ← 1
Step 4: Display first_term and second_term
Step 5: Repeat the steps until second_term ≤ 1000
5.1: temp ← second_term
5.2: second_term ← second_term + first_term
5.3: first_term ← temp
5.4: Display second_term
Step 6: Stop
Flowchart

The Flowchart is the most widely used graphical representation of an algorithm and procedural
design workflows. It uses various symbols to show the operations and decisions to be followed in
a program. It flows in sequential order.

Flowchart symbols:
Terminal Symbol: In the flowchart, it is represented with the help of a circle for denoting the
start and stop symbol. The symbol given below is used to represent the terminal symbol.

Input/output Symbol: The input symbol is used to represent the input data, and the output
symbol is used to display the output operation. The symbol given below is used for representing
the Input/output symbol.

Processing Symbol:It is represented in a flowchart with the help of a rectangle box used to
represent the arithmetic and data movement instructions. The symbol given below is used to
represent the processing symbol.
Decision Symbol: Diamond symbol is used for represents decision-making statements. The
symbol given below is used to represent the decision symbol.

Connector Symbol:The connector symbol is used if flows discontinued at some point and
continued again at another place. The following symbol is the representation of the connector
symbol.

Flow lines: It represents the exact sequence in which instructions are executed. Arrows are used
to represent the flow lines in a flowchart. The symbol given below is used for representing the
flow lines:

Hexagon symbol (Flat): It is used to create a preparation box containing the loop setting
statement. The symbol given below is used for representing the Hexagon symbol.
Develop a flowchart to illustrate how to make a Land phone telephone call
Design a flowchart for checking whether the number is positive or negative according to the
number entered by the user.

Draw a flowchart to find out the biggest of the three unequal positive numbers.
Draw a flowchart for adding the integers from 1 to 100 and to print the sum.

ABC company plans to give a 6% year-end bonus to each of its employees earning Rs 6,000 or
more per month , and a fixed Rs 250/- -bonus to the remaining employees. Draw a flowchart for
calculating the bonus for an employee

You might also like