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 is meant by preprocessor in c?
What is your stream meaning?
Why do we use main function?
How can a program be made to print the line number where an error occurs?
How can I open a file so that other programs can update it at the same time?
Write a program to print "hello world" without using a semicolon?
When should a type cast be used?
Using which language Test cases are added in .ptu file of RTRT unit testing???
Do you have any idea how to compare array with pointer in c?
What is ambagious result in C? explain with an example.
What does & mean in scanf?
What is the general form of function in c?
What does the && operator do in a program code?
Is it cc or c in a letter?
How do you define structure?