Greatest Common Divisor (GCD) or Highest Common Factor (HCF) of two positive integers is the largest positive integer that divides both numbers without remainder. It is useful for reducing fractions to be in its lowest terms.
Lowest Common Multiple (LCM) of two integers is the smallest integer that is a multiple of both numbers.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,product;
clrscr();
printf("Enter two no.\n");
scanf("%d%d",&a,&b);
product=a*b;
while(a!=b)
{
if(a>b)
a=a-b;
else
b=b-a;
}
printf("\nThe GCM is =%d",a);
printf("\nThe LCD is =%d",product);
getch();
}
Output:
Enter two number
4
6
The GCM is=2
The LCD is=24
Lowest Common Multiple (LCM) of two integers is the smallest integer that is a multiple of both numbers.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,product;
clrscr();
printf("Enter two no.\n");
scanf("%d%d",&a,&b);
product=a*b;
while(a!=b)
{
if(a>b)
a=a-b;
else
b=b-a;
}
printf("\nThe GCM is =%d",a);
printf("\nThe LCD is =%d",product);
getch();
}
Output:
Enter two number
4
6
The GCM is=2
The LCD is=24
Pankaj Gaikar is a
professional blogger
from Pune, India who writes on Technology, Android,
Gadgets, social media and latest tech updates at
Punk Tech
,
Being Android
&
Shake The Tech
. Email me
HERE
0 comments :
Post a Comment