C++ Exercises: Concat two given string of length atleast 1, after removing their first character
C++ Basic Algorithm: Exercise-64 with Solution
Write a C++ program to concat two given string of length atleast 1, after removing their first character.
Sample Solution:
C++ Code :
#include <iostream>
using namespace std;
string test(string s1, string s2)
{
return s1.substr(1) + s2.substr(1);
}
int main()
{
cout << test("Hello", "Hi") << endl;
cout << test("JS", "Python") << endl;
return 0;
}
Sample Output:
elloi Sython
Pictorial Presentation:
Flowchart:
C++ Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a C++ program to create a new string from two given string one is shorter and another is longer. The format of the new string will be long string + short string + long string.
Next: Write a C++ program to move the first two characters to the end of a given string of length at least two.
What is the difficulty level of this exercise?