Tuesday, 23 June 2015

C PROGRAM TO FIND L.C.M OF TWO NUMBERS



#include<stdio.h>
int main()
{
    int n1,n2,p1,p2;
    printf("Enter two positive integers: ");
    scanf("%d %d",&n1,&n2);
    p1=n1;
    p2=n2;
    while(p1!=p2)
    {
        if(p1>p2)
            p1-=p2;
        else
            p2-=p1;
    }
    printf("LCM of two numbers %d and %d is %d", n1, n2, (n1*n2)/p1);
    return 0;
}

OUTPUT
Enter two positive integers : 5
6
LCM of two numbers 5 and 6 is 30