What is the output of the following program?
#include #include #include using namespace std; void function(string str, int pos); int main(int argc, char** argv) { string names = "Adam and Eve"; function(names, 0); return 0; } void function (string str, int pos) { if (pos < str.length()) { function(str, pos+1); cout << str[pos]; } }
The program uses recursion to traverse the string and outputs the string from the end in a reverse order, the input of the program is "Adam and Eve" and the output is "evE dna madA".