Search This Blog

Translate This Page

Wednesday, 27 February 2013

Print Reverse of a string using Recursion


Print reverse of a  string using recursion:


# include <stdio.h>

/* Function to print reverse of the passed string */
void reverse(char *str)
{
   if(*str)
   {
       reverse(str+1);
       printf("%c", *str);
   }
}

int main() 
{
   char a[] = "Tech Stuff for Interview";
   reverse(a);
   return 0;
}



No comments:

Post a Comment

Latest Current Visitor

World Clock Time, for View Click on Country