0% found this document useful (0 votes)
2 views46 pages

Algorithm & Flowchart

Uploaded by

ruchiiraulstd99
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)
2 views46 pages

Algorithm & Flowchart

Uploaded by

ruchiiraulstd99
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

Introduction to

Algorithm and Flowchart

C PROGRAMMING COURSE

VISIT US AT
[Link]
Q1) What is a computer program?
A computer program is a sequence of instructions written using a Computer Programming Language to
perform a specified task by the computer.

-------------------------------------------------------------------------------------------------------------------------------------------
Q2) What is computer programming?
Computer programming is the act of writing computer programs, which are a sequence of instructions
written using a Computer Programming Language to perform a specified task by the computer.

-------------------------------------------------------------------------------------------------------------------------------------------
Q3) Need of computer programming. (MAY 17)

1. To solve any problem we have to first build the logic i.e we have to write Algorithms.

th
2. Once an algorithm is formed next step is to transform it into a program so that our computer can
execute it.

ep
3. To convert an algorithm into a program, we need a programming language.

4. Computers only understand 1s and 0s i.e. Binary language. There are two types of Programming
languages - The language which is close to computer language i.e. we can easily convert it into 0s and 1s
is called low level language
D
In
5. We can write a code in pure 1’s & 0’s but it would be very complex & time consuming because we need
to convert each & every step of algorithm into machine dependent codes of 1’s & 0’s manually.
hs

6. That’s why we use high level language. Syntax of high level language is similar to human language like
English. It also has set of grammar which makes it easy for developer to write programs and correct
errors in it.
at

7. It is very important to note that every program which is written in higher level language gets converted
into low level machine language through translators like compiler.
M

8. The high level programming language is easy to read while you cannot interpret low level language
code directly. Also high level language codes are portable (means same program can run on different
machines) & easy in development where as

9. The low-level programming language is not portable i.e code written on the machine might not run on
different machine & it is not easy to develop.
th
ep
D
-------------------------------------------------------------------------------------------------------------------------------------------
Q4) What is programming language?
In
A programming language is a formal constructed language designed to communicate instructions to a
machine, particularly a computer. Programming languages can be used to create programs to control
hs

the behaviour of a machine or to express algorithms.

Q5) Classify the programming languages.


at

What do you mean by high-level and low-level programming languages? Differentiate between
them.
M

The main difference between high level language and low level language is that, Programmers
can easily understand or interpret or compile the high level language in comparison of machine.
On the other hand, Machine can easily understand the low level language in comparison of
human beings.

There are two main categories of programming language:


a. High level language
b. Low level language
High-level languages are classified as procedural, non-procedural and problem-oriented languages

1. Procedural Languages: If User has to specify “what to do” and also “how to do” i.e step by step
procedure then such languages are nothing but procedural languages.

Examples: C, java, python etc.

2. Non-procedural Languages: A non-procedural language also called a declarative language requires


the programmer to specify what the program should do, rather than providing the sequential steps
indicating how the program should perform its tasks.

Example: PROLOG which is related to artificial intelligence, SQL for data base query

3. Problem-oriented Languages: There are some specific high level languages designed to solve specific
category of problems

th
Example: MATLAB for numerical, LATEX to write mathematical expressions in web pages.

ep
Low level languages can be classified into two categories -

1. Machine Language: Machine Language is purely written in the form of 1’s & 0’s & can be executed by
D
machine directly and hence known as machine language
In
2. Assembly Language: Assembly language is the language which is close to format of CPU instructions.
Assembly language is dependent on machine in which user wants to execute instructions.
hs

Every high level language is converted into assembly language & then from assembly language
conversion to machine code can be done efficiently.
at

[Link] HIGH LEVEL LANGUAGE LOW LEVEL LANGUAGE


1 It is programmer friendly language. It is a machine friendly language.
M

2 High level language is less memory Low level language is high memory efficient.
efficient.
3 It is easy to understand. It is tough to understand.
5 It is simple to maintain. It is complex to maintain comparatively.
6 It is portable. It is non-portable.
7 It can run on any platform. It is machine-dependent.
8 It needs compiler or interpreter for It needs assembler for translation.
translation.
9 One instruction = many machine code One instruction = many machine code
Instructions. instructions
th
-------------------------------------------------------------------------------------------------------------------------------------------
Q6) Features of good programming Languages

ep
Some special features of good programming languages are given below:

• Simplicity: Simple programming language is easy in learning and coding. All the programmers like
D
this type of language.
• Naturalness: A language should be natural and problem oriented. Many languages have a key
In
word (English word) like e.g., READ – DATA, PRINT, printf, writeln, DISPLAY, etc.
• Efficiency: Efficiency of programs coding, error handling, problem solving are major criteria of
higher languages. Efficient languages are widely accepted and used major problem area.
hs

• Compactness: Verbose languages have no compactness. In case of COBOL, lack of compactness is


a major drawback. In PASCAL, C, C ++, JAVA, these drawbacks are removed. So, indented
operations can be coded very concisely.
at

• Extensibility: A good programming language should allow extension through simple, natural, and
elegant mechanism.
M

• Suitability: A language should be suitable to working environment .For instance, a program


designed for data processing job should be operative in batch mode.
Q7) What is an algorithm? Which points you should consider while developing an
algorithm? (Dec 13, May 14, May 16, DEC 18)

1. The algorithm is the sequence of steps required to accomplish a task.

2. An algorithm is an effective procedure for solving a problem in a finite number of steps.

3. A well-designed algorithm will always provide an answer; it may not be the desired answer but there
will be an answer. It may be that the answer is that there is no answer. A well- designed algorithm is also
guaranteed to terminate.

