How to reverse a string using a recursive function, with
swapping?
Answer Posted / vignesh1988i
the corrected code is:::
#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!=count)
{
temp=a1[i];
a1[i]=a1[count1-1];
a1[count1-1]=temp;
i++;
reverse(--count1);
}
else
printf("\nthe reversed string is :%s",a1);
}
| Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
What are structural members?
What is a struct c#?
Can you please explain the difference between strcpy() and memcpy() function?
how to execute a program using if else condition and the output should enter number and the number is odd only...
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)
Write a program to check whether a number is prime or not using c?
What are terms in math?
Is c is a low level language?
What is the use of #include in c?
Why do we use int main?
What functions are used for dynamic memory allocation in c language?
What is the basic structure of c?
What is a wrapper function in c?
why return type of main is not necessary in linux