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...

Write a program to swap 2 chars without using a third
varable?
char *s = "A";
char *p = "B";

Answer Posted / lior

void swap(char *s, char *p)
{
if(0 == s || 0 == p)
return;
*s += *p;
*p = *s - *p;
*s = *s - *p;
}

int main()
{
/* Use chars and not strings!! */
char ac = 'A';
char bc = 'B';
char *a = &ac;
char *b = &bc;
swap(a,b);
}

Is This Answer Correct ?    12 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are default parameters? How are they evaluated in c++ function?

1131


What is the use of lambda in c++?

970


What is a pdb file?

943


How can you tell what shell you are running on unix system?

1060


Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.

2151


What is std namespace in c++?

1120


What is the use of vtable?

1100


Will the following program execute?

994


What is a constant reference?

1022


What do you mean by delegate? Can a user retain delegates?

885


Which is the best c++ compiler for beginners?

1018


Should the this pointer can be used in the constructor?

975


why is c++ called oops? Explain

989


Explain 'this' pointer and what would happen if a pointer is deleted twice?

1017


Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?

1201