write a program in c to print LCM using for loop
LCM stand for least common multipleprogram :
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,i;
printf("\n Enter the value of a= ");
scanf("\n %d",&a);
printf("\n Enter the value of b= ");
scanf("\n %d",&b);
for(i=1; i<=a*b; i++ )
{
if(i%a==0&&i%b==0 )
{
printf("\n LCM=%d",i);
}
}
getch();
}
No comments:
Post a Comment