Lab Report 04
Lab Report 04
Analysis:
String INSERTION refers to the process of inserting a substring or a character at a specific position
within an existing string. In programming, many languages offer built-in functions or methods to
facilitate string insertion, but the process generally involves splitting the string, inserting the new
substring, and then combining the parts back together.
Algorithm:
Split the original string into two parts:
• The part before the insertion point.
• The part after the insertion point.
Insert the new substring at the desired position.
Concatenate the parts (including the new substring) to form the final string.
Source Code:
[P.T.O]
Input-Output
01
Problem Statement 02:
Implement String DELETION
Analysis:
String DELETION refers to the process of removing a specific portion (a substring or character)
from a given string. Similar to string insertion, deletion involves identifying a position (or range of
positions) in the string and modifying the string by removing the specified part.
Algorithm:
Identify the portion of the string to be deleted (using position and length or a specific substring).
Remove the specified portion.
Concatenate the remaining parts of the string.
Source Code:
[P.T.O]
Input-Output
01
Problem Statement 03:
Implement String REPLACEMENT
Analysis:
String REPLACEMENT involves replacing part of a string (a substring or character) with another
string or character. String replacement can be used to modify a string by finding and replacing
substrings, either at specific positions or based on the occurrence of a particular pattern.
Algorithm:
Identify the portion of the string (a substring or character) to be replaced.
Replace the identified portion with the new substring.
Return the updated string.
Source Code:
[P.T.O]
Input-Output
01
Problem Statement 04:
Implement String Concatenation
Analysis:
String concatenation is the process of joining two or more strings together to form a new string.
Example:
𝑆𝑡𝑟𝑖𝑛𝑔 01: "𝐻𝑒𝑙𝑙𝑜, "
𝑆𝑡𝑟𝑖𝑛𝑔 02: "𝑤𝑜𝑟𝑙𝑑! "
Result : 𝑆𝑡𝑟𝑖𝑛𝑔 01 + 𝑆𝑡𝑟𝑖𝑛𝑔 02 = "𝐻𝑒𝑙𝑙𝑜, 𝑤𝑜𝑟𝑙𝑑! "
Algorithm:
BEGIN
DECLARE string1 AS "Hello, "
DECLARE string2 AS "world!"
DECLARE result AS string1 + string2
PRINT result
END
Source Code:
[P.T.O]
Input-Output
01