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

How can we check whether the contents of two structure variables are same or not?

0 Answers  


List down the guideline that should be followed while using friend function.

0 Answers  


Explain the uses oof nested class?

0 Answers  


What is virtual base class?

0 Answers  


What is an adaptor class or wrapper class in c++?

0 Answers  






What is an incomplete type in c++?

0 Answers  


Can turbo c++ run c program?

0 Answers  


Why do C++ compilers need name mangling?

3 Answers   Lucent,


What are the difference between reference variables and pointers in C++?

1 Answers  


Is there a new/delete equivalent of realloc?

1 Answers  


What it is and how it might be called (2 methods).

0 Answers  


What are all predefined data types in c++?

0 Answers  


Categories