#include<stdio.h>
int main(){
int n1,n2,x,y,lcm,gcd;
printf("\nEnter two numbers:");
scanf("%d %d",&n1,&n2);
lcm=func1(n1,n2);
gcd=func2(n1,n2);
printf("L.C.M=%d G.C.D=%d",lcm,gcd);
return 0;
}
int func1(int n1,int n2){
int x,y;
x=n1,y=n2;
while(n1!=n2){
if(n1>n2)
n1=n1-n2;
else
n2=n2-n1;
}
return (x*y)/n1;
}
int func2(int n1,int n2){
int x,y;
x=n1,y=n2;
while(n1!=n2){
if(n1>n2)
n1=n1-n2;
else
n2=n2-n1;
}
return n1;
}
output:
No comments:
Post a Comment