fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int a, b, hcf;
  5. printf("Enter two numbers:\n ");
  6. scanf("%d %d", &a, &b);
  7.  
  8. while (a != b) {
  9. if (a > b)
  10. a -= b;
  11. else
  12. b -= a;
  13. }
  14. hcf = a;
  15. printf("HCF = %d\n", hcf);
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 5324KB
stdin
12 18
stdout
Enter two numbers:
 HCF = 6