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
If you know then define #pragma?
#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); }
What happens if you free a pointer twice?
how we can make 3d venturing graphics on outer interface
What is the use of #include in c?
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.
What is integer constants?
what will be the output for the following main() { printf("hi" "hello"); }
What does != Mean in c?
What is the main difference between calloc () and malloc ()?
When should we use pointers in a c program?
Write a program to use switch statement.
What are integer variable, floating-point variable and character variable?
How can I trap or ignore keyboard interrupts like control-c?
How can I write functions that take a variable number of arguments?