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
any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above
What is #ifdef ? What is its application?
Why is it usually a bad idea to use gets()? Suggest a workaround.
Explain what are the standard predefined macros?
What are the 4 types of unions?
Can a variable be both constant and volatile?
What is the function of volatile in c language?
a c code by using memory allocation for add ,multiply of sprase matrixes
What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
Is c is a low level language?
Write a program of advanced Fibonacci series.
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?
How will you find a duplicate number in a array without negating the nos ?
Why is extern used in c?
Can you subtract pointers from each other? Why would you?