C program to find L.C.M.


                                         To find the L.C.M. ( Least Common Multiple ) Simply list the multiples of each number (multiply by 2, 3, 4, etc.) then look for the smallest number that appears in each list.

C program to find L.C.M as below.


Source Code to Find L.C.M

#include<stdio.h>
void main()
{
       int n1,n2,x,y;
       clrscr();

       printf("\nEnter first numbers:");
       scanf("%d",&n1);
       printf("\nEnter second numbers:");
       scanf("%d",&n2);
       x=n1,y=n2;
       while(n1!=n2)
       {
           if(n1>n2)
                   n1=n1-n2;
           else
                   n2=n2-n1;
       }
       printf("\nL.C.M=%d",x*y/n1);
       getch();

}


c program to find L.C.M.

0 comments:

Post a Comment