You are on page 1of 3

1)

REAL = [ ]
count = 0
loop while REAL.hasNext()
count = count + 1
end loop
output count

2a)
MAX = HEIGHTS [0]
loop i from 0 to HEIGHTS.length -1
if HEIGHTS[ i ] > MAX then
MAX = HEIGHTS[ i ]
endif
endloop
output MAX

2b)

Team = [ ]
loop I from 0 to HEIGHTS.length -1
if HEIGHTS[ i ] > 170 then
Team.addItem(NAMES [ i ] )
endif
endloop

3)
status = “”
loop I from 0 to N-1
if NUMS [ i ] = 2 or NUMS [ i ] = 3 then
endloop
status = “FALSE”
else:
status = “TRUE”
endloop
output status

4)
result = n
loop I from 1 to n
result = result * (n - i )
endloop
output result

5)
function sum(n):
if n < 10:
return n
else:
return n % 10 + sum(math.floor(n/10))

6a)
Input (N)
loop for I from 0 to 29:
if N == Table_Number [ i ] then
output Status[ i ]
endif
endloop

6b)
occupied = [ ]
available = [ ]
reserved = [ ]
loop for I from 0 to 29:
if Status [ i ] = “occupied” then
occupied.addItem( Table_Number [ i ] )
if Status [ i ] = “available” then
available.addItem( Table_Number [ i ] )
else:
reserved.addItem( Table_Number [ i ] )
endif
Endloop

7a)
sum = 0
count = 0
loop for I from 0 to Grade.length - 1:
sum = sum + Grade [ i ]
count = count + 1
endloop
output sum/count (or)

7b)
status = “False”
input ID
loop I from 0 to Student_ID.length - 1:
if ID == Students_ID [ i ] then
status = “True”
a=i
endif
endloop

if status = “True” then:


output Grade [ a]
else:
output “The array Student_ID does not include the provided student ID”
endif

7c)
function get_accepted_students(Student_ID, Grade, StudentName):
accepted_students = [] // List to store the names of accepted students

for i = 0 to length(Student_ID) - 1:
if Grade[i] > 70:
student_id = Student_ID[i]
student_name = StudentName[student_id]
accepted_students.append(student_name)

return accepted_students

You might also like