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
Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon
Why pointers are used in c?
What is maximum size of array in c?
What is a stream in c programming?
What tq means in chat?
Is it better to use a macro or a function?
What are the types of type specifiers?
Explain pointer. What are function pointers in C?
Explain how can I remove the trailing spaces from a string?
How can I prevent another program from modifying part of a file that I am modifying?
What is the collection of communication lines and routers called?
How can you tell whether two strings are the same?
What are the 4 types of functions?
Multiply an Integer Number by 2 Without Using Multiplication Operator
How can I remove the trailing spaces from a string?