1 votes 1 votes Assume $A$ and $B$ are non-zero positive integers. The following code segment: while(A!=B){ if*(A> B) A -= B; else B -= A; } cout<<A; // printing the value of A Computes the $LCM$ of two numbers Divides the larger number by the smaller number Computes the $GCD$ of two numbers Finds the smaller of two numbers Algorithms isro2018 algorithms identify-function + – Arjun asked Apr 22, 2018 recategorized Dec 31, 2019 by Arjun Arjun 4.1k views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply Akshay Koli 4 commented Apr 22, 2018 reply Follow Share it computes the GCD of two numbers so, option C is correct. 1 votes 1 votes scholaraniket commented Jan 2, 2020 reply Follow Share What is the significance of "*" after if statement? 1 votes 1 votes logan1x commented Jan 11, 2020 reply Follow Share @Sayan Bose Can you explain significance of "*"? 0 votes 0 votes Sayan Bose commented Jan 11, 2020 reply Follow Share Typing mistake 1 votes 1 votes Please log in or register to add a comment.
Best answer 2 votes 2 votes This is Euclidean algo for determining HCF of two numbers which works in this way : If we subtract smaller number from larger (we reduce larger number), GCD doesn’t change. So if we keep subtracting repeatedly the larger of two, we end up with GCD. Sayan Bose answered Apr 23, 2018 selected Apr 25, 2018 by Arjun Sayan Bose comment Share Follow See 1 comment See all 1 1 comment reply Rohithsingh1 commented Mar 24, 2022 reply Follow Share it can be solved, by taking suitable numbers, such that each option gets a unique answer. eg: A = 8, B = 12 option A) gives LCM of two numbers = 24 option B) if you divide a larger number by a smaller number it gives = 1 option C) GCD of two numbers = 4 option D) smaller of two numbers = 8 now if you run the code by taking A = 8 and B=12, it gives the output as 4, which is GCD of two numbers. 1 votes 1 votes Please log in or register to add a comment.
3 votes 3 votes option C is correct. sonveer tomar 1 answered Apr 22, 2018 sonveer tomar 1 comment Share Follow See all 0 reply Please log in or register to add a comment.