C Program to find the HCF ( GCD ) of 2 Numbers


#include<stdio.h>

int main()
{
         int a, b, max, i;
         printf("Enter 2 Numbers \n");
         scanf("%d \t %d",&a, &b);
       
         while ( a != b ) {
                if ( a > b )
                         a = a - b;
                else
                        b = b - a;
          }
       
          printf(" HCF of 2 Numbers = %d\n",a);
   
          return 0;

}

No comments:

Post a Comment