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
Why is c so popular?
Explain bit masking in c?
Can variables be declared anywhere in c?
Can a pointer be static?
What is main () in c?
Explain how do you print an address?
What is static and volatile in c?
why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above
Find MAXIMUM of three distinct integers using a single C statement
What are the primitive data types in c?
How the c program is executed?
What is %g in c?
What does c mean in standard form?
What are data structures in c and how to use them?
Explain heap and queue.