Friday, November 29, 2013

/* C Program to Find Highest Common Factor. */
#include<stdio.h>
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; 
}

Output:
Enter two integers: 
14 35 
HCF of 14 and 35 is 7

No comments :

Post a Comment