4. Computer scientist Niklaus Wirth stated that

Program = Algorithms + Data

th
ep
DEFINITION:-

“Algorithm is a step by step procedure, which defines a set of instructions to be executed


D
in a certain order to get the desired output. Algorithms are generally created
independent of underlying languages, i.e. an algorithm can be implemented in more
In
than one programming language.”
hs

EXPLANATION:-
To make a computer do anything, we have to write a computer program. To write a computer
at

program, we have to tell the computer, step by step, exactly what we want it to do. The computer then
"executes" the program, following each step mechanically, to accomplish the end goal.
M

When we are telling the computer what to do, we also get to choose how it's going to do it. That's where
computer algorithms come in. The algorithm is a list of instruction for accomplishing a task. Let's follow
an example to help get an understanding of the algorithm concept.

Let's say that you have a friend arriving at the station, and your friend needs to get from the station to
your house. Here are four different algorithms that you might give your friend for getting to your home:

1. The taxi algorithm:

Go to the taxi stand.

Get in a taxi.

Give the driver my address.


2. The call-me algorithm:

When your train arrives, call my cell phone.


Meet me outside platform 2.

3. The rent-a-car algorithm:

Take the shuttle to the rental car place.

Rent a car.

Follow the directions to get to my house.

th
4. The bus algorithm:
Outside platform 1, catch bus number 70.

ep
Transfer to bus 14 on Main Street.
Get off on Elm Street.
Walk two blocks north to my house.
D
All four of these algorithms accomplish exactly the same goal, but each algorithm does it in a completely
In
different way. Each algorithm also has a different cost and a different travel time. Taking a taxi, for
example, is probably the fastest way, but also the most expensive. Taking the bus is definitely less
expensive, but a whole lot slower. You choose the algorithm based on the circumstances.
hs
at
M
Q8) Characteristics of a good Algorithm / Points to be considered while developing an
Algorithm:

Not all procedures can be called an algorithm. An algorithm should have the below mentioned
characteristics −

th
ep
D
In
hs
at
M
Q9) CONTROL STRUCTURE /Key features of Algorithms:-

Algorithm uses the three types of control structures. They are:

1. Sequence (Process)
2. Decision(Selection)
3. Loop (Repetition)

1. These three control structures are sufficient for all purposes. The sequence is exemplified by
sequence of statements place one after the other – the one above or before another gets
executed first. In flowcharts, sequence of statements is usually contained in the rectangular
process box.
2. The decision/branch refers to a binary decision based on some condition. If the condition is true,

th
one of the two branches is explored; if the condition is false, the other alternative is taken. This is
usually represented by the ‘if-then’ construct in pseudo-codes and programs. In flowcharts, this is
represented by the diamond-shaped decision box. This structure is also known as the selection

ep
structure.
3. The loop allows a statement or a sequence of statements to be repeatedly executed based on
some loop condition. It is represented by the ‘while’ and ‘for’ constructs in most programming
D
languages, for unbounded loops and bounded loops respectively. (Unbounded loops refer to
those whose number of iterations depends on the eventuality that the termination condition is
In
satisfied; bounded loops refer to those whose number of iterations is known before-hand.) In the
flowcharts, a back arrow hints the presence of a loop. A trip around the loop is known as iteration.
hs

You must ensure that the condition for the termination of the looping must be satisfied after some
finite number of iterations, otherwise it ends up as an infinite loop, a common mistake made by
inexperienced programmers. The loop is also known as the repetition structure.
at
M
Q10) How to represent an Algorithm?

th
ep
D
There are three basic methods to represent any algorithm each of these methods are appropriate
In
according to the desired situation which will be explained later in this chapter:-

The three techniques are as listed below :-


hs

1) Step-form (written form): In this method of representation, the whole procedure is written in a
sequential manner step by step in English statements. Each statement solves a problem and all steps
together solves a complete problem. The steps have logical relation with preceding steps.
at

2) Pseudocode representation (written form): Pseudocode representation is a simpler version of a


M

programming code in plain English which uses short phrases to write code for a program before it is
implemented in a specific programming language. Usually, instructions are written in uppercase,
variables in lowercase and messages in sentence case.

3) Flowchart (graphical way): A flowchart is the graphical or pictorial representation of an algorithm


using different symbols, shapes and arrows in order to demonstrate a process or a program. The main
purpose of the flowchart is to analyse different processes which makes it easy to understand.
Step-form:-

In this method of representation, the whole procedure is written in a sequential manner step by
step in English statements

Before writing a step form for a problem, one should find out what is/are the inputs to the algorithm
and what is/are expected output after running the algorithm.

Now let us take some exercises to develop an algorithm for some simple problems: While writing
algorithms we will use following symbol for different operations:

‘ + ’ for Addition

‘ - ’ for Subtraction

th
‘ * ’ for Multiplication

ep
‘ / ’ for Division and

‘ ← ’ for assignment. For example A← X*3 means A will have a value of X*3.
D
In
hs
at
M
Example of Algorithms in step form:-

Problem1: Write an algorithm to read two numbers and find their sum.

Inputs to the algorithm:


First num1.
Second num2.

Expected output:
Sum of the two numbers.

Algorithm in Step Form:

th
Step 1 : Start

ep
Step 2 : PRINT “Enter two Numbers”
Step 3 : INPUT X,Y
Step 4 : S ← X + Y
Step 5 : PRINT “Sum of two numbers is = ” S
D
Step 6 : STOP
In
hs
at
M
FLOWCHARTS
Q11) What are Flowcharts?

“A program flowchart is a graphical representation of the algorithm or logical steps of a program.”

A flowchart is a diagram made up of boxes, diamonds and other shapes, connected by arrows - each shape
represents a step in the process, and the arrows show the order in which they occur.

