+ 13
Can anyone please make the program of hcf and lcm in c programming using functions.
12 Antworten
+ 9
thanks... but actually I could do lcm but I am unable to find hcf... so can you help me in this regard
+ 9
Shubham Kumar thank you dear 😊😊
+ 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;
}
+ 5
Find hcf or gcd using c lang👆
+ 5
Disha Welcome Dear😊
+ 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.
+ 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.
+ 2
but it looks for greatest common divisor
+ 1
not hcf(if not gcd, whatever it is)
+ 1
yes, that finds highest common factor