Thursday, 8 December 2016

Program to find LCM of 2 nos.

#include<conio.h>
#include<iostream.h>
void main()
{ clrscr();
  int a,b,c,d,e;
  cout<<"Enter 2 nos. ";
  cin>>a>>b;
  for (int i=a;i>=1;i--)
      { c=a*i;
for (int j=b;j>=1;j--)
   { d=b*j;
     if (c==d)
 e=c;
   }
      }
  cout<<"LCM is "<<e;
  getch();
}

No comments:

Post a Comment

Basic Implementation of Array as a Pointer

#include<iostream.h> #include<conio.h> void main() { clrscr();   int arr[5];   cout<<"Enter 5 nos. ";   f...