w3ajay

tally tutorial point, ms word 2013, ms excel 2013, ms powerpoint 2010,ccc question with answer in hindi 2021, Tally Prime in hindi , tally prime,Python,in python,programming in python,python

Thursday, December 26, 2019

C program to find HCF or GCD

C program to find HCF or  GCD


C program to find HCF and GCD: The code below finds the highest common factor  of two integers. HCF is also known as the greatest common divisor (GCD) or the greatest common factor (GCF)

#include <stdio.h>
#include<conio.h>
Vode main() 
{
  int a, b, i, gcd;
  printf("Enter two integers\n");
  scanf("%d%d", &a, &b);
for (i=1;i<a && i<b; ++i)
{
if(a%i==0 && b%i==0)
{
gcd=i;
  }
}
  printf("Greatest common divisor of %d and %d = %d\n", a, b, gcd);
  getch();
}

No comments:

Post a Comment

for more information please share like comment and subscribe