This is a turing
program that uses
loops to display a
triangle of stars:
var numRows : int := (10) * 2 %
variables are declared here
var intCount : int := 10
get numRows
numRows := numRows * 2
intCount := numRows
if numRows > 0 then
for row : 1 .. numRows by 2
for x : 1 .. (intCount)
put " " ..
end for
for column : 1 .. row
put "*" ..
end for
put ""
intCount := intCount - 1
end for
else
numRows := numRows + 2
intCount := intCount + 1
for row : numRows .. 1 by 2
for x : (intCount) .. 1
put " " ..
end for
for column : row .. 0
put "*" ..
end for
put ""
intCount := intCount - 1
end for
end if
A sample result if the number 4 is entered:
^^^*
^^***
^*****
*******