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
What is the concatenation operator?
The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.
What is difference between array and pointer in c?
Can math operations be performed on a void pointer?
Can you write the function prototype, definition and mention the other requirements.
Can a local variable be volatile in c?
What is the difference between mpi and openmp?
The file stdio.h, what does it contain?
Which header file should you include if you are to develop a function which can accept variable number of arguments?
What are the types of pointers in c?
what value is returned to operating system after program execution?
What is the use of a semicolon (;) at the end of every program statement?
What is the difference between test design and test case design?
Explain the ternary tree?
What is the total generic pointer type?