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
How are pointers type-cast?
What is a c++ object?
What is a class template?
Why null pointer is used?
What is c++ hiding?
Can c++ be faster than c?
Write about the various sections of the executable image?
Is it possible for a member function to delete the pointer, named this?
If you don’t declare a return value, what type of return value is assumed?
Why we use #include iostream in c++?
Can manipulators fall in love?
What is std :: endl?
How many different levels of pointers are there?
What are the uses of c++ in the real world?
Is c++ the hardest language?