Find GCD of Two Numbers C Program

C Program To Find GCD of Two Numbers

Learn How To Find GCD of Two Numbers in C Programming Language. GCD is an abbreviated form for Greatest Common Divisor. This C Program To Calculate GCD of Two Integers have been developed using a While Loop. The Output of the Code is displayed below.

What is GCD?

The Greatest Common Divisor (GCD) of Two or more than Two Integers is the Largest Integer (which is Positive) that Divides the Numbers without a Remainder.


Example of GCD

The LCM of 3 and 2 is 1.

The GCD of 12 and 8 is 4.

Formula To Find GCD of Two Integers

54

The Number 54 can be divided by 1, 54, 2, 18, 27, 6, 9, 3

24

The Number 24 can be divided by 1, 24, 3, 8, 12, 2, 4, 6

Common Divisors: 1, 2, 3, 6

The Largest Divisor is 6. Therefore, GCD of Integers 54 and 24 is 6.


Must Read: C Program To Print Strong Numbers From 1 To N


Method 1: C Program To Find GCD of Two Numbers using While Loop

Must Read: Find LCM of Two Integers in C Programming

Method 2: C Program To Find GCD of Two Integers using For Loop

Must Read: C Program To Convert Integers into Words (Strings)

Output

C Program To Find GCD of Two Numbers

In case you find any error in the above C Program To Find GCD of Two Numbers or if you have any doubts, let us know about it in the Comment Section below.

5 thoughts on “Find GCD of Two Numbers C Program

    1. Kush Rohan

      Yes. I don’t think there would be any problem in compiling this program in your Macbook.

      Reply
  1. Sanjay Shukla

    After getting gcd of integers, it is very easy to get lcm. Excellent code. Simplifies the logic.

    Reply

Let's Discuss