You are on page 1of 3

Programming Supplementary Exercise 3 (Practical Task)

1. Write a C++ program to check if x is a common factor of y and z. The sample output is shown
below:

Sample Output 1
Input x: 5
Input y: 10
Input z: 15
5 is a common factor of 10 and 15

Sample Output 2
Input x: 3
Input y: 7
Input z: 12
3 is NOT a common factor of 7 and 12
2. Modify Further Practice Question 2 to show the number of $5 coins, $2 coins and $1 coins
needed to pay a given amount. The sample output is shown below.
Amount = 28
Number of $5 coin = 5
Number of $2 coin = 1
Number of $1 coin = 0
3. In an annual dinner, 12 guests occupy 1 table. Mary writes a program to calculate how many
tables are needed and the number of empty seats based on the total number of guests.
The sample outputs of her program are shown below:

Sample Output 1
Number of guests = 60
Number of tables = 5
Number of empty seats = 0

Sample Output 1
Number of guests = 65
Number of tables = 6
Number of empty seats = 7

You might also like