By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,171 Members | 1,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,171 IT Pros & Developers. It's quick & easy.

plz help!

momotaro
100+
P: 357
am trying to get the LCD of tree num but i have problems with my code cause it did not treat the casees!!
plz help!
Expand|Select|Wrap|Line Numbers
  1. /* This program compute the gcd of two numbers*/
  2. #include <stdio.h>
  3. main()
  4. {
  5.      int a, b, i, c, min;
  6.         printf("Enter your tree numbers: ");
  7.         scanf("%d %d %d", &a, &b, &c);
  8.         min=a;
  9.         if (b<min)
  10.             min=b;
  11.         if (c<min)
  12.             min=c;
  13.         for (i=2; i<=min; ++i)
  14.             if (a%i==0 && b%i==0 && c%i==0)
  15.                 printf("your lcd is %d", i);
  16.             else
  17.                 printf("one");
  18.     sleep(10000);
  19. }
Nov 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: 94
why not use a recursive function?
Nov 8 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.