C Program To Find GCD using Pointers and Functions, using Euclid's Algorithm

C Program To Find GCD using Pointers and Functions, using Euclid's Algorithm

Technotip

4 года назад

2,777 Просмотров

https://technotip.com/8030/c-program-to-find-gcd-using-pointers-and-functions/

Write a function to compute the greatest common divisor given by Euclid's algorithm, exemplified for J = 1980, K = 1617 as follows:

1980 / 1617 = 1 1980 - 1 * 1617 = 363
1617 / 363 = 4 1617 - 4 * 363 = 165
363 / 165 = 2 363 - 2 * 165 = 33
5 / 33 = 5 165 - 5 * 33 = 0

Thus, the greatest common divisor is 33.

Analyze Above Problem Statement
1. We need to find Greatest Common Divisor(GCD) of 2 numbers entered by the user, using Euclid’s Algorithm.

2. If J = 1980 and K = 1617, GCD should be 33.

3. Make sure to use the calculation part as shown in problem statement.

4. We observe the calculation part in problem statement and formulate some formulas to figure out the result i.e., GCD of 2 numbers input by the user.

C Programming Interview / Viva Q&A List
https://technotip.com/6378/c-programming-interview-viva-qa-list/

C Programming: Beginner To Advance To Expert
https://technotip.com/6086/c-programming-beginner-to-advance-to-expert/

Тэги:

#C_Programming #GCD #Euclidean_algorithm #Eulid #Euclid’s_algorithm #pointers #functions #Greatest_Common_Divisor #numerator #denominator
Ссылки и html тэги не поддерживаются


Комментарии: