Friday, September 12, 2008

L.C.M OF TWO NUMBERS in c programming language


void main()
{
  int n1,n2,x,y;
  clrscr();
  printf("\nEnter two numbers:");
  scanf("%d %d",&n1,&n2);
  x=n1,y=n2;
  while(n1!=n2)
  {
            if(n1>n2)
                        n1=n1-n2;
            else
                        n2=n2-n1;
  }
   printf("L.C.M=%d",x*y/n1);
  getch();
}

No comments:

Post a Comment

Thanks to given comments.......

My Blog List