Flowcharting combines symbols and flowlines, to show figuratively the operation of an algorithm which
makes it self-explanatory.

The Flowcharts are more useful when the algorithms are large in size.

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

th
Q12) Explain need of Flowchart.

ep
D
In
hs
at
M
Q13) Explain Symbols used in flowcharts. What do you mean by flowchart? (MAY
17). List & Explain symbols used in drawing a flowchart. (DEC 17)

Following are the symbols which are typically used to develop the algorithms:

th
ep
D
In
hs
at
M
M
at
hs
In
D
ep
th
M
at
hs
In
D
ep
th
Q14) Steps required while constructing a Flowchart OR Writing an algorithm.

th
ep
D
In
hs
at
M
th
ep
D
In
Q15) Flow chart for if else, while. True IF False
hs

Conditions
• Flowchart for if – else
at
M

Sequence 1 Sequence 2
• Flowchart for While

FALSE
𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪

TRUE

𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺 𝑺𝑺

𝑺𝑺𝑺𝑺
-------------------------------------------------------------------------------------------------------------------------------------------

th
Q16) State advantages and disadvantages of Flowchart.

Please watch the videos and note down important points. CLICK HERE

ep
-------------------------------------------------------------------------------------------------------------------------------------------

Q17) what is an Algorithm? How do you develop an Algorithm? (DEC 16)


D
Please watch the videos and note down important points. CLICK HERE
In
-------------------------------------------------------------------------------------------------------------------------------------------
hs
at
M
Draw Step Form and Flowchart for finding sum of any two numbers.

STEP FORM

1. START
2. PRINT “Enter two numbers”
FLOWCHART
3. INPUT 𝑿𝑿 , 𝒀𝒀
4. 𝑺𝑺 ← 𝑿𝑿 + 𝒀𝒀
START
5. PRINT “Sum two numbers is” 𝑺𝑺

th
6. STOP

ep
FLOWCHART PRINT “Enter two numbers”
D
In
INPUT 𝑿𝑿 , 𝒀𝒀
hs

𝑺𝑺 ← 𝑿𝑿 + 𝒀𝒀
at
M

PRINT “Sum two numbers is” 𝑺𝑺

STOP
Draw Step Form and Flowchart for determining the remainder of a division
operation where the dividend and divisor are both integers

STEP FORM FLOWCHART

1. START
START
2. PRINT “Enter Dividend”
3. INPUT 𝑿𝑿

th
PRINT “Enter Dividend”
4. PRINT “Enter Divisor”

ep
5. INPUT 𝒀𝒀

6. 𝑸𝑸 ← (𝑿𝑿/𝒀𝒀) D INPUT 𝑿𝑿

7. 𝑹𝑹 ← 𝑿𝑿 − (𝒀𝒀 ∗ 𝑸𝑸)
PRINT “Enter Divisor”
In
8. PRINT “Remainder is” 𝑹𝑹

9. STOP
hs

INPUT 𝒀𝒀
at

𝑸𝑸 ← (𝑿𝑿/𝒀𝒀)
M

𝑹𝑹 ← 𝑿𝑿 − (𝒀𝒀 ∗ 𝑸𝑸)

PRINT “Remainder is” 𝑹𝑹

STOP
Draw Step Form and Flowchart for computing Factorial

STEPFORM
1. START
FLOWCHART
2. PRINT “Enter the value of N”

3. READ 𝑵𝑵 𝑺𝑺

𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺
4. 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ← 𝟏𝟏

th
𝑪𝑪
5. 𝐅𝐅𝐅𝐅𝐅𝐅𝐅𝐅 ← 𝟏𝟏 𝑷𝑷 𝑷𝑷 "Enter the value of 𝑵𝑵"

𝑷𝑷
𝑷𝑷𝑷𝑷
ep
6. 𝐅𝐅𝐅𝐅𝐅𝐅𝐅𝐅 ← 𝑭𝑭𝑭𝑭 ∗ 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪
𝑭𝑭𝑭𝑭
𝑪𝑪
𝑹𝑹𝑹𝑹 𝑹𝑹 𝑵𝑵

𝑹𝑹
7. IF 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ≥ 𝐍𝐍 THEN
D
𝑪𝑪
GOTO STEP 10
𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 = 𝟏𝟏
In
𝑪𝑪
8. 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ← 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 + 𝟏𝟏 𝑭𝑭𝑭𝑭 = 𝟏𝟏
𝑪𝑪
𝑪𝑪
𝑭𝑭𝑭𝑭
hs

9. GOTO STEP 6

10. PRINT “Factorial is ” 𝐅𝐅𝐅𝐅𝐅𝐅𝐅𝐅 𝑭𝑭𝑭𝑭 = 𝑭𝑭𝑭𝑭 ∗ 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪


at

𝑭𝑭𝑭𝑭
𝑭𝑭𝑭𝑭
𝑪𝑪
11. STOP
M

𝑰𝑰𝑰𝑰
𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 = 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 + 𝟏𝟏 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ≥ 𝑵𝑵
𝑪𝑪
𝑪𝑪
𝑪𝑪
No
Yes

𝑷𝑷 𝑷𝑷 "Factorial is " 𝑭𝑭𝑭𝑭


𝑷𝑷
𝑷𝑷
𝑻𝑻
𝑭𝑭𝑭𝑭
𝑺𝑺
𝑺𝑺𝑺𝑺𝑺𝑺
Draw Step form and Flowchart to find the reverse of a given number

STEPFORM
1. START

2. 𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹 𝑹𝑹 ← 𝟎𝟎
𝑹𝑹
3. PRINT “Enter positive number”

