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, without
swapping or using an extra memory?

Answer Posted / moinom

#include <iostream>
#include <conio>

void reverse(char a[], int s, int sc );

void reverse(char a[], int s, int sc ){

if ((sc-s)<(s-1))
{
a[sc-s]^=a[s-1];
a[s-1]^=a[sc-s];
a[sc-s]^=a[s-1];
reverse (a, s-1, sc) ;

}

}

void main (){


char a[]="ABCDEFG";

reverse(a, 7, 7);
cout<<a;
getch(); //i just use it to freeze the screen

}

Is This Answer Correct ?    14 Yes 29 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to Throw some light on the splay trees?

1066


Explain how do you view the path?

1178


Why is c platform dependent?

1092


PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM

2186


Can main () be called recursively?

1124


Explain the Difference between the New and Malloc keyword.

1141


Can we declare a function inside a function in c?

1042


How can I direct output to the printer?

1324


What are logical errors and how does it differ from syntax errors?

1303


How is pointer initialized in c?

1027


What is call by reference in functions?

1456


Explain null pointer.

1121


void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }

1727


What is #define used for in c?

1066


All technical questions

1992