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
Explain the advantages and disadvantages of macros.
Why is c used in embedded systems?
what are the different storage classes in c?
What is far pointer in c?
Why is c called c?
What are data structures in c and how to use them?
What is class and object in c?
Explain what is wrong with this program statement? Void = 10;
What is the best organizational structure?
How many data structures are there in c?
Write a c program to build a heap method using Pointer to function and pointer to structure ?
Do pointers need to be initialized?
Explain what will the preprocessor do for a program?
How can I do peek and poke in c?
What functions are used for dynamic memory allocation in c language?