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
Why is %d used in c?
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
Who is the main contributor in designing the c language after dennis ritchie?
How to compare array with pointer in c?
can we change the default calling convention in c if yes than how.........?
What does sizeof return c?
What are the types of data types and explain?
What is the difference between near, far and huge pointers?
State the difference between realloc and free.
What are lookup tables in c?
How do you construct an increment statement or decrement statement in C?
Explain is it valid to address one element beyond the end of an array?
What is the best way of making my program efficient?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
In c programming typeing to occupy the variables in memory space. if not useing the variable the memory space is wasted.ok, how to avoid the situation..? (the variable is used & notused)