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
What new()is different from malloc()?
What's the order in which the objects in an array are destructed?
What is :: operator in c++?
What is the purpose of templates in c++?
What is flush () in c++?
Why is null pointer used?
Which c++ operator cannot overload?
what are the iterator and generic algorithms.
What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor
What is namespace & why it is used in c++?
Should the member functions which are made public in the base class be hidden?
Is c++ a good first language to learn?
What operators can you overload in c++?
Is c++ low level?
Why c++ is called oop?