Algorithm Thinking Solution
Algorithm Thinking Solution
QUESTION 1
• Assignment: X ← Y + Z
• Iteration: FOR X ← 1 TO 10
• Input: READ X
• Output: PRINT X
• Reason: An array allows you to store a fixed number of elements (e.g., 24 values for hourly
temperatures in a day) in a sequential manner, enabling easy indexing and retrieval.
1. IF...THEN...ELSE
2. CASE...OF...OTHERWISE
QUESTION 2
• FOR I ← 1 TO 300: Loops through 300 iterations, one for each patient.
• INPUT Name[I]: Inputs and stores the name of each patient into the array Name[I].
• NEXT I: Ends the current iteration and moves to the next one.
INPUT Name[I]
I←I+1
ENDWHILE
(c). Algorithm to input a number between 0 and 100
REPEAT
INPUT Number
ENDIF
QUESTION 3
The condition UNTIL Count = 0 will never be met because Count starts at 0 and is incremented after
each iteration. It will never go back to 0.
Count ← 0
REPEAT
INPUT Value
Values[Count] ← Value
Count ← Count + 1
ENDIF
UNTIL Count = 50
(c). Modify pseudocode to limit values to 100–200
Count ← 0
REPEAT
INPUT Value
Values[Count] ← Value
Count ← Count + 1
ENDIF
UNTIL Count = 50
QUESTION 4
• Error 3 (Line 14): Mark[Count] ← HighestMark overwrites the mark instead of assigning
HighestMark.
LowestMark ← 100
LowestMarkStudents ← 0
FOR Count ← 1 TO 35
INPUT Name[Count]
INPUT Mark[Count]
HighestMarkStudents ← HighestMarkStudents + 1
ENDIF
HighestMark ← Mark[Count]
HighestMarkStudents ← 1
ENDIF
LowestMarkStudents ← LowestMarkStudents + 1
ENDIF
LowestMark ← Mark[Count]
LowestMarkStudents ← 1
ENDIF
NEXT Count
OUTPUT "There are ", HighestMarkStudents, " students with the highest mark of ", HighestMark
OUTPUT "There are ", LowestMarkStudents, " students with the lowest mark of ", LowestMark