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
What is the best way of making my program efficient?
What is the correct code to have following output in c using nested for loop?
In which layer of the network datastructure format change is done
How would you rename a function in C?
What is difference between function overloading and operator overloading?
What is static identifier?
What is conio h in c?
Define macros.
What is the difference between text and binary i/o?
Process by which one bit pattern in to another by bit wise operation is?
Why main function is special give two reasons?
What is exit() function?
Why c is called procedure oriented language?
Explain can you assign a different address to an array tag?
Write a program to use switch statement.