Here is a recursive function. Write an iterative version of it. Hint: Be sure you get the number of copies of "Hip" right.
What will be an ideal response?
```
void rec_cheers(int n)
{ using namespace std; if(1==n) cout << "Hurray!"
<< endl; else { cout << "Hip, "; rec_cheers(n-
1);
}
}
```
```
void iter_cheers(int n){for(int i = 0;i < n-
1;i++)//this is the tricky part!
cout << "Hip, "; cout << "Hurray!" << endl;}
```
You might also like to view...
Jessie, the PC technician, replaced a power supply in an older ATC computer. Jessie notices that the ATX motherboard connector has more pins than the main power connector coming from the power supply. What should Jessie do?
A) Obtain a compatible power supply. B) Replace the motherboard. C) Obtain a 20- to 24-pin power adapter. D) Nothing. The newer ATX power supply is compatible with both 20- and 24-pin connectors.
Which of the following statements is false?
a. Object-oriented programming is today's key programming methodology. b. Java has become the language of choice for implementing Internet-based applications and software for devices that communicate over a network. c. Software commands computer hardware to perform tasks. d. In use today are more than a trillion general-purpose computers and trillions more Java-enabled cellphones, smartphones and other handheld devices.