0% found this document useful (0 votes)
33 views

Introduction to Flowchart and Pseudocode

Uploaded by

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

Introduction to Flowchart and Pseudocode

Uploaded by

ashimakhosla11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Lesson 1- Introduction To

Flowchart and Pseudocode


Definition of Flow Chart:-
Flowcharts are a graphical way of representing an algorithm design.

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

Start / Finish Used to indicate the


start and finish of the
algorithm.
Process A process / action to
be performed, e.g. a
calculation or
the assignment of a
value.
Input / Output Used to show data
being inputted into the
system (e.g. by a
user), or data being
outputted (e.g. a
message or the value
from a variable).
Decision A question / test of a
condition that allows
the flowchart to
branch into one of two
Flowchart Example
PSEUDOCODE
Rules for writing pseudocode:
• Variables
Variables are assigned using the = operator.
X 3
Name ”Bob”
A variable is declared the first time a value is assigned. It
assumes the data type of the value it is given. Variables
declared inside a function or procedure are local to that
subroutine. Variables in the main program can be made
global with the keyword global.
• Outputting to Screen
Output (“hello”)
Taking Input from User
variable input(prompt to user)
Example:
Name input(“Please enter your name”)
• Iteration/loop - Count Controlled
for i=0 to 7
print(“Hello”)
next i
Will print hello 8 times (0-7 inclusive).
• Iteration/ loop- Condition Controlled
while answer != ”computer”
answer=input(“What is the password?”)
EndWhile

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

>= Greater than


equals to
• Logical Operators
 Arithmetic Operators
+ Addition
- Subtraction
* Multiplication
/ Division

MOD modulus
^ Exponentiatio
n
• Selection

Selection will be carried out with if/else and switch/case:

 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

Arrays will be 0 based and declared with the keyword


array.
array names[5] =(“Ahmad”,”ben”,”Catherine”,
“Dana”, “Elijah”)
names[0]=”Ahmad”
names[1]=”Ben”
names[2]=”Catherine”
names[3]=”Dana”
names[4]=”Elijah”
print(names[3])
Pseudocode to find the greater number
N1 Input(“enter the first number “)

N2 Input(“enter the second number”)

If (n1>n2)

Then

output (N1 “is greater number” )

Elseif (n2>n1)

then

Output (n2 “is greater number”)

Else
Output (“both numbers are equal”)

End if
Lets take another example

• Calculate the average of three 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: take the third number from the user as num3
Step 4: Add the three numbers and divide by 3
Step 5: Print the result
Flow chart
Pseudocode to find average
Begin

a= Input(“ enter the first number”)

b= Input(“ enter the second number”)

c= Input(“ enter the third number”)

Avg=0

Avg= (a+b+c)/3

Print (“the average of the three numbers are:” Avg)

end
Lets take one more example

• Lets find out the given number is even number or odd


number
Algorithm
Step 1: take a number from the user as num1
Step 2: divide the num1 with 2.
Step 3: If the remainder is 0 then print num1 is an even
number
Step4: if the reminder is 1 then print num1 is an odd
number
Flow chart
Pseudocode

n1= Input(“please give the number”)

Switch

Case (n1%2 == 0)

Print (n1 “is even number”)

Case(n1%2 != 0)

Print (n1 “is odd number”)

End switch
Pseudocode
Begin

n1= Input(“please give the number”)

If (n1 %2 == 0)
Then
Output(n1 “ is an even number”)
Else
Output(n1 “ is an odd number”)

endif
Thank You

You might also like