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


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


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)


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.

Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

5 thoughts on “Find GCD of Two Numbers C Program

  • September 8, 2016 at 4:26 pm

    Is this code compatible to work in Macintosh OS?

    • October 3, 2016 at 10:16 pm

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

  • September 8, 2016 at 4:27 pm

    This is really so simple to understand. Thank you so much.

  • September 20, 2016 at 12:05 am

    Is it possible to solve gcd of 2 integers using recursion function?

  • October 5, 2016 at 4:40 pm

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


Join The Discussion