//program to get hcf and lcm of two numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,n,n1,lcm,hcf;
printf("enter numbrs\n");
scanf("%d%d",&a,&b);
if(a>b)
{
n=a;
}
else
{
n=b;
}
for(n1=n;n1>=1;n1--)
{
if(a%n1==0 && b%n1==0)
{
hcf=n1;
break;
}
}
printf("hcf=%d",hcf);
printf("lcm=%d",(a*b)/hcf);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,n,n1,lcm,hcf;
printf("enter numbrs\n");
scanf("%d%d",&a,&b);
if(a>b)
{
n=a;
}
else
{
n=b;
}
for(n1=n;n1>=1;n1--)
{
if(a%n1==0 && b%n1==0)
{
hcf=n1;
break;
}
}
printf("hcf=%d",hcf);
printf("lcm=%d",(a*b)/hcf);
getch();
}
No comments:
Post a Comment