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
Is c++ a good beginners programming language?
What are c++ variables?
what does the following statement mean? int (*a)[4]
What are the differences between new and malloc?
What is the advantage of an external iterator.
What will the line of code below print out and why?
What is a node class in c++?
Define a pdb file.
What is fixed in c++?
Explain terminate() function?
What is difference between rand () and srand ()?
What is token c++?
What is data abstraction? How is it different from data encapsulation?
State two differences between C and C++.
describe private access specifiers?