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
Differentiate between an array and a list?
What is a terminating character in c++?
What is a tuple c++?
Why ctype h is used in c++?
Define a constructor?
Name the implicit member functions of a class.
What is algorithm in c++ programming?
What is a template in c++?
Does c++ have foreach?
Comment on c++ standard exceptions?
What can c++ be used for?
Discussion on error handling of C++ .
What is a float in c++?
the maximum length of a character constant can be a) 2 b) 1 c) 8
What is Destructor in C++?