th
4. INPUT 𝑫𝑫
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
ep
5. IF 𝑫𝑫 > 𝟎𝟎 THEN GOTO STEP 6
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
Else GOTO STEP 11 D
6. 𝑸𝑸 ← 𝑫𝑫 /𝟏𝟏
𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
𝟏𝟏
In
7. 𝑹𝑹𝑹𝑹𝑹𝑹 ← 𝑫𝑫 − 𝑸𝑸 ∗ 𝟏𝟏
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸𝑸
𝟏𝟏
hs

8. 𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹 𝑹𝑹 ← 𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹 𝑹𝑹 ∗ 𝟏𝟏 + 𝑹𝑹𝑹𝑹𝑹𝑹


𝑹𝑹
𝑹𝑹
𝟏𝟏
9. 𝑫𝑫 ← 𝑫𝑫 /𝟏𝟏
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
𝟏𝟏
at

10. GOTO STEP 5


M

11. PRINT “Reverse is ” 𝐑𝐑𝐑𝐑𝐑𝐑𝐑𝐑𝐑𝐑𝐑𝐑𝐑𝐑

12. STOP
𝑺𝑺

𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺
𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹 𝑹𝑹 ← 𝟎𝟎

𝑹𝑹
𝑷𝑷𝑹𝑹 " 𝑬𝑬𝑬𝑬𝑬𝑬𝑬𝑬 𝒑𝒑𝒑𝒑𝒑𝒑𝒑𝒑 𝒑𝒑𝒑𝒑 𝑵𝑵𝑵𝑵𝑵𝑵𝑵𝑵 "
𝑰𝑰𝑰𝑰𝑰𝑰
𝑬𝑬
𝒑𝒑
𝒑𝒑
𝑵𝑵𝑵𝑵
th
𝑫𝑫
𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
ep
No
𝑰𝑰𝑰𝑰
𝑫𝑫 > 𝟎𝟎
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
D
Yes
In
𝑸𝑸 ← 𝑫𝑫 /𝟏𝟏
𝑼𝑼𝑼𝑼𝑼𝑼𝑼𝑼𝑼𝑼𝑼𝑼𝑼𝑼
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
𝟏𝟏
hs

𝑹𝑹𝑹𝑹𝑹𝑹 ← 𝑫𝑫 − 𝑸𝑸 ∗ 𝟏𝟏 𝑫𝑫 ← 𝑫𝑫 /𝟏𝟏
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
𝟏𝟏
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
𝑫𝑫𝑫𝑫
𝟏𝟏
𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹 𝑹𝑹 ← (𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹 𝑹𝑹) ∗ 𝟏𝟏 + 𝑹𝑹𝑹𝑹𝑹𝑹
at
𝑹𝑹
𝑹𝑹
𝟏𝟏
M

𝑷𝑷 𝑷𝑷 "Reverse is " 𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹 𝑹𝑹 𝑺𝑺


𝑺𝑺𝑺𝑺𝑺𝑺
𝑷𝑷
𝑷𝑷𝑷𝑷
𝑹𝑹
Draw Flowchart to find the roots of quadratic equation.

𝑺𝑺

𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺
𝒂𝒂, , 𝒄𝒄

𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰
𝒃𝒃
th
𝒅𝒅( ) = ( ∗ ) − (𝟒𝟒 ∗ 𝒂𝒂 ∗ 𝒄𝒄)
𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫𝑫
𝒃𝒃
𝒃𝒃
ep
𝒀𝒀 𝑵𝑵
𝑰𝑰𝑰𝑰
𝒀𝒀𝒀𝒀
𝐝𝐝 < 𝟎𝟎

𝑵𝑵
= �(− ) + 𝒔𝒔 (𝒅𝒅)� /𝟐𝟐 ∗ 𝒂𝒂
𝒓𝒓 ← (− )/𝟐𝟐
D 𝒓𝒓
𝟏𝟏

𝒃𝒃
𝒔𝒔
𝒔𝒔𝒔𝒔
𝒓𝒓𝒓𝒓𝒓𝒓
𝒃𝒃
𝟐𝟐
In
𝟏𝟏 = �(− ) − 𝒔𝒔 (𝒅𝒅)� /𝟐𝟐 ∗ 𝒂𝒂
img ← 𝒔𝒔 (𝒂𝒂 (𝒅𝒅))/𝟐𝟐
𝒓𝒓
𝒃𝒃
𝒔𝒔
𝒔𝒔𝒔𝒔
hs
𝒔𝒔
𝒔𝒔𝒔𝒔
𝒂𝒂𝒂𝒂
𝟐𝟐
𝒀𝒀 𝑵𝑵
𝑰𝑰𝑰𝑰
𝒀𝒀𝒀𝒀
𝑷𝑷 𝑷𝑷 "𝑹𝑹 𝒂𝒂
𝑵𝑵
𝐝𝐝 = 𝟎𝟎
at
𝑷𝑷
𝑷𝑷𝑷𝑷
𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹
𝒂𝒂𝒂𝒂
𝒊𝒊 𝒊𝒊"
𝒊𝒊𝒊𝒊𝒊𝒊
𝒊𝒊𝒊𝒊𝒊𝒊𝒊𝒊
𝑷𝑷 𝑷𝑷
M

"Roots
𝑷𝑷 𝑷𝑷
𝑷𝑷
𝑷𝑷𝑷𝑷
"Roots
are real & equal"
𝑷𝑷
𝑷𝑷𝑷𝑷
are real & different"
𝑷𝑷 𝑷𝑷 “ 𝟏𝟏 =
𝑷𝑷
𝑷𝑷𝑷𝑷
𝒓𝒓
" real" + " 𝒊𝒊
𝒊𝒊
𝒊𝒊𝒊𝒊
𝑷𝑷 𝑷𝑷 𝟏𝟏 , 𝟐𝟐
𝑷𝑷
𝑷𝑷𝑷𝑷
𝒓𝒓
𝒓𝒓
𝑷𝑷 𝑷𝑷 “ 𝟐𝟐 =
𝑷𝑷
𝑷𝑷𝑷𝑷
𝒓𝒓
" real" − " 𝒊𝒊 𝑺𝑺
𝑺𝑺𝑺𝑺𝑺𝑺
𝒊𝒊
𝒊𝒊𝒊𝒊
Draw Step Form and Flowchart to swap two numbers using third variable

FLOWCHART
STEPFORM
START
1. START
2. PRINT “Enter two Numbers”
PRINT “Enter two Numbers”
3. INPUT 𝑿𝑿, 𝒀𝒀
4. PRINT “Before

th
Swapping 𝑿𝑿 =” 𝑿𝑿 , "Y=" 𝒀𝒀
INPUT 𝑿𝑿, 𝒀𝒀
5. ← 𝑿𝑿

ep
𝑻𝑻𝑻𝑻𝑻𝑻𝑻𝑻
6. 𝑿𝑿 ← 𝒀𝒀
PRINT “Before Swapping 𝑿𝑿 =” 𝑿𝑿 , "Y=" 𝒀𝒀
7. 𝒀𝒀 ←
D
𝑻𝑻𝑻𝑻𝑻𝑻𝑻𝑻
8. PRINT “After
Swapping “𝑿𝑿 =” 𝑿𝑿 , "Y=" 𝒀𝒀
In
𝑻𝑻𝑻𝑻𝑻𝑻𝑻𝑻
← 𝑿𝑿
10. STOP
𝑿𝑿 ← 𝒀𝒀
hs

𝒀𝒀 ← 𝑻𝑻𝑻𝑻𝑻𝑻𝑻𝑻
at

PRINT “After Swapping “𝑿𝑿 =” 𝑿𝑿 , "Y=" 𝒀𝒀


M

STOP
Draw Step Form and Flowchart to swap two numbers without using third
variable

STEP FORM FLOWCHART

1. START START
2. PRINT “Enter
Two Numbers” PRINT “Enter two Numbers”

th
3. INPUT 𝑿𝑿, 𝒀𝒀
4. PRINT “Before

ep
INPUT 𝑿𝑿, 𝒀𝒀
Swapping 𝑿𝑿 =” 𝑿𝑿 , "Y=" 𝒀𝒀
5. 𝑿𝑿 ← 𝑿𝑿 + 𝒀𝒀 D
6. 𝒀𝒀 ← 𝑿𝑿 − 𝒀𝒀 PRINT “Before Swapping 𝑿𝑿 =” 𝑿𝑿 , "Y=" 𝒀𝒀

7. X ← 𝑿𝑿 − 𝒀𝒀
In
8. PRINT “After
X ←X+Y
hs

Swapping “𝑿𝑿 =” 𝑿𝑿 , "Y=" 𝒀𝒀


Y ← 𝑿𝑿 − 𝒀𝒀
10. STOP
𝑿𝑿 ← 𝑿𝑿 − 𝒀𝒀
at
M

PRINT “After Swapping “𝑿𝑿 =” 𝑿𝑿 , "Y=" 𝒀𝒀

STOP
Draw Flowchart to find Sum and Average of N natural numbers.

𝑺𝑺

𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺
𝑷𝑷 𝑷𝑷 "Enter the value of 𝑵𝑵"
𝑷𝑷
𝑷𝑷𝑷𝑷
𝑵𝑵

th
𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰
ep
𝑺𝑺 = 𝟎𝟎
𝑺𝑺𝑺𝑺
𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 = 𝟎𝟎
𝑪𝑪
D
In
𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 = 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 + 𝟏𝟏
𝑪𝑪
𝑪𝑪
hs

𝑺𝑺 = 𝑺𝑺 + 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪
𝑺𝑺𝑺𝑺
𝑺𝑺𝑺𝑺
𝑪𝑪
at
M

No
𝑰𝑰𝑰𝑰
𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 = 𝑵𝑵 ?
𝑪𝑪
Yes

𝑷𝑷 𝑷𝑷 𝑺𝑺
𝑷𝑷
𝑷𝑷𝑷𝑷
𝑺𝑺𝑺𝑺
= 𝑺𝑺 /𝑵𝑵 𝑷𝑷 𝑷𝑷 "Average is"
𝑨𝑨𝑨𝑨𝑨𝑨
𝑺𝑺𝑺𝑺
𝑷𝑷
𝑷𝑷𝑷𝑷
𝑨𝑨𝑨𝑨𝑨𝑨
𝑺𝑺
𝑺𝑺𝑺𝑺𝑺𝑺
Draw Step Form and Flowchart to check whether a number is odd or even.

STEP FORM

1. START

2. PRINT “Enter a Number”


START
3. INPUT 𝑿𝑿

th
4. 𝑸𝑸 ← (𝑿𝑿/𝟐𝟐) PRINT “Enter a Number”

ep
5. 𝑹𝑹 ← 𝐗𝐗 − (𝟐𝟐 ∗ 𝑸𝑸)
INPUT 𝑿𝑿
6. IF (𝑹𝑹 = 𝟎𝟎) THEN PRINT 𝑿𝑿 “is Even”
D
ELSE PRINT 𝑿𝑿 “is Odd” 𝑸𝑸 ← (𝑿𝑿/𝟐𝟐)
In
7. STOP 𝑹𝑹 ← 𝐗𝐗 − (𝟐𝟐 ∗ 𝑸𝑸)
hs
at

