This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

good code bad answer

my code is 110% correct; eg no errors and runs properly. see.

int _val;

int myfunc2(int val)
{
  _val = val;
   return _val;
};

int Bar(int val)
{
  return _val + val + 1;
};

void myfunc1(int val)
{
  _val += Bar(val);
};

etc
etc
etc

it doesnt give me the right answer sometime.

HEEEEEEEELLLLLLLPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP

Parents
  • "my code is 110% correct"

    Not really - for a start, user code should not define identifiers with leading underscores!

    "no errors"

    If is entirely possible - and all too common - to write some very bad code that compiles with zero errors.

    See http://www.ioccc.org/ for some prime examples!

    "runs properly ... doesnt give me the right answer sometime"

    So it's not running properly, then - is it?!

    "HEEEEEEEELLLLLLLPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP"

    How?

    You've just shown a few function definitions; you haven't shown how you combine all this into a real program.

    You haven't explained what you think should be the "right" answers.

    You haven't explained what answers you get - and why you think ther are "wrong".

Reply
  • "my code is 110% correct"

    Not really - for a start, user code should not define identifiers with leading underscores!

    "no errors"

    If is entirely possible - and all too common - to write some very bad code that compiles with zero errors.

    See http://www.ioccc.org/ for some prime examples!

    "runs properly ... doesnt give me the right answer sometime"

    So it's not running properly, then - is it?!

    "HEEEEEEEELLLLLLLPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP"

    How?

    You've just shown a few function definitions; you haven't shown how you combine all this into a real program.

    You haven't explained what you think should be the "right" answers.

    You haven't explained what answers you get - and why you think ther are "wrong".

Children
No data