Futurex interview question

Reverse a string without using a loop in C.

Interview Answers

Anonymous

20 Oct 2016

The simplest way to reverse a string or any other container without an explicit loop in C++ is to use reverse iterators: string input; cin >> input; // the pair of iterators rbegin/rend represent a reversed string string output ( input.rbegin ( ), input.rend ( ) ) ; cout << output << endl;

Anonymous

23 Sept 2014

The desired method was to use recursion to build a stack and then undo it to print the string.