On 8 Jun 2005 14:26:05 -0000, bharath rajsingh
<[EMAIL PROTECTED]> wrote:
>  
> 
>    
>  hi 2 all 
>  here is a simple program in c .find the error in this program.
>  this is a program 2 find lcm for 2 nos.the concept i have used is 
>  
>  lcm = product of 2 nos./gcd
>  #include<stdio.h>
>  #include<conio.h>
>  main()
>  {
>  long int a,b,x,y;
>  printf("enter 2 nos\n");
>  scanf("%d %d",&a,&b);
>  x=a;
>  y=b;
>  while(a!=b)
>  {
>  if(a>b)
>  a=a-b;
>  else
>  b=b-a;
>  }
>  lcm=(x*y)/a;


The above statement may be going above limits with huge numbers.
Still, values like 250 and 200 and working fine on linux. I dont know
how its on windows. You may need to modify that line or use some kind
of optimisation.

HTH,

-jm

-- 
Jemshad O K                                               http://www.jemshad.com
Home  : +91-495-2415098
Office : +91-484-2427971, 2428918
Mobile: +91-9895662373

"I know Karate, Kung-Fu and 47 other dangerous words"




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/tech4all/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to