How to reverse a string using a recursive function, with
swapping?
Answer Posted / nitin
#include<stdio.h>
#include<conio.h>
#include<string.h>
char * reverse (char *);
void main()
{
char p[90],*k;
gets(p);
clrscr();
k=reverse(p);
puts(k);
getch();
}
char * reverse(char *p)
{
char *k="";
if (*p==NULL )
{
return("");
}
else
{
k=reverse(p+1);
}
k[strlen(k)]=*p ;
k[strlen(k)+1]=NULL;
return k;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are the general description for loop statement and available loop types in c?
How do I convert a string to all upper or lower case?
What is the best way to store flag values in a program?
How do you do dynamic memory allocation in C applications?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
What is the -> in c?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
Explain what is the purpose of "extern" keyword in a function declaration?
Tell us two differences between new () and malloc ()?
How does selection sort work in c?
Explain #pragma statements.
What does node * mean?
What is the newline escape sequence?
What is string function c?
Is malloc memset faster than calloc?