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
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
a c code by using memory allocation for add ,multiply of sprase matrixes
how do you execute a c program in unix.
Hai what is the different types of versions and their differences
What is table lookup in c?
How can you increase the size of a dynamically allocated array?
Explain can you assign a different address to an array tag?
What does 3 periods mean in texting?
What are the usage of pointer in c?
what is the height of tree if leaf node is at level 3. please explain
How can you restore a redirected standard stream?
What does the && operator do in a program code?
What is dynamic memory allocation?
What are register variables in c?
What is int main () in c?