Question: Write code to allow the user to enter a positive integer. Compute and display the sum of the odd integers from 1 to the entered

Write code to allow the user to enter a positive integer. Compute and display the sum of the odd integers from 1 to the entered integer, including the entered integer if it is odd.
For example, if the user enters 11, then 1+3+5+7+9+11 is computed.
If the user enters 12, then 1+3+5+7+9+11 is computed.
For example:
Input Result
11
Enter an integer: 11
Sum of the odds is 36
12
Enter an integer: 12
Sum of the odds is 36

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!