C++ Examples – C++ program to find HCF and LCM of two numbers




cpp tutorials
cpp tutorials
# include <iostream>
# include <string>
using namespace std;
int main()
{
  int a,b,c;
  cout<< "Enter two nos :"<<endl;
  cout<< "Enter first no. : ";
  cin>>a;
  cout<< "Enter sec. no. : ";
  cin>>b;
  c=a*b;
  while(a!=b)
    {
      if(a>b)
        a=a-b;
      else
        b=b-a;
    }
  cout<< "HCF = " << a<<endl;
  cout<< "LCM = " << c/a<<endl;
  return 0;
}

/*
OUTPUT:
Enter two nos :
Enter first no. : 5
Enter sec. no. : 9
HCF = 1
LCM = 45
*/

Different ways of Putting the above question

  • Write a c++ program to find LCM of two numbers
  • I want a C++ program to find LCM and HCF of two
  • Find hcf and lcm using recursive technique
  • How To write a c program to calculate the lcm and hcf
  • LCM And HCF C++.Program to find HCF and LCM

 

 


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





1 Comment

Leave a Reply

Your email address will not be published.


*