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
What are local variables c?
Is c procedural or functional?
What is file in c preprocessor?
What is c programming structure?
Why do we use c for the speed of light?
What is the code in while loop that returns the output of given code?
i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me
What are the parts of c program?
I have seen function declarations that look like this
What is a scope resolution operator in c?
Function calling procedures? and their differences? Why should one go for Call by Reference?
What is linear search?
What is property type c?
What is #include called?
What is pointer in c?