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 / prasenjit roy

#include <stdio.h>

//No restrinction of datatype
#define SWAP(x,y) { x = x ^ y; \
y = x ^ y; \
x = x ^ y; \
}

void main()
{
char c = 'c';
char d = 'd';
SWAP(c, d);
}

Is This Answer Correct ?    13 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What new()is different from malloc()?

1114


What's the order in which the objects in an array are destructed?

1419


What is :: operator in c++?

1059


What is the purpose of templates in c++?

1037


What is flush () in c++?

1083


Why is null pointer used?

1176


Which c++ operator cannot overload?

1021


what are the iterator and generic algorithms.

2171


What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor

1165


What is namespace & why it is used in c++?

1124


Should the member functions which are made public in the base class be hidden?

1034


Is c++ a good first language to learn?

1074


What operators can you overload in c++?

1045


Is c++ low level?

1037


Why c++ is called oop?

1129