Debugging Activity
Conditional Problems

 


Odd or Even

In the lecture videos for this week I showed you how to determine if a number was odd or even.

Suppose that in a few weeks you forgot how to do that so you went to ChatGPT and asked it to write it for you. I actually did this. And this is what I got back.

 

Right now if you run this, it looks correct

 

But depending on how you look at it, there are two serious flaws.

  1. One is an out and out programming error. See if you can identify the error and how you would fix this program.
  2. The other is a simple issue where "good" programmers wouldn't (and shouldn't) write this code this way. See if you can identify the "bad style" issue that is present in this code.

 

You can watch the appropriate code-walkthrough video to see how I would answer these questions.