How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / vinay tiwari
void reverse(char *,int b);
void main()
{
char a[26];
int len;
clrscr();
printf("enter string ");
gets(a);
len=strlen(a);
reverse(a,len);
getch();
}
void reverse(char * a,int len)
{
if(len==0)
printf("%c",a[len]);
else
{
printf("%c",a[len]);
reverse(a,len-1);
}
}
| Is This Answer Correct ? | 177 Yes | 62 No |
Post New Answer View All Answers
Which built-in library function can be used to match a patter from the string?
Why isnt there a numbered, multi-level break statement to break out
What extern c means?
What is ctrl c called?
What are extern variables in c?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
How do I use strcmp?
Which is better pointer or array?
What is sizeof c?
What is the benefit of using #define to declare a constant?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What are the functions to open and close file in c language?
What is indirection in c?
What will be your course of action for a push operation?
What are volatile variables in c?