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 are single and multiple inheritances in c++?
What is purpose of abstract class?
What are enumerations?
write a corrected statement so that the instruction will work properly. if (4 < x < 11) y = 2 * x;
What is difference between c++ 11 and c++ 14?
When there is a global variable and local variable with the same name, how will you access the global variable?
What is the object serialization?
What is class definition in c++ ?
Program to check whether a word is a sub-string or not of a string typed
Does c++ have foreach?
What do c++ programmers do?
write a programme to get a character and thier ASCII value
Write a program to find the reverse Fibonacci series starting from N.
What is a multimap c++?
What is the difference between a definition and a declaration?