How to reverse a string using a recursive function, with
swapping?
Answer Posted / vignesh1988i
#include<stdio.h>
#include<conio.h>
char a1[50]; //GLOABAL VAR.
void reverse(int);
void main()
{
int count=0;
printf("enter the string :");
scanf("%s",a1);
for(int i=0;a1[i]!='\0';i++)
count++;
reverse(count);
getch();
}
void reverse(int count1)
{
char temp;
static int i=0;
if(i<=count1/2)
{
temp=a1[i];
a1[i]=a1[count1-1];
a1[count1-1]=temp;
i++;
reverse(--count1);
}
else
printf("\nthe reversed string is :%s",a1);
}
thank u
| Is This Answer Correct ? | 8 Yes | 1 No |
Post New Answer View All Answers
Is sizeof a keyword in c?
What does the c preprocessor do?
What is the general form of #line preprocessor?
Write a program to find factorial of a number using recursive function.
What is s in c?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What is external variable in c?
What is a #include preprocessor?
What is c value paradox explain?
Where can I get an ansi-compatible lint?
How can type-insensitive macros be created?
What is 1d array in c?
State two uses of pointers in C?
Is c is a low level language?
What is the description for syntax errors?