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

/*
reverse string between start and end indexes of a string
*/

void reverse( char* str, int start, int end )
{
if( str && ( start < end ) )
{
*( str + start ) ^= *( str + end ) ^= *( str + start )
^= *( str + end ) ;
reverse( str, ++start, --end );
}
}

int main()
{
char sample[] = "My String!";
reverse( str, 0, strlen( sample )-1 )
}

Is This Answer Correct ?    15 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of arrays in c?

1095


What is the difference between printf and scanf )?

1023


#include int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

1677


What is the benefit of using const for declaring constants?

990


What is a union?

989


Why do some versions of toupper act strangely if given an upper-case letter?

1037


Explain what happens if you free a pointer twice?

1016


What are the c keywords?

1146


What is use of pointer?

1011


What is volatile keyword in c?

997


What is a ternary operator in c?

1058


Is c procedural or object oriented?

953


Why main function is special give two reasons?

1483


.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }

1228


Explain what are the different data types in c?

1160