Can anyone please make the program of hcf and lcm in c programming using functions. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 13

Can anyone please make the program of hcf and lcm in c programming using functions.

10th Oct 2018, 10:37 AM
....D.....
11 Answers
+ 9
thanks... but actually I could do lcm but I am unable to find hcf... so can you help me in this regard
10th Oct 2018, 10:48 AM
....D.....
+ 9
Shubham Kumar thank you dear 😊😊
6th Dec 2018, 5:30 AM
....D.....
+ 6
int main() { int n1, n2, i, gcd; printf("Enter two integers: "); scanf("%d %d", &n1, &n2); for(i=1; i <= n1 && i <= n2; ++i) { if(n1%i==0 && n2%i==0) gcd = i; } printf("G.C.D of %d and %d is %d", n1, n2, gcd); return 0; }
6th Dec 2018, 5:26 AM
Shubham Kumar
+ 5
Find hcf or gcd using c lang👆
6th Dec 2018, 5:26 AM
Shubham Kumar
+ 5
Disha Welcome Dear😊
6th Dec 2018, 5:37 AM
Shubham Kumar
+ 4
To find HCF 1>We divide the bigger number by smaller one. 2> Divide smaller number in step 1 with remainder obtained in step 1. 3.>Divide divisor of second step with remainder obtained in step 2. 4>We will continue this process till we get remainder zero and divisor obtained in end is the required H.C.F.
6th Dec 2018, 5:24 AM
Shubham Kumar
+ 3
highest common fraction is not anything, if you meant greatest common divisor you should look at euclids algorithm, and then implement it in C.
10th Oct 2018, 10:46 AM
Bebida Roja
Bebida Roja - avatar
10th Oct 2018, 10:50 AM
Bebida Roja
Bebida Roja - avatar
+ 2
but it looks for greatest common divisor
10th Oct 2018, 10:50 AM
Bebida Roja
Bebida Roja - avatar
+ 1
not hcf(if not gcd, whatever it is)
10th Oct 2018, 10:51 AM
Bebida Roja
Bebida Roja - avatar
+ 1
yes, that finds highest common factor
10th Oct 2018, 10:52 AM
Bebida Roja
Bebida Roja - avatar