#include<stdio.h>

int lcm(int a,int b); 

int main()
{
	int a;
	int b;

	printf("Enter two numbers to find lcm of ? :-\n1. ");
	scanf("%d",&a);
	printf("2. ");
	scanf("%d",&b);
	printf("%d is the lcm of %d and %d\n\n",lcm(a,b),a,b);
	getchar();
	return(0);
}

/******************* FUNCTION *****************************/

int lcm(int a,int b)
{
	int i,g,pr,z,q,dummy,lc = 0;

/************************************************************************/
	
/********* Determining weather a is a prime or not **************/
	
	
	for(i = 2 ;i < a;i++)      /* The loop */
	{
		pr = (a % i);

		if(pr == 0)
		{	
			dummy=14296;
			break;
		}	
	}
	
	if(dummy != 14296)
	{
		lc = a * b;
	}

dummy = 0;
	
/********* Determining weather a is a prime or not **************/


	for(i = 2 ;i < b;i++)      /* The loop */
	{
		pr = (b % i);

		if(pr == 0)
		{	
			dummy=14296;
			break;
		}	
	}
	
	if(dummy != 14296)
	{
		lc = a * b;
	}
/************************************************************************/
	if((a % b) == 0)
	{
		lc = b/a;
	}
	if((b % a) == 0)
	{
		lc = a/b;
	}
/************************************************************************/
	
	if(b>a)
	{
		g = b;
	}
	else
	{
		g = a;
	}
		
	for(z=1;z <= g;z++)
	{
		if(((b % z) == 0) && ((a % z) == 0))
		{
			lc = (b/z) * (a/z);
		}
	}
/********************************************************************/
		return(lc);
}

This is a lcm finding program.
please tell me if there are any bugs in this program and tell me how u liked my idea.

>>Examine this program? Tell me its bugs

Well, all you have to do is run it several times and you will find out the bugs.

Also asked, and unanswered, here

commented: hehe....nice find... :) +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.