Write a program for to find L.C.M. of two given numbers using C language. Following is a source code of L.C.M. (Lowest (Least) Common Multiples).
#include<stdio.h>
#include<conio.h>
int main()
{
int no1,no2,x,y;
clrscr();
printf("Enter two numbers : ");
scanf("%d %d",&no1,&no2);
x=no1, y=no2;
while(no1 != no2)
{
if(no1 > no2)
no1 = no1 - no2;
else
no2 = no2 - no1;
}
printf("LCM = %d", x*y/no1);
getch();
return 0;
}
0 comments :
Post a Comment