/*
Author: Yana
Module: revline.c
What:
-----
The program prints a line of characters backwards.
Input: A line of characters.
Output: The reversed line.
How:
----
Algorithm: recursive solution.
*/
#include <stdio.h >
void revline(void);       /* function prototype */
int main (){
-
printf( "Please enter a line of characters: " );
- revline();
- printf( "\n" );
- return 0;
}
/* function definition
revline: Reads a character line and prints it backwards
Parameters: none.
Return Value: none.
Algorithm: Recursive - Read a character, reverse rest of input
line recursively, and finally print the character. */
void revline(void)
{-
char c;       /* Next character read. */
- if ((c = getchar()) != '\n'){
- revline();
- printf( "%c", c );
- }
}