11.2 Constructs (3)

Resources | Revision Questions | Computer Science

Login to see all questions

Click on a question to view the answer

1.

Consider a scenario where you need to calculate the sum of the first 'n' positive integers. Write pseudo-code for a count-controlled loop to achieve this. Assume 'n' is an integer input from the user.

2.

Write pseudo-code for a 'while' loop that repeatedly prompts the user for positive integer input until a valid input is provided. The loop should continue until the user enters a number greater than 0. The prompt message should be "Enter a positive integer:". The user's input should be stored in a variable called number.

3.

Write pseudo-code for a 'pre-condition' loop that repeatedly prompts the user for positive integer input until a number greater than 10 is entered. The loop should include input validation to ensure the user enters a valid integer.