Program to find the HCF of two number in C-language

#include<stdio.h>
int main()
{
    int a,b,i,hcf,min;
    printf("Enter first number\n");
    scanf("%d",&a);
    printf("Enter second number\n");
    scanf("%d",&b);
    min=a<b?a:b;
    for(i=1;i<=min;i++)
    {
        if(a%i==0&&b%i==0)
        {
            hcf=i;
        }
    }
    printf("HCF of %d and %dis=%d",a,b,hcf);
}

OUTPUT
Enter first number
55
Enter second number
15
HCF of 30 and 9 is=5

Comments

Popular posts

Creative pattern of butterfly in C-language

Program to show present time and date in C-language

Introduction of C-language.

Program to cheque enter number is a perfect number or not using if else in C-language

Program to cheque four digits number is palindrome or not in C-language

Program to print the cube of a number in c-language

Simple Hello world program in c- language