IF (𝑹𝑹 = 𝟎𝟎)

No
M

Yes

PRINT 𝑿𝑿 “is Even” PRINT 𝑿𝑿 “is Odd”

STOP
Draw Step Form and Flowchart to find Maximum among 2 natural number.

STEP FORM
1. START
2. PRINT “Enter two Numbers”
3. INPUT 𝑿𝑿, 𝒀𝒀
FLOWCHART
4. IF (𝑿𝑿 > 𝒀𝒀) THEN PRINT 𝑿𝑿 “is Maximum”

th
START
ELSE IF (𝑿𝑿 = 𝒀𝒀) PRINT “Both

ep
numbers are Equal”
ELSE PRINT 𝒀𝒀 “is Maximum” D PRINT “Enter two Numbers”

5. STOP
INPUT 𝑿𝑿, 𝒀𝒀
In
hs

No Yes
IF (𝑿𝑿 > 𝒀𝒀)
at
M

Yes No
PRINT 𝑿𝑿 “is Maximum”
IF (𝑿𝑿 = 𝒀𝒀)

PRINT “Both nos are Equal” PRINT 𝒀𝒀 “is Maximum”

STOP
Draw Step Form and Flowchart to find the largest of Three numbers.

STEP FORM

1. START

2. PRINT “Enter three Numbers”

th
3. INPUT 𝑿𝑿, 𝒀𝒀, 𝒁𝒁

ep
4. IF �𝑿𝑿 > 𝒀𝒀 𝑿𝑿 > 𝒁𝒁� THEN PRINT 𝑿𝑿 “is Maximum”
𝑨𝑨𝑨𝑨𝑨𝑨
ELSE
D
IF (𝑿𝑿 = 𝒀𝒀 = 𝒁𝒁) THEN PRINT “All 3 nos are equal”
In
ELSE
IF (𝒀𝒀 > 𝒁𝒁) THEN PRINT 𝒀𝒀 “is Max”
hs

ELSE PRINT 𝒁𝒁 “is Max”

5. STOP
at
M
START

PRINT “Enter three Numbers”

INPUT 𝑿𝑿, 𝒀𝒀, 𝒁𝒁

𝑿𝑿 > 𝒀𝒀 No
IF � �

𝑨𝑨𝑨𝑨𝑨𝑨
𝑿𝑿 > 𝒁𝒁

th
Yes

IF (𝑿𝑿 = 𝒀𝒀 = 𝒁𝒁)
Yes
PRINT 𝑿𝑿 “is Maximum”

ep
No

PRINT “All 3 nos are equal”


D IF (𝒀𝒀 > 𝒁𝒁)
Yes
In
PRINT 𝒀𝒀 “is Max” No
hs

PRINT 𝒁𝒁 “is Max”


at

STOP
M
Draw Flowchart to find the largest of N numbers.

STEP FORM

1. START

th
2. PRINT “Enter the count of numbers”
3. INPUT 𝑵𝑵

ep
4. 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ← 𝟎𝟎
𝑪𝑪
5. PRINT “Enter the First Number”
D
6. INPUT
In
𝑨𝑨
7. 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ← 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 + 𝟏𝟏
𝑪𝑪
𝑪𝑪
hs

8. 𝐌𝐌 ←
𝐌𝐌𝐌𝐌
𝑨𝑨
9. PRINT “Enter Next Number”
at

10. INPUT 𝑩𝑩
11. 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ← 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 + 𝟏𝟏
M
𝑪𝑪
𝑪𝑪
12. IF 𝑩𝑩 > 𝐌𝐌 THEN
𝐌𝐌𝐌𝐌
𝐌𝐌 ← 𝑩𝑩
𝐌𝐌𝐌𝐌
13. IF 𝑪𝑪 < = 𝑵𝑵 THEN GOTO STEP 9
14. PRINT “Maximum is ” 𝐌𝐌
𝐌𝐌𝐌𝐌
15. STOP
𝑺𝑺

𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺
𝑷𝑷 𝑷𝑷 "Enter the count of Numbers”
𝑷𝑷
𝑷𝑷𝑷𝑷
th
𝑵𝑵

ep
𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰
𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ← 𝟎𝟎
D
𝑪𝑪
In
𝑷𝑷 𝑷𝑷 "Enter the first Number”
𝑷𝑷
𝑷𝑷𝑷𝑷
hs 𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰
𝑨𝑨
at

𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ← 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 + 𝟏𝟏
M
𝑪𝑪
𝑪𝑪

𝑴𝑴𝑴𝑴𝑴𝑴
𝑨𝑨
A-35
A-34

𝑷𝑷 𝑷𝑷 "Enter Next Number”

𝑷𝑷
𝑷𝑷𝑷𝑷
𝑩𝑩

𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰
th
𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ← 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 + 𝟏𝟏
𝑪𝑪
𝑪𝑪
ep
Yes
𝑰𝑰𝑰𝑰
𝑩𝑩 >
D
𝑴𝑴𝑴𝑴𝑴𝑴
In
← 𝑩𝑩 No
hs
𝑴𝑴𝑴𝑴𝑴𝑴
at

Yes
𝑰𝑰𝑰𝑰
𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 ≤ 𝑵𝑵
M
𝑪𝑪
No

𝑷𝑷 𝑷𝑷 “Maximum is ” MAX
𝑷𝑷
𝑷𝑷𝑷𝑷
𝑺𝑺
𝑺𝑺𝑺𝑺𝑺𝑺
Draw Step Form to find whether the given number is prime or not.

STEP FORM

1. START
2. PRINT “ENTER THE NUMBER”

