Search (Article Or Program)

18 June 2011

L.C.M of Three Numbers (in C)

#include
#include
main()
{
clrscr();
printf("\t\t>>>>>>>>>>>>L.C.M of 3 Numbers<<<<<<<<<<\n\n");
int a,b,c,l,m,n,r,x,y,z;
printf("Enter 1st Number : \n");
scanf("%d",&a);
printf("Enter 2nd Number :\n");
scanf("%d",&b);
printf("Enter 3rd Number :\n");
scanf("%d",&c);
x=a;
y=b;
z=c;
while(b!=0)
{
r=a%b;
a=b;
b=r;
}
l=(x*y)/a;
m=l;
while(c!=0)
{
r=l%c;
l=c;
c=r;
}
n=(m*z)/l;
printf("The result is %d",n);
getch();
}