Figure 8 shows a VB.Net program that is being developed - AQA - GCSE Computer Science - Question 17 - 2021 - Paper 1
Question 17
Figure 8 shows a VB.Net program that is being developed.
It is supposed to calculate and display the highest common factor of two numbers entered by the user.
The ... show full transcript
Worked Solution & Example Answer:Figure 8 shows a VB.Net program that is being developed - AQA - GCSE Computer Science - Question 17 - 2021 - Paper 1
Step 1
State the output from the program in Figure 8 when the user enters the numbers 4 and 4.
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
When the user enters the numbers 4 and 4, the program in Figure 8 outputs 2. This occurs because the loop checks the values of count from 1 to 4, but it does not find an HCF of 4 since it does not iterate through a logical sequence to identify the highest common factor correctly.
Step 2
State the line number from the program in Figure 8 which contains the error that stops the program from sometimes working correctly.
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The line number that contains the error is line 6.
Step 3
Describe how the line of code identified in your answer to 17.2 should be changed so that the program in Figure 8 will work correctly.
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The line should be changed from If num1 Mod count = 0 to If num1 Mod count <= 0, allowing the program to correctly identify the highest common factor, particularly when both input numbers are the same.