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 / shivaraj

main()
{
char str[10];
cin>>str;
int len=strlen(str);
reverse(len);
cout<<"Reversed string is: "<<str;
}

void reverse(int len)
{
static int i=0;
str[i]=str[len-1]; //put the char in last pos to first pos
for(j=len-1;j>i;j--)
str[j]=str[j-1]; //shift to right
i++;

if(i==len)
return;

reverse(len);
}

Is This Answer Correct ?    5 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are header files and what are its uses in C programming?

1157


How can my program discover the complete pathname to the executable from which it was invoked?

1045


What does dm mean sexually?

1271


What is union in c?

1075


using for loop sum 2 number of any 4 digit number in c language

2280


What are formal parameters?

1075


What are the similarities between c and c++?

1024


Explain the priority queues?

1047


What is dynamic variable in c?

998


Explain about C function prototype?

1037


How do you define a string?

1063


A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?

2278


What math functions are available for integers? For floating point?

1094


Is there anything like an ifdef for typedefs?

1108


#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??

1920