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 are default parameters? How are they evaluated in c++ function?
What is the use of lambda in c++?
What is a pdb file?
How can you tell what shell you are running on unix system?
Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.
What is std namespace in c++?
What is the use of vtable?
Will the following program execute?
What is a constant reference?
What do you mean by delegate? Can a user retain delegates?
Which is the best c++ compiler for beginners?
Should the this pointer can be used in the constructor?
why is c++ called oops? Explain
Explain 'this' pointer and what would happen if a pointer is deleted twice?
Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?