Concatenate suffixes of a String | C ++ implementation of the approach ; Function to print the expansion of the string ; Take sub - string from i to n - 1 ; Print the sub - string ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void printExpansion ( string str ) { string suff = " " ; for ( int i = str . length ( ) - 1 ; i >= 0 ; i -- ) { suff = suff + str [ i ] ; cout << suff ; } } int main ( ) { string str = " geeks " ; printExpansion ( str ) ; return 0 ; }