Question: For C++: Use a function that translates the following sentence into a C++ statement or statements: If you take any whole number and repeatedly multiply

For C++:

Use a function that translates the following sentence into a C++ statement or statements:

"If you take any whole number and repeatedly multiply it by 3, and add 1 if it is odd or divide it by 2 if it is even, you will eventually reach the number 1."

The function's parameter is "any whole number" and returns the number of times the loop iterates.

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!