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 is oop in c++?
What is lambda in c++?
What is a local reference?
what are the events occur in intr activated on interrupt vector table
Explain object slicing in c++?
Why is swift so fast?
What are files in c++?
What is the use of typedef?
What is near, far and huge pointers? How many bytes are occupied by them?
What is the use of setprecision in c++?
Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.
Write a program which uses Command Line Arguments
Difference between a homogeneous and a heterogeneous container
Mention the ways in which parameterized can be invoked. Give an example of each.
Define friend function.