Question: Write a complete program that does the following: accepts a positive integer from a user if the integer is negative , the program should print

Write a complete program that does the following:

accepts a positive integer from a user

if the integer is negative, the program should print "The number entered was negative."

if the integer is 0, the program should print "The number entered was zero."

if the integer is positive, the program should

use a loop to calculate the sum of all the odd integers from zero to the integer the user entered and

print "The sum from 0 to " followed by the integer entered, followed by " is " and followed by the calculated sum. The following could be possible outputs from your program:

The sum from all the odd integers from 0 to 5 is 9

or

The sum from all the odd integers from 0 to 8 is 16

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 Databases Questions!