Emily Clark

Greenhorn
+ Follow
since Mar 02, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Emily Clark

By setting the seven integers in the separate while loop it created the correct output - I see why the results were originally odd by using the same counter. Odd and Even should have been two separate counters and parameters from the beginning.

Thanks you guys!
8 years ago
Thank you, good to be here.

Would you recommend having this second segment as a separate instance from the first? So, the first whileLoop offers the odd counting, then this is an entirely separate instance?
8 years ago
For my intro programming class, this assignment requests the use of a while loop. The objective is to input 2 integers (firstNum, secondNum), verify the first value is smaller than the second, and then output the odd integers between the two input values
(inlcuding the input if it is odd). After outputting those, it wants us to output the sum of even integers between (and including if input was even) the inputs.

The formatting guide that came with our assignment uses test variables 5 and 21, so I have been testing my program with the same values. The odd numbers populate perfectly. The issue I'm running into is that when it's time to add the sum of the integers the value is not correct. If I enter even values 6 & 20 I get a sum of 91, and if I enter 5 and 21 I get a value of 118, neither of which are the correct value (104, which they should both be.) This is what I have for my program right now. I'm really not sure where to go/what to do to rectify this issue.



Edit: Editing to mention the Sqr variables above are for a second part of the program I have not written yet, but are irrelevant to this loop. (it is in a second whileloop).
8 years ago