C++ program to concatenate strings in reverse order


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

Updated on: 03-Mar-2022

432 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements