Gives the output cba .Can't say why?
This must have happened when you must have given the input "abc" isnt it ?
The above function is basically an example of a recursive function or basically a function which calls itself. Hence the above prog waits for the user input and keeps on accepting it until the user presses a Return or Enter key on the keyboard. And when the return key is pressed the entered input is printed in reverse order.
One note though, recursive functions if used improperly can cause stack overflow since each time a recursive function is called a new stack is allocated for the function.
getch() returns an int, not a char. And there is an open parenthesis missing in the if condition.
I don't see why two people assume that == is the desired operator between c and getchar(). For one, (c==getchar()) will never return a value equal to '\n'. And of course Deacon J's use of == is nonsensical.
a new stack is allocated
A new stack frame. There's just one stack (in C, anyway), and you normally don't make copies of it.