Print reverse of a String using recursion

String is a group of characters means a linear sequence of characters,(a,b,c,d),word.By using recusive function we can reverse a string from begin to end.A recursive is a function that calls itself is termed as a recursive function and the process involved in doing this is called recursion.



/* A preprocessor directive that contains standard input and output operations*/



print_reverse(char *S) /*print_reverse is a recursive function which takes variable S*/

/*S is a pointer which points to a character*/


if(*S!=NULL) /*check whether the string pointer value is not equal to NULL*/


/*print_reverse function calls itself after incrementing the pointer by 1*/


/*putchar writes a single character to the standard output stream, that is, the value of S is decremented

         And that string pointer is written*/



/*Main Function*/

void main()


/*A character array S whose size is 80 is declared*/

char S[80];

printf("\n Enter a String:\n");

/*gets function declared in stdio.h header file reads a line from standard input and stores it in S*/


printf("\n The reverse string:\n");

/*print_reverse function is called with the argument S*/




Reverse String