Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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++ image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2 8 .

Answered: 1 week ago