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 is oop in c++?

1083


What is lambda in c++?

1235


What is a local reference?

1191


what are the events occur in intr activated on interrupt vector table

1758


Explain object slicing in c++?

1058


Why is swift so fast?

1129


What are files in c++?

1041


What is the use of typedef?

1102


What is near, far and huge pointers? How many bytes are occupied by them?

1119


What is the use of setprecision in c++?

1017


Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.

1053


Write a program which uses Command Line Arguments

1186


Difference between a homogeneous and a heterogeneous container

1144


Mention the ways in which parameterized can be invoked. Give an example of each.

1064


Define friend function.

1049