C Program Code:
#include<stdio.h>
int main()
{
int firstNumber;
int secondNumber;
int lcm;
int i,n;
printf("Find LCM of Two Numbers in C \n");
printf("Enter First Number : ");
scanf("%d",&firstNumber);
printf("Enter Second Number : ");
scanf("%d",&secondNumber);
lcm=0;
n=firstNumber*secondNumber;
for(i=1; i<=n && lcm ==0; i++)
{
if(i%firstNumber==0&&i%secondNumber==0)
{
lcm=i;
}
}
printf("LCM is %d \n",lcm);
printf("Press enter to continue...\n");
fflush(stdin);
getchar();
return 0;
}
|
Find LCM of Two Numbers C Program Output Screenshot
C Program