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
Why c++ is called oop?
Is swift faster than go?
What are virtual functions in c++?
What are the advantages of using const reference arguments in a function?
What is scope operator in c++?
What is stl containers in c++?
What is the difference between #import and #include in c++?
Perform addition, multiplication, subtraction of 2-D array using Operator Overloading.
What is the object serialization?
What is null and void pointer?
If you want to share several functions or variables in several files maitaining the consistency how would you share it?
What is the difference between global variables and static varables?
What are the advantages of early binding?
What sorting algorithm does c++ use?
Is c++ a good first language to learn?