Question: Q1 (Language C++ / Try to run it in CodeRunner first) A) B) Write a program that asks for the end value (positive integer), and

Q1 (Language C++ / Try to run it in CodeRunner first)

A)Q1 (Language C++ / Try to run it in CodeRunner first) A)

B) B) Write a program that asks for the end value (positive integer),

Write a program that asks for the end value (positive integer), and computes the sum of the odd numbers from 0 to the value entered, inclusive. If the user enters a negative value as input then print Invalid input. For example: Test Input Result // test case example 1 20 Enter a positive number: Sum: 100 // test case - example 2 -1 Enter a positive number: Invalid input. Write a program that takes a positive integer n, and prints the sequence as explained below, If n is a multiple of 3, then the next value in the sequence is n-1. Otherwise, the next value in the sequence is n/2 (integer division). The sequence continues until n is positive. Please note that the sequence should not contain any negative values or 0. Make sure your program validates the user input. For invalid inputs, print "Invalid input." For example: Test Input Result // test case example 1 13 Enter a positive number: 13 6 5 2 1 // test case - example 2 -10 Enter a positive number: Invalid input

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!