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

What is a binary file? List the merits and demerits of the binary file usagein C++.

1369


Is c++ a float?

1107


What should main() return in c and c++?

1072


Define a constructor?

1107


Can we change the basic meaning of an operator in c++?

1159


What is implicit pointer in c++?

1143


What is the exit function in c++?

1027


Can you please explain the difference between overloading and overriding?

1149


What is the difference between ++ count and count ++?

1198


How do you define a class in c++?

1135


Can user-defined object be declared as static data member of another class?

1076


What is the insertion operator and what does it do?

1099


Is c++ fully object oriented?

1019


Why do we need c++?

1107


Evaluate as true or false: !(1 &&0 || !1) a) True b) False c) Invalid statement

1256