Well first off - you should divide the inputted number by 2 and check to see that it's even. If there's a remainder then you know it's an odd number. This will also guarantee it's an integer since there will be no precision. Then make it another error check on it's own. You should display error messages for the error they are for.
second - In your second loop, don't inc by 2, do it by one and just divide by 2. If there's a remainder then don't add the number to sum. Once you're out of you second loop, add sum to my num and display them.
|