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

Is ca high or low level language?

1020


What is constructor c++?

1067


What does new in c++ do?

967


What is void pointer in c++ with example?

1025


What is a storage class?

1183


How a macro differs from a template?

1105


What are punctuators in c++?

1091


Define anonymous class.

1016


What is atoi?

925


Which software is best for c++ programming?

1000


What is general format for a prototype?

977


What do you mean by volatile and mutable keywords used in c++?

930


Write about the role of c++ in the tradeoff of safety vs. Usability?

1006


What does namespace mean in c++?

1038


What is using namespace std in cpp?

1068