How to reverse a string using a recursive function, with
swapping?

Answer Posted / vignesh1988i

my next logic:::

#include<stdio.h>
#include<conio.h>
void reverse(char*,char*);
void main()
{
char a1[50],*p;
int count=0;
printf("enter the string:");
scanf("%s",a1);
for(int i=0;a[i]!='\0';i++)
count++;
p=a1+(count-1);
reverse(a1,p);
printf("the reversed one is : %s",a1);
getch();
}
void reverse(char *a1,char *p)
{
char temp;
if(a1<=p)
{
temp=*a1;
*a1=*p;
*p=temp;
reverse(++a1,--p);
}
}




thank u

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If you know then define #pragma?

862


#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }

895


What happens if you free a pointer twice?

803


how we can make 3d venturing graphics on outer interface

4350


What is the use of #include in c?

803


write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.

1742


What is integer constants?

789


what will be the output for the following main() { printf("hi" "hello"); }

10097


What does != Mean in c?

787


What is the main difference between calloc () and malloc ()?

820


When should we use pointers in a c program?

858


Write a program to use switch statement.

865


What are integer variable, floating-point variable and character variable?

848


How can I trap or ignore keyboard interrupts like control-c?

811


How can I write functions that take a variable number of arguments?

837