Program to Replace a Substring in a String | FACE Prep

Program to Replace a Substring in a String | FACE Prep

The program to replace a substring in a string is discussed here. The steps for replacing a substring with another string are given below.


Program to Replace a Substring in a String


Input:nnhi hellonstring to be replaced: hinstring to be replaced with: heynnoutput: hey hellon


Algorithm to Replace a Substring in a String

  • Input the full string (s1).
  • Input the substring from the full string (s2).
  • Input the string to be replaced with the substring (s3).
  • Find the substring from the full string and replace the new substring with the old substring (Find s2 from s1 and replace s1 by s3).



Program to Replace a Substring in a String


Program to Replace a Substring in a String

Asked in recruitment drive of Wipro.n


@@coding::1@@


Program to Replace a Substring in a String


Recommended Programs









Program to Replace a Substring in a String