How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / right
char* reverseStringR(char* string){
if(string[0] && !string[1])
return string;
char first = string[0];
reverseStringR(string+1);
size_t length_rest = strlen(string+1);
memmove(string, string+1, length_rest);
string[length_rest] = first;
return string;
}
| Is This Answer Correct ? | 3 Yes | 4 No |
Post New Answer View All Answers
what is the syallabus of computer science students in group- 1?
Where static variables are stored in memory in c?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
Explain the use of #pragma exit?
a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);
What is the code in while loop that returns the output of given code?
Tell us the use of fflush() function in c language?
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.
Can we declare variables anywhere in c?
What is #error and use of it?
Write a program to reverse a given number in c language?
What are linker error?
ATM machine and railway reservation class/object diagram
How can you find out how much memory is available?
Tell me what are bitwise shift operators?