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

Differentiate between an array and a list?

1176


What is a terminating character in c++?

1384


What is a tuple c++?

1008


Why ctype h is used in c++?

957


Define a constructor?

1045


Name the implicit member functions of a class.

1078


What is algorithm in c++ programming?

1121


What is a template in c++?

1839


Does c++ have foreach?

1046


Comment on c++ standard exceptions?

1069


What can c++ be used for?

1095


Discussion on error handling of C++ .

1118


What is a float in c++?

980


the maximum length of a character constant can be a) 2 b) 1 c) 8

1092


What is Destructor in C++?

1182