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 a responder chain?

1 Answers  


How did c++ get its name?

1 Answers  


What is flush programming?

1 Answers  


What is the real purpose of class – to export data?

1 Answers  


What are the popular tools used to detect memory leaks in c++

4 Answers   TATA,


write a program that takes two numbers from user that prints the smallest number

2 Answers  


Write a program that will count the number of digits in an input integer up to value MAX_VALUE (2147483647). Thus, for an input of 5837 the output should be 4 digits Make sure that your program works for the numbers 0, 1, and 10. For the number 0, the output should be 1 digit

2 Answers  


What is a built-in function?

1 Answers  


What is data types c++?

1 Answers  


What are the types of pointer?

1 Answers  


Why c++ is the best language?

1 Answers  


You want to link a c++ program to c functions. How would you do it?

1 Answers  


Categories