Question: Ask the user about the initial integer input for both programs. 1. Make a function called half() that takes an integer argument. The function must

Ask the user about the initial integer input for both programs.

1. Make a function called half() that takes an integer argument. The function must print the number it received to the screen, then the program should divide that number by two to make a new number. If the new number is greater than zero, the function then calls itself (the function half()) passing it the new number as its argument. If the number is zero or less, then the function exits. (This technique is called recursion.)

Call the function half() with an argument of 100, then the screen output should be 100 50 25 ... ... 1

2. Write a program that does exactly the same as in the Program 1. But this time use the technique of repetition. Choose a looping that you find the most appropriate among while, for, do...while. You don't need to create a function in this program.

Compile and execute the program making sure that all syntax and logic errors are removed. Name the CPP file LastNameFirstInitial.cpp. For example, I would name my files LeeD1.cpp and LeeD2.cpp. Upload two files for this assignment. Explain your program appropriately using comments (/* */, //) inside the CPP file.

This is C++

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!