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
What is a binary file? List the merits and demerits of the binary file usagein C++.
Is c++ a float?
What should main() return in c and c++?
Define a constructor?
Can we change the basic meaning of an operator in c++?
What is implicit pointer in c++?
What is the exit function in c++?
Can you please explain the difference between overloading and overriding?
What is the difference between ++ count and count ++?
How do you define a class in c++?
Can user-defined object be declared as static data member of another class?
What is the insertion operator and what does it do?
Is c++ fully object oriented?
Why do we need c++?
Evaluate as true or false: !(1 &&0 || !1) a) True b) False c) Invalid statement