C Program to calculate HCF

Simple C Program to calculate highest common factor of two numbers.
#include <stdio.h>
 int main() 
 {
  int a,b,c,hcf;
 
  printf("Enter first number: ");
  scanf("%d",&a);
  printf("Enter sceond number: ");
  scanf("%d",&b);
 
  while (b != 0) {
    c = b;
    b = a % b;
    a = c;
  }
 
  hcf = a;
 
  printf("HCF = %d\n",hcf);
 
  return 0;
}



Popular posts from this blog