google search

Popular Posts


Welcome to BCA Notes

>>>>>>>>>>>>>>>>

Visitors

Search This Blog

Blogger templates

Visitor Map


Thursday, 26 June 2014

c++ program for finding HCF and LCM




Source Code:-
#include<iostream.h>
#include<conio.h>
 
int main()
 {
  int a,b,x,y,t,hcf,lcm;
 
  cout<<"Enter 1st number"<<endl;
  cin>>x;
  cout<<"Enter 2nd number"<<endl;
  cin>>y;
 
  a=x;
  b=y;
 
  while(b!=0)
  {
    t=b;
    b=a%b;
    a=t;
  }
 
  hcf=a;
  lcm=(x*y)/hcf;
 
  cout<<"HCF : "<<hcf<<endl;
  cout<<"LCM :"<<lcm;
 getch();
  return 0;
}

For any questions,query,suggestion & output :-
Contact Me
write to me
@
rishabhbaid96@gmail.com

0 comments:

Post a Comment