A procedure definition describes what the procedure will do. As an example in question 3, lines 1-3 are part of the definition of the procedure chorus. But no code gets executed
until you call the procedure. A procedure call is when you use the name of the procedure
to cause the code in the definition to be executed.
You call a procedure by using its name (as an example in question 3 lines 5 and 7 are procedure calls)
4 5 1 2 3 6 7 1 2 3
procedure printTable
const LARGEST := 10
for i : 1 .. LARGEST
put i, " ", i*i
endforend printTable
Prints a table of the squares of the numbers from 1 to 10.
% part a
procedure printRectangle
const SYMBOL := '*'
const HEIGHT := 3
const WIDTH := 8
for row : 1 .. HEIGHT
for col : 1 .. WIDTH
put SYMBOL ..
endforput ""
endforend printRectangle
% part b
printRectangle
put "Now a second call"
printRectangle
put "One last time"
printRectangle
% include the procedure definitions from the question
solid
solid
% include the procedure definitions from the question
solid
for i : 1 .. 6
hollow
endfor
solid
var howMany : intprocedure solid
for i : 1 .. 20
put "*" ..
endforput ""
end solid
procedure hollow
for i : 1 .. 20
if i = 1 or i = 20 thenput "*" ..
elseput " " ..
endifendforput ""
end hollow
put "How many rows do you want?"
get howMany
if howMany < 2 thenput "Sorry that number is too small"
else
solid
for i : 1 .. howMany - 2
hollow
endfor
solid
endif