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