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

Is c++ a good beginners programming language?

1027


What are c++ variables?

1016


what does the following statement mean? int (*a)[4]

1037


What are the differences between new and malloc?

1065


What is the advantage of an external iterator.

993


What will the line of code below print out and why?

687


What is a node class in c++?

1038


Define a pdb file.

1035


What is fixed in c++?

992


Explain terminate() function?

1017


What is difference between rand () and srand ()?

1052


What is token c++?

991


What is data abstraction? How is it different from data encapsulation?

956


State two differences between C and C++.

1104


describe private access specifiers?

1154