C++ Program to Find LCM and HCF of Two Numbers on Command Line

I’m writing every article I think will help you in some way. in that respect C++ Program to Find LCM and HCF of Two Numbers on Command Line This article will be very useful for you.

C++ Program to Find LCM and HCF of Two Numbers on Command Line

C++ Program to Find LCM and HCF of Two Numbers on Command Line

/* To find the LCM and HCF of 2 given numbers*/

#include<stdio.h>
#include<conio.h>

void main(){
	int m, n, a, b, temp;

	START:
	printf("nEnter the numbers m and n :");
	scanf("%d%d",&m,&n);
	a = n; b = m;
	if (m*n == 0)
		printf("HCF and LCM cannot be enumerated for 0");
	else{
		while (n>0){
			temp = n;
			n = m % n;
			m = temp;
		}
		printf("HCF = %dt LCM = %dn",m,a*b/m);

		goto START; 
	}
	_getch();


}

Read Also: C++ Graphics Program to Draw Flowerpot Design in Command Line

Final Words

C++ Program to Find LCM and HCF of Two Numbers on Command Line Thank you for reading this useful article. Also, let us know if you have any doubts about this article. We are committed to helping you.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment