9.2 Algorithms (3)

Resources | Revision Questions | Computer Science

Login to see all questions

Click on a question to view the answer

1.

Write pseudo-code to calculate the average of three numbers. The program should prompt the user to enter three numbers, store these values, calculate the average, and then display the average to the user. The average should be displayed to two decimal places.

2.

Consider an algorithm to determine if a given year is a leap year. A year is a leap year if it is divisible by 4, except for years divisible by 100 but not by 400. Write an algorithm, using logic statements, to determine if a given year is a leap year.

3.

The following flowchart illustrates an algorithm for calculating the factorial of a non-negative integer. Write pseudo-code to represent this algorithm.

Flowchart for Factorial