Thursday, July 25, 2019

Find HCF(gcd) of two number

Tags

Find  HCF(gcd) of two number:


find hcf(gcd) of two number


#include<stdio.h>
#include<conio.h>

void main()
{
int i,num1,num2,temp,HCF=1;
clrscr();

printf("Enter Any Two Numbers To Find HCF:- ");
scanf("%d%d",&num1,&num2);

temp=(num1<num2)?num1:num2;

for(i=1;i<=temp;i++)
{
if(num1%i==0 && num2%i==0)
{
HCF=i;
}
}
printf("HCF of %d and %d=%d\n",num1,num2,HCF);
getch();
}


Output:




EmoticonEmoticon