Tuesday, March 21, 2023

find the hcf of any two numbers in c

  //find the hcf of any two numbers

 #include <stdio.h>
 int main (){
    int num1,num2,i,hcf ;
    printf ("enter two numbers :");
    scanf ("%i%i",&num1,&num2);
    for (i=1;i<=num1&&i<=num2;i++){
        if (num1%i==0 && num2%i==0){
            hcf =i;
        }
    }
     
    printf ("hcf of %i and %i is %i ",num1,num2,hcf);
    return 0;
 }

No comments:

Post a Comment

print a multiplication table of any integer taking from user

 // print a multiplication table of any integer taking from user  #include "stdio.h" int main () { int n,mul,i; printf ("...