Q : Write a program to calculate Greatest Common Factor ?
The highest number that divides exactly into two or more numbers. It is the "greatest" thing for simplifying fractions!
Greatest Common Factor of 12 and 16 is 4 because after 4 there is not any number which devide both 12 and 16.
Solution :
/* ################################
Girfa Student Help
HCF
for more visit :
http://girfahelp.blogspot.in/p/c-language.html
################################
*/
#include<stdio.h>
void main()
{
int
min,max,hcf,i,x;
printf("Enter
first Number>> ");
scanf("%d",&min);
printf("Enter
Second Number >> ");
scanf("%d",&max);
for(i=min;i>=1;i--)
{
if(min%i==0 &&
max%i==0)
{
hcf=i;
break;
}
}
printf("\n\tH.C.M
is %d",hcf);
}
No comments:
Post a Comment