Introduction to Flowchart and Pseudocode
Introduction to Flowchart and Pseudocode
Definition of Pseudocode:-
You can write algorithms in plain English before you decide which programming
language you want to use. Writing algorithms this way is called pseudocode.
Definition of Algorithms:-
An algorithm is a set of instructions that describes how to solve a problem.
Algorithms can be designed using pseudo-code and/or flowcharts. They are
written using statements and expressions.
Let’s take an example
Write algorithm ,flowchart and pseudocode to find the
larger number between two numbers .
Algorithm
Step 1: take a number from the user as num1
Step 2: take the second number from the user as num2
Step 3: compare the two numbers
Step 4: if num 1 is greater ,print num 1 is the greater
number
Step 5: if num2 is greater , print num 2 is the greater
number
Step 6: if both numbers are equal , print both the
numbers are equal
FLOW CHART SYMBOLS
NAME SYMBOL EXPLAINTION
Do
answer=input(“What is the password?”)
until
Answer == ”computer”
• Logical Operators
AND and OR
Comparison Operators
== Equals to
!= Not Equals to
< Less than
<= Less than
equals to
> Greater than
= Assignment
MOD modulus
^ Exponentiatio
n
• Selection
if/else
if
entry==”a”
then
print(“You selected A”)
Elseif
entry==”b”
then
print(“You selected B”)
else
print(“Unrecognized selection”)
endif
Switch /case
switch entry:
case “A”:
print(“You selected A”)
case “B”:
print(“You selected B”)
default:
print(“Unrecognized selection”)
End switch
• Array
If (n1>n2)
Then
Elseif (n2>n1)
then
Else
Output (“both numbers are equal”)
End if
Lets take another example
Avg=0
Avg= (a+b+c)/3
end
Lets take one more example
Switch
Case (n1%2 == 0)
Case(n1%2 != 0)
End switch
Pseudocode
Begin
If (n1 %2 == 0)
Then
Output(n1 “ is an even number”)
Else
Output(n1 “ is an odd number”)
endif
Thank You