GATEverse
← GATE CSE 2013

Q50

MCQ2 marks, −0.67

The procedure given below is required to find and replace certain characters inside an input character string supplied in array AA. The characters to be replaced are supplied in array oldcoldc, while their respective replacement characters are supplied in array newcnewc. Array AA has a fixed length of five characters, while arrays oldcoldc and newcnewc contain three characters each. However, the procedure is flawed. void find_and_replace (char *A, char *oldc, char *newc) { for (int i=0; i<5; i++) for (int j=0; j<3; j++) if (A[i] == oldc[j]) A[i] = newc[j]; } The procedure is tested with the following four test cases. The tester now tests the program on all input strings of length five consisting of characters ‘aa’, ‘bb’, ‘cc’, ‘dd’ and ‘ee’ with duplicates allowed. If the tester carries out this testing with the four test cases given above, how many test cases will be able to capture the flaw? Only one Only two Only three All four

Sign in to save attempts.

Loading…