Tuesday, March 21, 2023

find the lcm of any two numbers in c.

  //find the lcm of any two numbers

 #include <stdio.h>
 int main (){
    int num1,num2,i,hcf,lcm ;
    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;
        }
    }
    lcm=(num1*num2)/hcf ;
    printf ("lcm of %i and %i is %i ",num1,num2,lcm);
    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 ("...