The program to reverse every word in a sentence using recursion is discussed here. Input the sentence from the user and call the function to reverse every word in the sentence. Each word in the sentence is identified and they are reversed and printed. The end of the word is identified by a ” “. If this space is identified in the input, the characters up to that space are reversed and printed. The same procedure is followed until the entire sentence is scanned.
For example,
Input: Program to reverse a sentence using recursion
Output: margorP ot esrever ecnetnes gnisu noisrucer
@@coding::1@@
Time complexity: O(n)