Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to reverse a string using a recursive function, without
swapping or using an extra memory?

Answer Posted / vishnu

Try this ...

#include <stdio.h>
#include <stdlib.h>

int Rev (char *s, char *b)
{
int i ;
char c ;

if (*s == '\0')
{
return 0 ;
}
c = *s ;
i = Rev (s + 1, b) ;
b[i] = c ;
return i+1 ;
}

int main ()
{
int end ;
char str[] = "Billie jean is not my lover - MJ" ;

end = Rev (str, str) ;
str[end] = '\0' ;
printf ("Now [%s]\n", str) ;
exit (0) ;
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to write optimum code to divide a 50 digit number with a 25 digit number??

3267


Why do we use header files in c?

1067


What are the advantages of Macro over function?

2002


Explain do array subscripts always start with zero?

1223


which type of aspect you want from the student.

2162


int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer

1034


Explain what is page thrashing?

1090


What is difference between main and void main?

1203


Can we declare variable anywhere in c?

966


What header files do I need in order to define the standard library functions I use?

1050


What is mean by data types in c?

1027


If the size of int data type is two bytes, what is the range of signed int data type?

1018


Can you please explain the difference between syntax vs logical error?

1181


What is variables in c?

1050


How do I convert a string to all upper or lower case?

1105