#include<conio.h>
#include<iostream.h>
int HCF_of(int x,int y);
void main()
{ clrscr();
int x,y,z;
cout<<"Enter 2 nos. ";
cin>>x>>y;
z=HCF_of(x,y);
cout<<"HCF is "<<z;
getch();
}
int HCF_of(int x,int y)
{ int a,b,c;
a=x>y?x:y;
b=x<y?x:y;
for (int i=1;i<=a;i++)
{ if (a%i==0)
{ if (b%i==0)
c=i;
}
}
return(c);
}
#include<iostream.h>
int HCF_of(int x,int y);
void main()
{ clrscr();
int x,y,z;
cout<<"Enter 2 nos. ";
cin>>x>>y;
z=HCF_of(x,y);
cout<<"HCF is "<<z;
getch();
}
int HCF_of(int x,int y)
{ int a,b,c;
a=x>y?x:y;
b=x<y?x:y;
for (int i=1;i<=a;i++)
{ if (a%i==0)
{ if (b%i==0)
c=i;
}
}
return(c);
}
No comments:
Post a Comment