










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











str[0] 1000 str[1] 1001 str[2] 1002 str[3] 1003 str[4] 1004 str[5] 1005
i=0; while(str[i] != '\0) { putchar(str[i]); i++; }*
© Oxford University Press 2012. All rights reserved.
Step1: [Initialize] SET I= Step 2: Repeat Step 3 while STR[I] != ‘\0’ Step 3: IF STR[1] > ‘a’ AND STR[I] < ‘z’ SET Upperstr[I] = STR[I] - 32 ELSE SET Upperstr[I] = STR[I] [END OF IF] [END OF LOOP] Step 4: SET Upperstr[I] = ‘\0’ Step 5: EXIT
APPENDING
© Oxford University Press 2012. All rights reserved. REVERSING A STRING
The insertion operation inserts a string S in the main text, T at the kth position. The general syntax of this operation is: INSERT(text, position, string). For ex, INSERT(“XYZXYZ”, 3, “AAA”) = “XYZAAAXYZ” Algorithm to insert a string in the main text Step 1: [INITIALIZE] SET I=0, J=0 and K= Step 2: Repeat steps 3 to 4 while text[I] != ‘0’ Step 3: IF I = pos, then Repeat while str[K] != ‘\0’ new_str[j] = str[k] SET J=J+ SET K = K+ [END OF INNER LOOP] ELSE new_str[[J] = text[I] SET J = J+ Step 4: SET I = I+ [END OF OUTER LOOP] Step 5: SET new_str[J] = ‘\0’ Step 6: EXIT
Name[0] Name[1] Name[2] Name[3] Name[4]