Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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)
B)
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 inputStep 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