C Program to reverse string using recursion

Simple C program to reverse string using recursion: If string is "C Basic Examples" then program will print "selpmaxE cisaB C".
/* C program to reverse string */
#include<stdio.h>
void PrintReverse(char *str)
{
 if(*str=='\0')//null character
 return ;
 PrintReverse(str+1);
 printf("%c",*str);
}
int main()
{
 char str[20]="reverse";
 PrintReverse(str);
 return 0;
}
/* End of the program */


Popular posts from this blog