Q:

C Program to Find LCM of Two Numbers Using While Loop

belongs to collection: Loops C Programs for Practice

0

Write A C Program to Find LCM of Two Numbers Using while Loop

 

Logic : 

LCM ( Least Common Multiple ) also called the lowest common multiple or smallest common multiple If you have any question please let me know in comment Box .

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>
int main()
{
   int num1, num2, max;
  
   printf("Enter Two Positive Integers :\n");
   scanf("%d %d", &num1, &num2);
  
   max=(num1>num2) ? num1 : num2;
   while(1)                    
   {
       if(max%num1==0 && max%num2==0)
       {
           printf("LCM of %d And %d is %d", num1, num2,max);
           break;      
       }
       ++max;
   }
   return 0;
}

 

Output:

Enter Two Positive Integers:

23 56

LCM of 23 and 56 is 1288

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Program For Reverse A Number Using While Loop... >>
<< C Program to Find GCD of two Numbers Using For Loo...