Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
COMPUTER PROGRAMMING
INTRODUCTION TO ALGORITHMS AND
FLOWCHARTS (CONTINUED)
EXPRESSING ALGORITHMS
• Natural Languages
• Pseudocode
• Flowcharts
• Programming Languages
NATURAL LANGUAGE ALGORITHM
Cilbir
• 6 eggs
• ½ kg yogurt
• 3 large garlic cloves
• 4 Tbs fresh butter
• 1 tsp red pepper, coarsely ground
• 2 middle-sized onions cut horizontally
• plenty water
• Boil water in a fairly big pot. Break one by one the eggs and pour them in a plate, being
careful not to break the yolk. To ensure a homogenous cooking, let them “glide” from
the plate into the boiling water. Within three minutes the eggs are ready but if you
prefer hard-boiled, allow them to cook for another minute or so.
• Meanwhile brown the butter in a skillet and add the garlic and onion. In the last possible
moment add the coarsely ground red pepper and turn off the fire. Remove the eggs
from the pot using a skimmer and place them in a deep plate.
• Cover the eggs with plenty of yogurt and pour the hot butter over them. Serve
immediately.
From www.gourmet.gr
PSEUDOCODE ALGORITHM EXAMPLE
Set moveCount to 1
FOR each row on the board
FOR each column on the board
IF gameBoard position (row, column) is occupied THEN
CALL findAdjacentTiles with row, column
INCREMENT moveCount
END IF
END FOR
END FOR
ALGORITHM EXAMPLE
Input radius
Set pi = 3.14
Calculate area = pi * radius * radius
LABWORK 2
• Arrows
• Processing steps
• Input/Output
• Conditional (Decision)
FLOWCHART SYMBOLS (OTHERS)
• Document
• Magnetic Tape
• Display
• Manual Input
FLOWCHART EXAMPLE
From wikipedia.org
FLOWCHART EXAMPLE
From smartdraw.com
FLOWCHART EXAMPLE
From wikipedia.org
FLOWCHART EXAMPLE
START
Input N
Sum =0
C=0
Input number
Sum = Sum + number
C=C+1
No C = N?
Yes
A = Sum / N
Print A
END
LABWORK 3
• Draw a flowchart to find the product of two numbers using only addition
operation
LABWORK 5
LABWORK 6
• Draw a flowchart to find the division of two integer numbers using only
subtraction operation. Find the division and remainder.
LABWORK 6
SUMMARY