Thursday, August 12, 2010


Recursion is the process of calling the same function itself again and again until some condition is specified. This process is used for repetitive computation in which each action is satisfied in terms of a previous result.The main program displays the prompt and then calls the reverse ( ) function. Then the recursive reverse ( ) function reads a single character until end of line (\n) is encountered. Each function call reads a new character and pushed it into the stack. Once the end-of-line is encountered, then the successive characters are popped from the stack and displayed on a last-in-first-out basis, thus the characters are displayed in reverse order.

No comments: