Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

include iostream include string using namespae std; int funcl( string strl , str

ID: 3764062 • Letter: I

Question

include iostream include string using namespae std; int funcl( string strl , string str2 ) { return strl.find( str2 + str2 ); string func2( string & strl, int int1 ) { int origLength = str1.length(); for( int i = inti ; i origLength = 2 ; i+= 2 ) { str1 += "a"; } return strl ; } int main { string si , s2 ; s1 = "na banana" ; s2 - "na" ; int index = func1( al , s2 ); cout index endl; OUTPUT 1 int integerl = 2; si = func2( s2, integerl ); cout si s2 integerl endl;OUTPUT 2 return 0; What is the value of str2 + str2 on line 6? What is displayed by the statement on line 23? What is the value of int1 on line 9? What is the value of origLength * 2 on line 11? What is the value assigned to i second time in the for loop? What is the value assigned to s1 on line 26? What is the value displayed by s2 on line 28?

Explanation / Answer

a)
as we passing the string na...
so str2+str2 gives "nana"

-------------------------------------------------------
b)
after comparing string "na banana" with "nana"
it matches at index 5
so it prints 5

---------------------------------------------
c) we declared in main as 2
so int1 has 2

---------------------------------------------------------
d)
as we are passing string s2...so it has length 2
so 2*2 = 4
-------------------------------------------------------------
e)
we are incrementing by 2 after every for loop
so initially i=2
second for loop 2+2 = 4
--------------------------------------------------------
f)
it only loop one time..
so initally "na" after appending one 'a'
s1 contains finally "naa"

-------------------------------------------------------
g) as we are passing as referrence..... so it moifies the original string
so it contains as same as s1
so s2 contains "naa"