Write a program to swap 2 chars without using a third
varable?
char *s = "A";
char *p = "B";
Answer Posted / dooglus
#include <cstdio>
void swap(char *c, char *d)
{
*d = *c^*d; // c = C d = C^D
*c = *c^*d; // c = C^C^D d = C^D
*d = *c^*d; // c = C^C^D d = C^C^D^C^D
}
main()
{
char c = 'c';
char d = 'd';
swap(&c, &d);
}
| Is This Answer Correct ? | 20 Yes | 3 No |
Post New Answer View All Answers
What do you mean by a template?
How do you invoke a base member function from a derived class in which you have not overridden that function?
Write a function that swaps the values of two integers, using int* as the argument type?
Why was c++ created?
Explain virtual class and friend class.
What are literals in C++?
Write a program to find the Fibonacci series recursively.
What is else syntax in c++?
What does new do in c++?
What kind of jobs can I get with c++?
What is &x in c++?
what is the difference between linear list linked representaion and linked representation? what is the purpose of representing the linear list in linked represention ? is it not avoiding rules of linear represention?
What is == in programming?
How do you write a function that can reverse a linked-list?
What is the size of integer variable?