LCM HCF of Two Numbers coderinme

LCM HCF of Two Numbers coderinme

LCM HCF of Two Numbers coderinme
The full form of LCM is Least Common Multiple. What is it? The least number which is exactly divisible by each one of the given numbers is called their L.C.M. The full form of HCF is Highest Common Factor. Its is also known as Greatest Common Measure (G.C.M.) or Greatest Common Divisor (G.C.D.). Now what is this term? The H.C.F. of two or more than two numbers is the greatest number that divides each of them exactly.
C program to find the LCM (lowest common divisor) and HCF (Highest Common Factor) of entered two numbers.

#include <stdio.h>
int main()
{
int a,b, max, HCF,LCM;
printf("Enter two positive integers: ");
scanf("%d %d", &a,&b);
max = ( a < b ) ? a : b;
while(1)
{
if( max % a == 0 && max % b == 0 )
{
LCM = max;
printf("LCM: %d\n",LCM);
HCF = ( a * b ) / LCM;
printf("HCF: %d",HCF);
break;
}
max++;
}
getch();
return 0;
}

For more programs in C, visit our C Coder Archives

LCM HCF of Two Numbers coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.