C Program To Find LCM Of Two Numbers

C Program To Find LCM Of Two Numbers 

/* Author --> HARSH PATEL */                                                                                                                                         
#include <stdio.h>
int main()
{
    int Num1, Num2, max_Value;

    printf("Enter Two Integer Values \n");
    scanf("%d %d", &Num1, &Num2);

    max_Value = (Num1 > Num2)? Num1 : Num2;

    while(1) //Alway True
    {
    	if(max_Value % Num1 == 0 && max_Value % Num2 == 0)
    	{
    		printf("LCM of %d and %d = %d", Num1, Num2, max_Value);
    		break;
		}
		++max_Value;
	}
    return 0;
}


output-1

Enter Two Integer Values 
10
20
LCM of 10 and 20 = 20


output-2

Enter Two Integer Values 
150
250
LCM of 150 and 250 = 750



•now the program ends without any error.

Popular posts from this blog

C Program To Print Hello World

Declare And Initialize Two Character Constants And Output It To User

C Program To Calculate Profit Or Loss