Question: Can you help write this code in c++ Create a function that takes any integer and cuts it in half, storing and returning the result

Can you help write this code in c++  Can you help write this code in c++ Create a function

Create a function that takes any integer and cuts it in half, storing and returning the result using a static int. Call this function from within a loop and stop 'halving' when it can no longer be 'halved'. Print each iteration; displaying the total 'halving* steps that occur. Specifications: the program will print your info and a message that describes its mission. (Must use the function you created in Lab 04). Program will ask the user for an integer, N, which is not equal to zero (Exit if it's 0). the program then calls/invokes a function which halves N. This function call occurs in a loop, halving the value of N that was passed until it can no longer be halved (i.e. equals Program will repeat until a user inputs 0 to exit. Your function should take an integer data type and return one. This means that halving is always an integer, for example '25/2' should return 12 and not 12.5. static int will exist in your function body: sec the example in the pre-lab. To receive full marks with a working solution: Ensure you did not repeat bad-practice mistakes based on feedback from previous lab. Use the program header function you created in Lab04. Must use a function to halve N. Program must use the static modifier within the function body

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!