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;
}
Answer Posted / sachin chakote
only first letter will be swapped
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are shallow and deep copy?
Can a Structure contain a Pointer to itself?
What methods can be overridden in java?
Why isn't sizeof for a struct equal to the sum of sizeof of each member?
What is the difference between #import and #include?
How does class accomplish data hiding in c++?
What is the importance of mutable keyword?
What is c++ namespace?
What is std :: flush?
What are the uses of pointers?
What is object in c++ wikipedia?
Explain how a pointer to function can be declared in C++?
If dog is a friend of boy and boy is a friend of house, is dog a friend of house?
When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?
What is c++ mutable?