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

Explain how can you restore a redirected standard stream?

1032


How do you initialize pointer variables?

1034


What is structure data type in c?

974


What are bitwise shift operators in c programming?

1040


Which is best book for data structures in c?

1041


What does malloc () calloc () realloc () free () do?

1006


What is the most efficient way to count the number of bits which are set in an integer?

1003


What is an auto variable in c?

1171


Why do we use c for the speed of light?

1106


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

2205


What are the 5 elements of structure?

1043


What is an endless loop?

1233


cavium networks written test pattern ..

4030


Explain modulus operator.

1001


Can include files be nested? How many levels deep can include files be nested?

1091