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 / dooglus

#include <cstdio>

void swap(char *c, char *d)
{
*d = *c^*d; // c = C d = C^D
*c = *c^*d; // c = C^C^D d = C^D
*d = *c^*d; // c = C^C^D d = C^C^D^C^D
}

main()
{
char c = 'c';
char d = 'd';
swap(&c, &d);
}

Is This Answer Correct ?    20 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does count ++ do in c++?

1197


What is flush () in c++?

1077


Can I have a reference as a data member of a class? If yes, then how do I initialise it?

1221


Define namespace in c++?

1042


what is a class? Explain with an example.

1135


What are the differences between java and c++?

1072


Can we use pointers in c++?

1046


What are destructors?

995


How to access a variable of the structure?

1080


What are pointer-to-members in C++? Give their syntax.

1134


Why is null pointer used?

1168


Which is the best c++ software?

1096


How do I download c++?

1005


What is c++ array?

1111


Is there a sort function in c++?

993