C Program to find lcm of two number
Here we discuss C Program to find lcm of two number
LCM Program Code
#include<stdio.h>
#include<conio.h>
void lcm(int,int);
void main()
{
int a,b;
clrscr();
printf("EANY TWO NUMBER: \t");
scanf("%d %d",&a,&b);
lcm(a,b);
getch();
}
//function to calculate l.c.m
void lcm(int a,int b)
{
int m,n;
m=a;
n=b;
while(m!=n)
{
if(m<n)
{
m=m+a;
}
else
{
n=n+b;
}
}
printf("\nL.C.M OF %d & %d IS %d",a,b,m);
}
No comments:
Post a Comment