How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / prakash
#include <stdio.h>
void reverse(char *str)
{
if (*str == '\0')
return;
reverse(str+1);
printf("%c", *str);
}
int main()
{
char str[50];
printf("Enter the string: ");
scanf("%s", str);
printf("Reversed string: ");
reverse(str);
printf("\n");
return 1;
}
| Is This Answer Correct ? | 23 Yes | 24 No |
Post New Answer View All Answers
Explain what are its uses in c programming?
What is difference between array and structure 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
what is the basis for selection of arrays or pointers as data structure in a program
What is an lvalue?
What is #include cctype?
Write a program to reverse a linked list in c.
What are the restrictions of a modulus operator?
how to construct a simulator keeping the logical boolean gates in c
Is it better to use malloc() or calloc()?
What are variables and it what way is it different from constants?
What is wrong with this program statement? void = 10;
What are volatile variables in c?
What does a function declared as pascal do differently?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon