DECLARE data : ARRAY[1:5] OF INTEGER
DECLARE target : INTEGER
DECLARE found : BOOLEAN
data ← [5, 2, 8, 1, 9]
target ← 11
found ← FALSE
FOR index ← 1 TO 5 DO
IF data[index] = target THEN
found ← TRUE
OUTPUT "Target found"
BREAK
ENDIF
NEXT index
IF found = FALSE THEN
OUTPUT "Target not found"
ENDIF
data = [5, 2, 8, 1, 9]
target = 11
found = False
for index in range(len(data)):
if data[index] == target:
found = True
print("Target found")
break
if not found:
print("Target not found")
Dataset: [5, 2, 4, 1, 6, 3]
[2, 5, 4, 1, 6, 3]
[2, 4, 5, 1, 6, 3]
[2, 4, 1, 5, 6, 3]
[2, 4, 1, 5, 6, 3]
[2, 4, 1, 5, 3, 6]
[2, 1, 4, 3, 5, 6]
[1, 2, 3, 4, 5, 6]
(No swaps; sorted.)DECLARE nums : ARRAY[1:11] OF INTEGER
nums ← [66, 7, 69, 50, 42, 80, 71, 321, 67, 8, 39]
DECLARE numlength : INTEGER
numlength ← 11
DECLARE swaps : BOOLEAN
swaps ← TRUE
WHILE swaps DO
swaps ← FALSE
FOR y ← 1 TO numlength - 1 DO
IF nums[y] > nums[y + 1] THEN
DECLARE temp : INTEGER
temp ← nums[y]
nums[y] ← nums[y + 1]
nums[y + 1] ← temp
swaps ← TRUE
ENDIF
NEXT y
numlength ← numlength - 1
ENDWHILE
OUTPUT nums
nums = [66, 7, 69, 50, 42, 80, 71, 321, 67, 8, 39]
numlength = len(nums)
swaps = True
while swaps:
swaps = False
for y in range(numlength - 1):
if nums[y] > nums[y + 1]:
nums[y], nums[y + 1] = nums[y + 1], nums[y]
swaps = True
numlength -= 1
print(nums)
Total ← 0
FOR Count ← 1 TO ReceiptLength DO
INPUT ItemValue
Total ← Total + ItemValue
NEXT Count
OUTPUT Total
Count ← 0
DO
OUTPUT "Pass number", Count
Count ← Count + 1
UNTIL Count >= 50
Total ← 0
Scores ← [25, 11, 84, 91, 27]
Highest ← max(Scores)
Lowest ← min(Scores)
FOR Count ← 0 TO LENGTH(Scores) - 1 DO
Total ← Total + Scores[Count]
NEXT Count
Average ← Total / LENGTH(Scores)
OUTPUT "The highest score is:", Highest
OUTPUT "The lowest score is:", Lowest
OUTPUT "The average score is:", Average