[Solved]-Trace Following Code Complete Trace Table First Outer Loop Iteration Passed Function Finds Q37255237

Trace the following code and complete the trace table after the first outer loop iteration is passed in the function findString where findString() determines if a string exists inside another string. The first argument to the function should be the character string that is to be searched and the second argument is the string you are interested in finding. If the function finds the specified string, have it return the location in the source string where the string was found. If the function does not find the string, have it return -1. So, for example, the call index – findString (“a chatterbox”, “hat”); searches the string “a chatterbox” for the string “hat” . Because “hat” does exist inside the source string, the function returns 3 to indicate the starting posi tion inside the source string where “hat” was found:- (30pt) #include« stdio. h> void main() int findString(const char Si[], const char S2[]);//rototype int index; index- findString(“a chatterbox”, “hat”); printf( “hat appears in chatterbox at pos %i”, index) getch(); int findString(const char S1[], const char S2[]) int i-0,j,k,startPos-0; while (S1[i] !- ‘e)//outer while loop startPos – i; k İ:// keep a copy of S1 index j 8;//index of S2 while (S2]S1[k] && S1[k] ‘&&S2[j] e*)//inner while loop if (S2[j] #- ”)// Reached to the end, so this means it is found as // substring of S1 return(startPos); i++;//increment ǐ which is S1 inde, before entering the inner while return(-1); S1 S2 0 False hat a chatterbox Show transcribed image text Trace the following code and complete the trace table after the first outer loop iteration is passed in the function findString where findString() determines if a string exists inside another string. The first argument to the function should be the character string that is to be searched and the second argument is the string you are interested in finding. If the function finds the specified string, have it return the location in the source string where the string was found. If the function does not find the string, have it return -1. So, for example, the call index – findString (“a chatterbox”, “hat”); searches the string “a chatterbox” for the string “hat” . Because “hat” does exist inside the source string, the function returns 3 to indicate the starting posi tion inside the source string where “hat” was found:- (30pt) #include« stdio. h> void main() int findString(const char Si[], const char S2[]);//rototype int index; index- findString(“a chatterbox”, “hat”); printf( “hat appears in chatterbox at pos %i”, index) getch(); int findString(const char S1[], const char S2[]) int i-0,j,k,startPos-0; while (S1[i] !- ‘e)//outer while loop startPos – i; k İ:// keep a copy of S1 index j 8;//index of S2 while (S2]S1[k] && S1[k] ‘&&S2[j] e*)//inner while loop if (S2[j] #- ”)// Reached to the end, so this means it is found as // substring of S1 return(startPos); i++;//increment ǐ which is S1 inde, before entering the inner while return(-1); S1 S2 0 False hat a chatterbox
Expert Answer
Answer to Trace the following code and complete the trace table after the first outer loop iteration is passed in the function fin… . . .
OR

