A student is tracing the following algorithm. The function INT gives the integer part of any number, eg INT(2.3) = 2 and INT (6.7) = 6. Line 10 Input A, B Line 20 Let C = INT(A ÷ B) Line 30 Let D = B × C Line 40 Let E = A – D Line 50 If E = 0 then go to line 90 Line 60 Let A = B Line 70 Let B = E Line 80 Go to line 20 Line 90 Print B Line 100 Stop Trace the algorithm in the case where the input values are: (a) (i) A = 36 and B = 16; (ii) A = 11 and B = 7. (b) State the purpose of the algorithm.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 22PE
icon
Related questions
Question

solve the question(b)

A student is tracing the following algorithm. The function INT gives the
integer part of any number, eg INT(2.3) = 2 and INT (6.7) = 6.
Line 10 Input A, B
Line 20 Let C = INT(A ÷ B)
Line 30
Let D = B × C
Line 40
Let E = A – D
Line 50 If E = 0 then go to line 90
Line 60
Let A = B
Line 70
Let B = E
Line 80 Go to line 20
Line 90 Print B
Line 100 Stop
Trace the algorithm in the case where the input values are:
(a) (i) A = 36 and B = 16;
(ii) A = 11 and B = 7.
(b) State the purpose of the algorithm.
Transcribed Image Text:A student is tracing the following algorithm. The function INT gives the integer part of any number, eg INT(2.3) = 2 and INT (6.7) = 6. Line 10 Input A, B Line 20 Let C = INT(A ÷ B) Line 30 Let D = B × C Line 40 Let E = A – D Line 50 If E = 0 then go to line 90 Line 60 Let A = B Line 70 Let B = E Line 80 Go to line 20 Line 90 Print B Line 100 Stop Trace the algorithm in the case where the input values are: (a) (i) A = 36 and B = 16; (ii) A = 11 and B = 7. (b) State the purpose of the algorithm.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Distributed Database Concepts
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning