this is to swap to strings....but in output the whole
strings are swapped leaving first as it is...why it is so

#include<iostream.h>
int main()
{
char a[]="ajeet";
char b[]="singh";
long x=*a;
long y=*b;
cout<<x<<":"<<y;
x=x+y;
y=x-y;
x=x-y;
*a=x;
*b=y;
cout<<x<<":"<<y;
cout<<&a<<endl;
cout<<&b<<endl;
}



this is to swap to strings....but in output the whole strings are swapped leaving first as it is.....

Answer / sachin chakote

only first letter will be swapped

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

what is VOID?

0 Answers  


Explain working of printf?

8 Answers  


Discuss the effects occur, after an exception thrown by a member function is unspecified by an exception specification?

0 Answers  


Define the process of error-handling in case of constructor failure?

0 Answers  


What is the difference between mutex and binary semaphore?

0 Answers  






How does the copy constructor differ from the assignment operator (=)?

0 Answers  


What is singleton pattern in c++?

0 Answers  


What is an object in c++?

0 Answers  


When is a template better solution than a base class??

2 Answers   emc2,


Describe protected access specifiers?

0 Answers  


What is long in c++?

0 Answers  


What is the difference between method overloading and method overriding in c++?

0 Answers  


Categories