Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is difference between far and near pointers?

1044


What is the use of a static variable in c?

1062


What are different storage class specifiers in c?

1096


Is fortran faster than c?

1046


Explain can you assign a different address to an array tag?

1054


Is there anything like an ifdef for typedefs?

1154


What does nil mean in c?

1272


WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

1868


Why does this code crash?

1104


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

1306


What is getch () for?

1243


How do I read the arrow keys? What about function keys?

1088


Can i use “int” data type to store the value 32768? Why?

1192


What header files do I need in order to define the standard library functions I use?

1063


What's the total generic pointer type?

1056