Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create this C++ program that uses a function to half N, and use a static modifier within the function body. E.1. Question 1: Integer halving
Create this C++ program that uses a function to half N, and use a static modifier within the function body.
E.1. Question 1: Integer halving function using the static modifier (40 Marks) Requirement: 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 ving steps that occur. Specifications: 1. The program will print your info and a message that describes its mission. (Must use the function you created in Lab04 2. Program will ask the user for an integer, N, which is not equal to zero (Exit if it's 00 3. 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 1) 4. Program will repeat until a user inputs 0 to exit. Implementation tips: 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: see 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 Labo4 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
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