Write a recursive function takes a word string as input argument and reverse the word. Print out the results of recursive calls. Also write a main program accepts input from the user and then call the recursive function. Example: Enter a word: hello h eh leh lleh olleh
IN C++ language
void reverse(int,string) { string str; int len = strlen(str); char c; for(i=1;i<len:i++) { for(j=1;j<i;j++) { c=getchar(str,len-j); printf("%c",c); } } } it may require som modificatons but the logic will be the same as i havnt used c for long time.
@samay That's in C, and it's also not recursive :( try one of these, recursive but I suck at C++ (it also does it a little differently from your example): http://ideone.com/cnH7r Using the C++ library function, best way to do it, but I doubt it's recursive http://ideone.com/ewIsg#li_ewIsg
Join our real-time social learning platform and learn together with your friends!