Q:

Write a C++ program to insert a given string into middle of the another given string of length 4

0

Write a C++ program to insert a given string into middle of the another given string of length 4

Sample Output:

[[Hello]]
((Hi))

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>

using namespace std;

string test(string s1, string word)
         {
            return s1.substr(0, 2) + word + s1.substr(2);
         }         
       
int main() 
 {
  cout << test("[[]]","Hello") << endl;  
  cout << test("(())", "Hi") << endl;  
  return 0;    
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now