#include<stdio.h>
#include<conio.h>
int hcf(int n1 ,int n2);
void main()
{
int n1,n2;
clrscr();
printf("enter the two number =");
scanf("\n%d\n%d",&n1 ,&n2);
printf("\n HCF of two numbers is =%d",hcf(n1,n2));
getch();
}
int hcf(int n1 ,int n2)
{
int i,minimum,u;
if (n1>n2)
{
minimum=n2;
}
else
{
minimum=n1;
}
for(i=minimum;i>=1;i--)
{
if(n1%i==0 && n2%i==0)
{
u=i;
return u;
}
}
}
No comments:
Post a Comment