Answer as much as you can x, exchange x and y.x = 78, y = 36;78/36 = 2 with a remainder of 6, r + 0; x becomes 36, y becomes 6.x = 36, y = 6,36/6 = 6 with a remainder of 0, r = 0; answer is y =...


Answer as much as you can


Part B - Finding Greatest Common Divisor (GCD)<br>Design and develop a solution with functions (modules) and control structures for a program<br>that finds the greatest common divisor (GCD) of positive integers x and y.<br>The Euclidean algorithm for finding the GCD of x and y is defined as follows:<br>• if y is greater than x, then exchange x and y;<br>• divide x by y and get the remainder r; if r is equal to 0, then GCD(x, y) is y; stop the<br>loop.<br>• replace x by y and replace y by r; return to the previous step.<br>For example, finding GCD of 36 and 78:<br>x = 36, y = 78<br>y > x, exchange x and y.<br>x = 78, y = 36;<br>78/36 = 2 with a remainder of 6, r + 0; x becomes 36, y becomes 6.<br>x = 36, y = 6,<br>36/6 = 6 with a remainder of 0, r = 0; answer is y = 6.<br>Provide screenshot of the program run in the answer script if your developed program produces<br>the expected output. Note that you are required to maintain a good program style when<br>developing your C++ program. Program style refers to things that make your program easy to<br>read and understand but do not affect the execution of the program. Follow the advice given<br>for placing whitespaces to improve readability, choosing good user-defined identifiers and<br>giving comments that are relevant and liberally, but not to excess.<br>Part B- Assessment<br>Part 1- Program Design Elements<br>i.<br>Construct a structure chart with data flow and execution of conditional and loops for<br>program design.<br>ii.<br>Construct a flowchart for the Euclidean Algorithm to illustrate the execution flow of<br>the process.<br>Part 2 - Use of Selection and Loop Control Structures<br>The following processes/modules will be assessed:<br>i.<br>The module that reads x and y.<br>ii.<br>The module that finds GCD using the Euclidean algorithm.<br>iii.<br>The module that prints GCD.<br>

Extracted text: Part B - Finding Greatest Common Divisor (GCD) Design and develop a solution with functions (modules) and control structures for a program that finds the greatest common divisor (GCD) of positive integers x and y. The Euclidean algorithm for finding the GCD of x and y is defined as follows: • if y is greater than x, then exchange x and y; • divide x by y and get the remainder r; if r is equal to 0, then GCD(x, y) is y; stop the loop. • replace x by y and replace y by r; return to the previous step. For example, finding GCD of 36 and 78: x = 36, y = 78 y > x, exchange x and y. x = 78, y = 36; 78/36 = 2 with a remainder of 6, r + 0; x becomes 36, y becomes 6. x = 36, y = 6, 36/6 = 6 with a remainder of 0, r = 0; answer is y = 6. Provide screenshot of the program run in the answer script if your developed program produces the expected output. Note that you are required to maintain a good program style when developing your C++ program. Program style refers to things that make your program easy to read and understand but do not affect the execution of the program. Follow the advice given for placing whitespaces to improve readability, choosing good user-defined identifiers and giving comments that are relevant and liberally, but not to excess. Part B- Assessment Part 1- Program Design Elements i. Construct a structure chart with data flow and execution of conditional and loops for program design. ii. Construct a flowchart for the Euclidean Algorithm to illustrate the execution flow of the process. Part 2 - Use of Selection and Loop Control Structures The following processes/modules will be assessed: i. The module that reads x and y. ii. The module that finds GCD using the Euclidean algorithm. iii. The module that prints GCD.
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here