C Program to find the HCF of the numbers - With Output

#include<conio.h>
#include<stdio.h>

void main()
{
int num1,num2,min,i;
printf(“Enter two numbers  : ”);
scanf(“%d%d”,&num1,&num2);
min=(num1>num2)?num2:num1;

for(i=min;i>=1;--i)
{
                if(num1%i==0&&num2%i==0)
{
                                printf(“HCF of %d and %d is %d”,num1,num2,i);
                                break;
}
}

getch();
}

OUTPUT :
Enter two number 5 10

HCF of 5 and 10 is 5
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment