How to reverse a string using a recursive function, without
swapping or using an extra memory?

Answer Posted / siva kumar

void reverse_string(char *string) {

static int start_index = 0;
static int end_index = strlen(string) - 1;

if (start_index <= end_index) {
char temp = string[end_index];
string[end_index] = string[start_index];
string[start_index] = temp;
start_index++;
end_index--;
reverse_string(string);
}
}

Is This Answer Correct ?    11 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is chain pointer in c?

589


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

1725


How does normalization of huge pointer works?

613


How can you determine the size of an allocated portion of memory?

732


What is structure padding and packing in c?

602






What is this infamous null pointer, anyway?

596


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

655


Explain what standard functions are available to manipulate strings?

597


Is Exception handling possible in c language?

1564


What is indirection? How many levels of pointers can you have?

647


What are the disadvantages of a shell structure?

680


What is the symbol indicated the c-preprocessor?

685


#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }

755


Sir i need notes for structure,functions,pointers in c language can you help me please

1933


What is call by value in c?

544