Question: Consider the following recursive function: Line 1 . void myfun ( string word ) Line 2 . { Line 3 . if ( word .

Consider the following recursive function:
Line 1. void myfun(string word)
Line 2.{
Line 3. if (word.length()==0){ return; }
Line 4. myfun(word.substr(1, word.length()));
Line 5. cout << word[0];
Line 6.}
What changes about this function if lines 4 and 5 are swapped?
Question 3 options:
nothing
creates infinite recursion
prints the characters of the string in both forward and reverse order
reverses the order in which the characters of the string are printed

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 Programming Questions!