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

Why is c++ still used?

612


What is c++ runtime?

661


What are the advantages of c++?

600


What relational operators if statements in c++?

649


Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .

693






Explain the virtual inheritance in c++.

605


What are the implicit member functions of class?

601


Can a built-in function be recursive?

588


What is purpose of abstract class?

590


What can I safely assume about the initial values of variables which are not explicitly initialized?

629


What is data types c++?

548


What are the basics of local (auto) objects?

636


What is enum c++?

622


Does dev c++ support c++ 11?

565


Difference between struct and class in terms of access modifier.

701