// Write a program to print HCF of two numbers. Using while-loop.//
hcf stand for highest comman factor
program :
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,i,h;
printf("\n Enter the value of a= ");
scanf("%d",&a);
printf("\n Enter the value of b= ");
scanf("%d",&b);
if(a>b)
{
h=a;
}
else
{
h=b;
}
i=h;
while(i>=1)
{
if(a%i==0 && b%i==0)
{
printf("\n HCF=%d",i);
break;
}
i--;
}
getch();
}
No comments:
Post a Comment