Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Compute the sum of all odd integers from 1 inclusive up to (and possibly including) top. The value for top may or may not be
Compute the sum of all odd integers from 1 inclusive up to (and possibly including) top. The value for top may or may not be included in the final sum depending on whether top is an odd or even integer. (1+3+5+7+...)
- Prompt the user to supply a value for top.
- Determine if value is even or odd. If even, subtract one to make it odd. If value is odd, leave as is
- Use a looping construct to generate the sum.
- Display the result sum to the Run I/O window.
EXAMPLE:
Enter top value: 12
Sum: 36
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started