Computer Science – 9.2 Algorithms | e-Consult
9.2 Algorithms (1 questions)
Login to see all questions.
Click on a question to view the answer
Pseudo-code:
- Input: Get a list of numbers, 'numbers'.
- Initialization: Set 'hasNegative' to false.
- Sequence:
- For each number 'number' in 'numbers':
- Decision: If 'number' is less than 0:
- Set Flag: Set 'hasNegative' to true.
- Break Loop: Exit the loop.
- Decision: If 'hasNegative' is true:
- Output: Display "The list contains negative numbers."
- Else:
- Output: Display "The list does not contain negative numbers."