Introductory Examples of Flowcharts and Pseudocode
[Pages:4]Introductory Examples of Flowcharts and Pseudocode
Chapter 3
Calculate Pay - sequence
Start input hours input rate
Begin input hours input rate pay = hours * rate print pay
End
pay = hours * rate
print pay End
Sum of 2 Numbers - sequence
Start
input x input y
Begin input x, y sum = x + y print sum
End
sum = x + y output sum
End
1
2
Average of 3 Numbers - sequence
Start
input x input y input z
sum = x + y + z avg = sum / 3.0
Begin input x input y input z sum = x + y + z avg = sum / 3.0 print avg
End
print avg End
3
Calculate Pay with Overtime - selection
input hours, rate
F hours 40
T pay = hours * rate
pay = 40 * rate + (hours - 40) * 1.5 * rate
print pay
Begin input hours, rate if hours 40 then pay = hours * rate else pay = 40 * rate + (hours ? 40) * rate * 1.5 print pay
End
4
Average of 10 Numbers ? iteration with a while loop
i = 0 sum = 0
while i < 10 T
input x
F avg = sum / 10.0
sum = x + sum increment i
print avg
Begin i = 0 sum = 0 while i < 10 input x sum = sum + x ++i avg = sum / 10.0 print avg
End
Begin i = 0 sum = 0
a: if i 10 goto b input x sum = sum + x ++i goto a
b: avg = sum / 10.0 print avg
End
Comment Strictly speaking, the above flowchart corresponds more to the pseudocode on the right hand side. However, as you can see, `gotos' make code less modular and more unreadable.
5
Average of 10 Numbers ? iteration with a for loop
sum = 0
i
1
1 10
1
Begin sum = 0 for i = 1 to 10 input x sum = sum + x avg = sum / 10.0 print avg
End
input x sum = x + sum
i avg = sum / 10.0
print avg
6
Flowchart for Function or Subroutine Module
Begin
print "input 3 numbers" input a, b, c
Begin print "Input 3 numbers: " input a, b, c avg = average(a, b, c) print "Average is ", avg
End
Average
print "average is", avg input a, b, c
End
Average
sum = a + b + c avg = sum / 3
Exit
Begin Average(a, b, c) sum = a + b + c avg = sum / 3.0 return avg
End
7
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- es117 lecture 3 marmara
- lab 2 designing pseudocode and flowchart using
- algorithm and flow chart 1 1 introduction
- introductory examples of flowcharts and pseudocode
- pseudocode flowchart examples
- scheme syllabus mca se
- edexcel gcse in computer science scheme of work for year
- 2005 2006 2005 2006
- aplicaȚia nr
- pure aloha com
Related searches
- examples of values and beliefs
- examples of ideals and values
- examples of antonyms and synonyms
- examples of signs and symptoms
- examples of advantages and disadvantages
- examples of products and services
- examples of beliefs and ideals
- examples of facts and opinions
- examples of positive and normative analysis
- examples of words and opposite
- examples of wholesalers and retailers
- examples of strengths and weakness