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 volatile variable how do you declare it?

1182


What is a void pointer in c?

1153


What are local variables c?

1063


What is omp_num_threads?

1131


How can you restore a redirected standard stream?

1171


What is the use of parallelize in spark?

1064


How can I call a function with an argument list built up at run time?

1285


What is difference between main and void main?

1285


What is an arrays?

1135


Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?

1051


What is break statement?

1173


What is function prototype in c language?

1085


Why is it usually a bad idea to use gets()? Suggest a workaround.

1864


What are global variables and explain how do you declare them?

1180


cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration

1149