Even or Odd (practice problem)

This is a discussion on Even or Odd (practice problem) within the C Programming forums, part of the General Programming Boards category; Originally Posted by homer_3 Your logic is wrong. If you passed in odd(2), 2!=1 so odd() would call even(2-1), 1!=0 ...

  1. #16
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Quote Originally Posted by homer_3 View Post
    Your logic is wrong. If you passed in odd(2), 2!=1 so odd() would call even(2-1), 1!=0 so even would call odd(1-1), and next thing you know you are dealing with negative numbers, which your code doesn't handle.

    Is this warm up supposed to familiarize you with recursion?
    Aaaaaand another one who didn't read my post...

  2. #17
    Registered User
    Join Date
    Nov 2008
    Posts
    119
    Quote Originally Posted by EVOEx View Post
    Aaaaaand another one who didn't read my post...
    You know what they say about assumptions. I read it. It didn't mention recursion. I was curious if the OP took that route to solving the problem because he was doing an exercise in recursion.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  2. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  3. Words and lines count problem
    By emo in forum C Programming
    Replies: 1
    Last Post: 07-12-2005, 03:36 PM
  4. inStream practice problem not working?
    By correlcj in forum C++ Programming
    Replies: 2
    Last Post: 10-27-2002, 04:58 PM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21