th
3. INPUT 𝑵𝑵
4. IF 𝑵𝑵 = 𝟐𝟐 THEN

ep
PRINT “PRIME” GOTO STEP 12
5. ← 𝟐𝟐
𝑫𝑫
6. 𝐐𝐐 ← (𝑵𝑵/ )
D
𝑫𝑫
7. 𝑹𝑹 ← 𝑵𝑵 − (𝑸𝑸 ∗ )
In
𝑫𝑫
8. IF 𝑹𝑹 = 𝟎𝟎 THEN GOTO STEP 11
hs

9. ← + 𝟏𝟏
𝑫𝑫
𝑫𝑫
at

10. IF <= 𝑵𝑵/𝟐𝟐


𝑫𝑫
THEN GOTO STEP 6
M

ELSE PRINT “PRIME “

11. PRINT “NOT PRIME “

12. STOP
Draw Step Form to write an algorithm to check whether given number is an
Armstrong Number or not.

STEP FORM

1. START
2. PRINT “ENTER THE NUMBER”
3. INPUT 𝑵𝑵

th
4. ← 𝑵𝑵
𝑴𝑴
ep
5. 𝑺𝑺 ← 𝟎𝟎
6. 𝑸𝑸 ← 𝑵𝑵/𝟏𝟏
𝟏𝟏
D
7. 𝑹𝑹 ← 𝑵𝑵 − 𝑸𝑸 ∗ 𝟏𝟏
𝟏𝟏
In
8. 𝑺𝑺 ← 𝑺𝑺 + 𝑹𝑹 ∗ 𝑹𝑹 ∗ 𝑹𝑹
9. 𝑵𝑵 ← 𝑸𝑸
hs

10. IF 𝑵𝑵 > 𝟎𝟎 THEN GOTO STEP 𝟔𝟔


11. IF 𝑺𝑺 =
at

THEN
𝑴𝑴
PRINT “THE NUMBER IS ARMSTRONG “
M

ELSE
PRINT “THE NUMBER IS NOT ARMSTRONG “
12. STOP
Draw Flowchart to calculate Simple Interest.

𝑺𝑺

𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺
th
𝑷𝑷 𝑷𝑷 "Enter the value of Principal Amount,
𝑷𝑷
𝑷𝑷𝑷𝑷
ep
Time & Rate of Interest"
D
𝑷𝑷, , 𝑹𝑹
𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰
𝑻𝑻
In
hs

𝑷𝑷 ∗ ∗ 𝑹𝑹
=
𝑻𝑻
𝟏𝟏
𝑰𝑰
𝟏𝟏𝟏𝟏
at
M

𝑷𝑷 𝑷𝑷 “Simple Interest is”


𝑷𝑷
𝑷𝑷𝑷𝑷
𝑰𝑰
𝑺𝑺
𝑺𝑺𝑺𝑺𝑺𝑺
Draw Step Form and Flowchart Student Grading System.

STEP FORM

1. START

2. PRINT “Enter the marks”

th
3. READ 𝑴𝑴
𝑴𝑴𝑴𝑴𝑴𝑴
𝑴𝑴
ep
4. 𝑴𝑴 ≥ 𝟗𝟗 𝑻𝑻 =
𝑰𝑰𝑰𝑰
𝑴𝑴𝑴𝑴𝑴𝑴
𝑴𝑴
𝟗𝟗
𝑻𝑻
𝑻𝑻𝑻𝑻
𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮
𝑨𝑨
𝑬𝑬 𝑴𝑴 ≥ 𝟖𝟖 𝑻𝑻 = 𝑩𝑩
𝑬𝑬
𝑬𝑬𝑬𝑬
𝑰𝑰𝑰𝑰
𝑴𝑴𝑴𝑴𝑴𝑴
𝑴𝑴
𝟖𝟖
𝑻𝑻
𝑻𝑻𝑻𝑻
𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮
𝑬𝑬
D 𝑴𝑴 ≥ 𝟔𝟔𝟔𝟔 𝑻𝑻 = 𝑪𝑪
𝑬𝑬
𝑬𝑬𝑬𝑬
𝑰𝑰𝑰𝑰
𝑴𝑴𝑴𝑴𝑴𝑴
𝑴𝑴
𝑻𝑻
𝑻𝑻𝑻𝑻
𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮
𝑬𝑬 =
In
𝑬𝑬
𝑬𝑬𝑬𝑬
𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮
𝑫𝑫
5. PRINT “Grade is ” 𝐆𝐆 𝐆𝐆
𝐆𝐆𝐆𝐆
𝐆𝐆
hs

6. STOP
at
M
𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮
Yes

=
𝑨𝑨
𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰
𝑷𝑷
𝑷𝑷 𝑷𝑷
𝑷𝑷𝑷𝑷
𝑺𝑺
𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺
𝑺𝑺
𝑺𝑺𝑺𝑺𝑺𝑺
𝑰𝑰𝑰𝑰
𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮
𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮
𝑴𝑴𝑴𝑴𝑴𝑴
M
𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀 ≥ 90
𝑴𝑴

𝑴𝑴
Yes
at

= 𝑩𝑩
𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮
hs No

𝑰𝑰𝑰𝑰
In 𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀 ≥ 80
D
Yes

= 𝑪𝑪
No

ep
𝑰𝑰𝑰𝑰
th
𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮𝑮
𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀 ≥ 65
No

𝑫𝑫
Draw Flowchart to Sum of First N numbers.

𝑺𝑺
𝑺𝑺𝑺𝑺𝑺𝑺𝑺𝑺
𝑷𝑷 𝑷𝑷 "Enter the value of 𝑵𝑵"
𝑷𝑷
𝑷𝑷𝑷𝑷
th
𝑵𝑵

