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


Please Help Members By Posting Answers For Below Questions

What are the uses of c++ in the real world?

658


Differentiate between realloc() and free().

676


Define virtual constructor.

735


Is it possible to get the source code back from binary file?

838


What is abstract keyword in c++?

709






What is the basic structure of a c++ program?

708


How do you save a c++ program?

659


What does it mean to declare a destructor as static?

714


What is the use of seekg in c++?

693


What is the difference between prefix and postfix versions of operator++()?

694


What is cout flush?

659


List the advantages of inheritance.

750


give me an example for testing a program showing the test path .show how the test is important and complex.

2536


Can we get the value of ios format flags?

763


How is computer programming useful in real life?

672