20_10

Write a C program to find LCM of two numbers using GCD

Source code:

 //C program to find LCM of two numbers using GCD

#include <stdio.h>

int main()

{

int Num1, Num2, LCM; 

printf("Enter two number: ");

scanf("%d %d", &Num1, &Num2); 

int a = Num1;

int b = Num2;

int Temp, GCD;

while (Num2 != 0)

{

    Temp = Num2;

    Num2 = Num1 % Num2;

    Num1 = Temp;

}

GCD = Num1;

LCM = (a * b) / GCD;

printf("LCM  = %d", LCM);

return 0;

}

Output:

C program to find LCM of two numbers using GCD


No comments:

Post a Comment

Write a program in C to convert a decimal number to binary using recursion.

 Source code: //Write a program in C to convert a decimal number to binary using recursion. #include<stdio.h> long convertB_to_D(int d...