NextIndexPrevious

Programs in C language

8. Program to find LCM of given number.
#include<stdio.h>

void main()
{
	int a, b, i;
    clrscr();
    printf("Enter any two numbers:");
    scanf("%d%d",&a,&b);
    
    for(i=2;i<=(a*b);i++)
    {
    	if(i%a==0 && i%b==0)
        	printf("LCM = %d",i);
        break;
     }
     getch();
}
Input :

12 30
Output :

LCM = 60



Father of C Language
Dennis Ritchie

Dennis Ritchie

Born: September 9, 1941, Bronxville
Died: October 9, 2011, Murray Hill