3. Source Code to Find HCF or GCD #include int main() { int - TopicsExpress



          

3. Source Code to Find HCF or GCD #include int main() { int num1,num2; printf("Enter two integers: "); scanf("%d %d",&num1,&num2); printf("HCF of %d and %d is ",num1 , num2); while(num1!=num2) { if(num1>num2) num1-=num2; else num2-=num1; } printf("%d",num1); return 0; } This is the best way to find HCF of two numbers. In this method, smaller number is subtracted from larger number and that number is stored in place of larger number. This process is continued until, two numbers become equal which will be HCF. All source codes above displays the same output. Output Enter two integers: 14 35 HCF or 14 and 35 is 7
Posted on: Thu, 29 Aug 2013 10:27:06 +0000

Trending Topics



Recently Viewed Topics




© 2015