ep
𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰
𝑺𝑺 = 𝟎𝟎
D
𝑺𝑺𝑺𝑺
𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 = 𝟎𝟎
In
𝑪𝑪
hs

𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 = 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 + 𝟏𝟏
𝑪𝑪
𝑪𝑪
at

𝑺𝑺 = 𝑺𝑺 + 𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪
𝑺𝑺𝑺𝑺
𝑺𝑺𝑺𝑺
𝑪𝑪
M 𝑰𝑰𝑰𝑰
𝑪𝑪𝑪𝑪𝑪𝑪 𝑪𝑪 = 𝑵𝑵 ? 𝑷𝑷 𝑷𝑷 𝑺𝑺 𝑺𝑺
𝑺𝑺𝑺𝑺𝑺𝑺
No Yes
𝑪𝑪
𝑷𝑷
𝑷𝑷𝑷𝑷
𝑺𝑺𝑺𝑺
Draw Step Form to print Fibonacci series upto N terms.

STEP FORM

1. START
2. PRINT “ENTER THE NUMBER OF TERMS”

th
3. INPUT 𝑵𝑵

ep
4. C ←1
5. T1 ← 0 D
6. T2 ← 1
7. NEXT ← 1
In
8. PRINT NEXT
hs

9. NEXT ← T1 +T2
10. C ← C+1
at

11. T1 ← T2
12. T2 ← NEXT
M

13. IF C<= N THEN GOTO 8


14. STOP
Draw Step Form to find sum of series 𝟏𝟏 + 𝒙𝒙 + 𝒙𝒙𝟐𝟐 + 𝒙𝒙𝟑𝟑 + 𝒙𝒙𝟒𝟒 +. . . . . . . . up to N terms

STEP FORM

1. START
2. PRINT “ENTER THE NUMBER OF TERMS”

th
3. INPUT 𝑵𝑵
4. PRINT “ENTER VALUE OF X ”

ep
5. INPUT 𝑿𝑿
6. T ←1
D
7. C←1
In
8. S←0
9. S ← S+T
hs

10. C ← C+1
11. T ← T*X
at

12. IF C<= N THEN GOTO 9


13. PRINT S
M

14. STOP
𝒙𝒙𝟐𝟐 𝒙𝒙𝟑𝟑 𝒙𝒙𝟒𝟒
Draw Step Form to find sum of series 𝟏𝟏 + 𝒙𝒙 + + + + … up to N terms.
𝟐𝟐! 𝟑𝟑! 𝟒𝟒!

STEP FORM

1. START
2. PRINT “ENTER THE NUMBER OF TERMS”
3. INPUT 𝑵𝑵

th
4. PRINT “ENTER A NUMBER”
5. INPUT 𝑿𝑿

ep
6. ←1
𝑻𝑻
7. 𝑪𝑪 ← 1
D
8. 𝑺𝑺 ← 0
In
9. 𝑺𝑺 ← 𝑺𝑺 +
𝑻𝑻
10. ← ∗ 𝑿𝑿/𝑪𝑪
hs
𝑻𝑻
𝑻𝑻
11. 𝑪𝑪 ← 𝑪𝑪 + 𝟏𝟏
12. IF 𝑪𝑪 <= 𝑵𝑵 THEN GOTO 𝟗𝟗
at

13. PRINT 𝑺𝑺
M

14. STOP
Draw Step Form and Flowchart to identify Type of triangle, it’s Area and
Perimeter.

STEP FORM
1. START

2. PRINT “Enter Sides”

3. INPUT 𝒂𝒂, , 𝒄𝒄

th
𝒃𝒃
4. IF �𝒂𝒂 ≤ 𝟎𝟎 ≤ 𝟎𝟎 𝒄𝒄 ≤ 𝟎𝟎� THEN PRINT “Invalid

ep
𝑶𝑶𝑶𝑶
𝒃𝒃
𝑶𝑶𝑶𝑶
Data”
GOTO STEP 11 D
5. IF �𝒂𝒂 + > 𝒄𝒄 + 𝒄𝒄 > 𝒂𝒂 𝒄𝒄 + 𝒂𝒂 > �
𝒃𝒃
𝑨𝑨𝑨𝑨𝑨𝑨
𝒃𝒃
𝑨𝑨𝑨𝑨𝑨𝑨
𝒃𝒃
THEN GOTO STEP 6
In
ELSE PRINT “Invalid Triangle” GOTO STEP 11
hs

6. IF �𝒂𝒂 = = 𝒄𝒄 � THEN PRINT “Equilateral Triangle”


𝒃𝒃
𝑨𝑨𝑨𝑨𝑨𝑨
𝒃𝒃
ELSE IF �𝒂𝒂 = = 𝒄𝒄 𝒄𝒄 = 𝒅𝒅 � PRINT “Isosceles
at
𝒃𝒃
𝑶𝑶𝑶𝑶
𝒃𝒃
𝑶𝑶𝑶𝑶
Triangle”
ELSE PRINT “Scalene Triangle”
M

7. 𝑷𝑷 ← 𝒂𝒂 + + 𝒄𝒄
𝒃𝒃
8. ← 𝑷𝑷/𝟐𝟐
𝒔𝒔
9. ← 𝑺𝑺 � ∗ ( − 𝒂𝒂)( − )( − 𝒄𝒄)�
𝑨𝑨
𝑺𝑺𝑺𝑺𝑺𝑺
𝒔𝒔
𝒔𝒔
𝒔𝒔
𝒃𝒃
𝒔𝒔
10. PRINT “Area = ” and “Perimeter = ” 𝑷𝑷
𝑨𝑨
11. STOP
M
at
hs
In
D
ep
th

You might also like