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
Tell me with an example the self-referential structure?
What does typedef struct mean?
What is the difference between āgā and āgā in C?
Which header file is essential for using strcmp function?
What are the 5 organizational structures?
What is 1f in c?
Tell me the use of bit field in c language?
How can a process change an environment variable in its caller?
Explain what is the benefit of using #define to declare a constant?
Do you know the use of fflush() function?
Why are algorithms important in c program?
write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)
Explain what is gets() function?
Is there any data type in c with variable size?
How can I write a function that takes a format string and a variable number of arguments?