Explore
ProGrad Programs
Placement Prep
TCS Codevita
Live Placement Training
Webinars
About Us

Edit
Reply




Edit

Program to Replace a Substring in a String | FACE Prep

Published on 09 Mar 2020

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


Input:

hi hello
string to be replaced: hi
string to be replaced with: hey

output: hey hello


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


Asked in recruitment drive of Wipro.


C
C++
Java
Python 3

Output
Input- Enter the main String:Notwithstanding Enter the string to be replaced:with Enter the replacing string: under Output- Notunderstanding


Recommended Programs







If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in