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
Distinguish between actual and formal arguments.
What is array of structure in c programming?
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
Difference between MAC vs. IP Addressing
Is null equal to 0 in sql?
Difference between malloc() and calloc() function?
what is the basis for selection of arrays or pointers as data structure in a program
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
Array is an lvalue or not?
What is #include cctype?
a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler
What is meant by gets in c?
How can a program be made to print the line number where an error occurs?
What are the types of assignment statements?