C program to find the G.C.D. of two number.

Posted by Mangesh on March 16, 2018

/* Program to find Greatest Common Factor of two number. */

Description :

The greatest common divisor (GCD) of a set of integers is the largest integer that divides each integer in the set. It is also called Highest Common Factor.

Program :

int gcd(int a,int b)
  return b;
  return gcd(b%a,a);
void swap(int a,int b)
  int temp;
  temp = a;
  a = b;
  b = temp;
void main()
  int x,y;
  printf("Enter first number : ");
  printf("Enter second number : ");
  printf("Greatest Common Factor of %d and %d is %d.",x,y,gcd(x,y));

Output :

C program for gcd` tested in Turbo C 3.2

Written with from Mangesh.

Related Post
1 C program to calculate factorial of given number.
2 C program to convert decimal number to binary number.
3 C program to find the G.C.D. of two number.
Latest Post
1 C program to implement Queue using linked list.
2 C program for binary search tree (BST).
3 C program to search an element in linked list.
4 C program for postorder traversal in binary tree.
5 C program for preorder traversal in binary tree.