C++ program to concatenate strings in reverse order

C++Server Side ProgrammingProgramming

Suppose we have two strings S and T. Both are in lowercase letters. Concatenate T and S in this order to generate the final string.

So, if the input is like S = "ramming"; T = "prog", then the output will be "programming"

Steps

To solve this, we will follow these steps −

res := T concatenate S
return res

Example

Let us see the following implementation to get better understanding −

#include <bits/stdc++.h>
using namespace std;

string solve(string S, string T){
   string res = T + S;
   return res;
}
int main(){
   string S = "ramming";
   string T = "prog";
   cout << solve(S, T) << endl;
}

Input

"ramming", "prog"

Output

programming
raja
Updated on 03-Mar-2022 07:52:29

Advertisements