- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
Following C++ program ask to the user to enter any two number to find HCF & LCM, then display the result on the screen :
Source Code: Print HCF and LCM of Two Numbers
/* C++ Program - Find HCF and LCM of Two Numbers */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int a, b, x, y, t, hcf, lcm; cout<<"Enter two number : "; cin>>x>>y; a=x; b=y; while(b!=0) { t=b; b=a%b; a=t; } hcf=a; lcm=(x*y)/hcf; cout<<"HCF = "<<hcf<<"\n" cout<<"LCM = "<<lcm<<"\n"; getch(); }Output
Enter two number:20 8 HCF=4 LCM=40