0% found this document useful (0 votes)
42 views13 pages

Lesson 1,2 Pseudocodeflowchartexamples-180402195549

The document provides examples of pseudocode and flowcharts for common programming problems. It explains the basic syntax and constructs used in pseudocode like inputs, outputs, loops, conditions. It then gives 9 examples of pseudocode and flowcharts for problems like adding numbers, calculating area and perimeter, checking positive/negative numbers, finding sum of even numbers from 1-100.

Uploaded by

Abdullah Shahzad
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)
42 views13 pages

Lesson 1,2 Pseudocodeflowchartexamples-180402195549

The document provides examples of pseudocode and flowcharts for common programming problems. It explains the basic syntax and constructs used in pseudocode like inputs, outputs, loops, conditions. It then gives 9 examples of pseudocode and flowcharts for problems like adding numbers, calculating area and perimeter, checking positive/negative numbers, finding sum of even numbers from 1-100.

Uploaded by

Abdullah Shahzad
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/ 13

PSEUDOCODE &

FLOWCHART
EXAM PLES C

By: Humaira Ikhlaq


Pseudocode
• Pseudocode is a compact and informal high-level
description of a program using the conventions of a
programming language, but intended more for
humans.
• There is no pseudocode standard syntax and so at
times it becomes slightly confusing when writing
Pseudocode and so let us understand pseudo code
with an example.
Pseudecode Syntax
• FOR THOSE TUTORIALS I'LL USE THAT SYNTAX
• INPUT – indicates a user will be inputting something
• OUTPUT – indicates that an output will appear on the screen
• WHILE – a loop (iteration that has a condition at the beginning)
• FOR – a counting loop (iteration)
• REPEAT – UNTIL – a loop (iteration) that has a condition at the end
• IF – THEN – ELSE – a decision (selection) in which a choice is made
• any instructions that occur inside a selection or iteration are usually indented
Operator Used
Relational Operators
Pseudocode & Flowchart Example 1
Add Two Numbers
1 BEGIN / START
2 NUMBER s1, s2, sum
3 OUTPUT("Input number1:")
4 INPUT s1
5 OUTPUT("Input number2:")
6 INPUT s2
7 sum=s1+s2
8 OUTPUT sum
9 END

sum
Pseudocode & Flowchart Example 2
Calculate Perimeter of Rectangle

1 BEGIN
2 NUMBER b1,b2,area,perimeter
3 INPUT b1
4 INPUT b2
5 area=b1*b2
6 perimeter=2*(b1+b2)
7 OUTPUT area
8 OUTPUT perimeter area
9 END

perimeter
Pseudocode & Flowchart Example 3
Find Perimeter Of Circle using Radius

BEGIN
2 NUMBER r, perimeter
3 INPUT r
4 area=3.14*2*r
5 OUTPUT perimeter
6 END

perimeter
Pseudocode & Flowchart Example 4
Calculate sales taxes

BEGIN
3 NUMBER price, tax, taxRate, total
4
5 OUTPUT "Enter Product Price"
6 INPUT price
7 OUTPUT "Enter tax rate
8 amoung 1 and 100"
9 OKU taxRate
10
11 tax= price* taxRate/100
12 total= price + tax
13
14 OUTPUT "Product tax="+tax
15 OUTPUT "Product total price ="+total

END
Pseudocode & Flowchart Example 5
Check a Number is Positive or Negative

BEGIN
5
6
7 NUMBER num
8
9 OUTPUT "Enter a Number"
10 INPUT num
11
12
IF num>0 THEN
13 OUTPUT "Entered number is
14 positive" ELSE IF num <0 THEN
15 OUTPUT "Entered number is
16 negative" ELSE
OUTPUT "Entered number is
zero"
ENDIF

END
Pseudocode & Flowchart Example 7
Print Numbers from 1 to 100

BEGIN
2 NUMBER counter
3
4 FOR counter = 1 TO 100 STEP 1
5 OUTPUT counter
6 ENDFOR
7
8 END
Pseudocode & Flowchart Example 9
Read 10 numbers and find sum of even numbers

1
2
BEGIN
3 NUMBER counter, sum=0, num
4
5
FOR counter=1 TO 10 STEP
6 1 DO OUTPUT "Enter a
7
8
Number" INPUT num
9 IF num % 2 == 0 THEN
10
11
sum=sum+num
12 ENDIF
13
14
ENDFOR
15 OUTPUT sum
Introduction to Creating
Flowcharts
https://
www.youtube.com/watch?v=S
WRDqTx8d4k

You might also like