Write a program to swap 2 chars without using a third
varable?
char *s = "A";
char *p = "B";
Answer Posted / lior
void swap(char *s, char *p)
{
if(0 == s || 0 == p)
return;
*s += *p;
*p = *s - *p;
*s = *s - *p;
}
int main()
{
/* Use chars and not strings!! */
char ac = 'A';
char bc = 'B';
char *a = ∾
char *b = &bc;
swap(a,b);
}
| Is This Answer Correct ? | 12 Yes | 13 No |
Post New Answer View All Answers
State the difference between delete and delete[].
What is function overloading in C++?
If you don’t declare a return value, what type of return value is assumed?
What is the best c c++ compiler for windows?
what is VOID?
If dog is a friend of boy, is boy a friend of dog?
Can we use clrscr in c++?
Is swift a good first language?
Explain method of creating object in C++ ?
What are the advantages of inheritance in c++?
What kind of problems can be solved by a namespace?
What is c++ iterator?
What is the difference between equal to (==) and assignment operator (=)?
When does a 'this' pointer get created?
Which sort does c++ use?