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

State the difference between delete and delete[].

1117


What is function overloading in C++?

1434


If you don’t declare a return value, what type of return value is assumed?

968


What is the best c c++ compiler for windows?

1072


what is VOID?

1075


If dog is a friend of boy, is boy a friend of dog?

991


Can we use clrscr in c++?

1083


Is swift a good first language?

1055


Explain method of creating object in C++ ?

1111


What are the advantages of inheritance in c++?

1109


What kind of problems can be solved by a namespace?

1102


What is c++ iterator?

1157


What is the difference between equal to (==) and assignment operator (=)?

1085


When does a 'this' pointer get created?

1109


Which sort does c++ use?

1027