16.. What is recursion?.

Added on -2019-09-25

| 6 pages
| 1265 words
| 398 views

Trusted by 2+ million users,
1000+ happy students everyday

Showing pages 1 to 3 of 6 pages

16. What is recursion?a. It's when a function outputs a pointer.b. It's when a function calls itself.c. It's when a function calls another function.d. It's when a function outputs a null value.17. What would the output for this loop be?for(int i=1; i<3; i++) { cout << "The number is: " << i << endl;}a.The number is: 1The number is: 2b.The number is: 1The number is: 2The number is: 3c.The number is: 0The number is:1The number is:2d.The number is:3The number is: 2The number is:118. Look at the following code. (Note the numbers are not the same as in question 17)How many times will the function "numberFunction" call itself from within itself?#include <iostream>using namespace std;void numberFunction(int i) { cout << "The number is: " << i << endl; i++; if(i<10) { numberFunction(i); }}
int main() {int i = 0;numberFunction(i);return 0;}a.0b.9c.1d.1019. Look back at the code in Question 18.How many times is NumberFuncition called in the main program?a.1b.10c.2d.020. Here is some code similar to the code in Question 18. But the value of initial value of i is set to 11 instead of 0.What would be the output of this program?#include <iostream>using namespace std;void numberFunction(int i) { cout << "The number is: " << i << endl; i++; if(i<10) { numberFunction(i); }}
int main() {int i = 11;numberFunction(i);return 0;}a.The number is: 11b.The number is: 12c.The number is: 0d.There would be no output because 11 > 10.21. What does this constructor do?Graph()a.returns the number of nodes in a Graph imageb.Creates an empty Graph objectc.Creates a BasicGraph templated.Creates a svg image22.What does this code do?Graph<NodeType,ArcType> h;a. Creates an empty Graph object named h.b. Creates a default Graph object named h, with 3 nodes and 3 arcs.c. Returns the number of nodes in h.d. Returns a null value if h is empty.23.What is an important difference between the BasicGraph and Graph classes?a. The edge type has been preset to "bubble".b. The vertex type has been preset to "point".c. You do not need to supply the vertex and edge types.d. Trick question, there is no important difference between the two.24.In this bit of codebool isEmpty() const;"bool" indicates that isEmpty ____.

Found this document preview useful?

You are reading a preview
Upload your documents to download
or
Become a Desklib member to get accesss

Students who viewed this