Make a new start with a new Thought!

NOTE :                // indicates comments.This wont get printed in the output.This is used for for documentation purpose. PROGRAM: #incl...

LCM

NOTE :
              
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.

PROGRAM:

#include <stdio.h>
#include<conio.h>
void main()
{
    int a, b, minMultiple;
    clrscr();
    printf("Enter two positive integers: ");
    scanf("%d %d", &a, &b);

    // maximum number between a and b is stored in minMultiple
    minMultiple = (a>b) ? a : b;

    // Always true
    while(1)
    {
if( minMultiple%a==0 && minMultiple%b==0 )
{
    printf("The LCM of %d and %d is %d.", a, b,minMultiple);
    break;
}
++minMultiple;
    }
    getch();
}

OUTPUT :


0 comments: