LCM of Two Numbers In C

LCM of Two Numbers In C


Program in c to Find Lowest Common Multiple(LCM) of two Numbers


Home » C-Programming » Basic C Programming » Program to print “Hello world”

 

« Previous Program

Next Program »


Write a Program in c to Find Lowest Common Multiple(LCM) of two Numbers

\* C Program to to Find Lowest Common Multiple(LCM) of two Numbers *\

# include < stdio.h >
int  main( )
{

int  num1, num2, i, gcd ;
printf(" Enter the first Number : ") ;
scanf("%d ",& num1) ;
printf("\n Enter the second Number : ") ;
scanf("%d ",& num2) ;
i = 1 ;
do
{

if(  num1 % i   == 0   &&  num2  % i   == 0  )
gcd = i ;
i = i + 1 ;

}
while (  i  <=  10) ;
lcm = ( num1 * num2 ) / gcd ;
printf(" Lowest Common Multiple of Entred Number is : ") ;
printf("%d ",lcm) ;
return ( 0 ) ;

}

Output of Program: