ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories >> Software >> Programming-Languages >> C++ >> OOPS
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
swapping program does not use third variable
 Question Submitted By :: Vinothkumaar
I also faced this Question!!     Rank Answer Posted By  
 
  Re: swapping program does not use third variable
Answer
# 1
class swap
{
public:
int a,b;
void swapp()
{
a = a + b;
b = a - b;
a = a - b;
}
};
class swap s1.
s1.swapp();
cout<<a<<b;
 
Is This Answer Correct ?    1 Yes 0 No
Jayasrinivas.donavalli
 
  Re: swapping program does not use third variable
Answer
# 2
void main()
{
int a,b;//example a=10,b=12;
a=a+b;//a=22
b=a-b;//b=10;
a=a-b;//a=12
}
 
Is This Answer Correct ?    1 Yes 0 No
Jayabalan.s
 
 
 
  Re: swapping program does not use third variable
Answer
# 3
void main()
{
int a,b;//example a=10,b=12;
a=a~b;//a=22
b=a~b;//b=10; 
a=a~b;//a=12
}


NOTE:
    ~=XOR operator( not able to write xor
            operator so iam using this symbol which is not 
             correct)
 
Is This Answer Correct ?    1 Yes 1 No
Abdul Rahman
 
  Re: swapping program does not use third variable
Answer
# 4
swap(a,b);
{
  a=a+b;
  b=a-b;
  a=a-b;
}
Explenation:
if a=5 and b=10
   a=a+b(5+10)=15
   b=a-b(15-10)=5------------swaped here
   a=a-b(15-5)=10------------
 
Is This Answer Correct ?    1 Yes 0 No
Venkanna
 
 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
Name an advantage of linked list over array? IBM6
What is multiple inheritance ? Ness-Technologies8
what is diff between .net 1.1 and .net 2.0  3
suppose A is a base class and B is the derved class. Both have a method foo which is defined as a virtual method in the base class. You have a pointer of classs B and you typecast it to A. Now when you call pointer->foo, which method gets called? The next part of the question is, how does the compiler know which method to call? EA-Electronic-Arts2
How is exception handling carried out in c++?  1
In c++ there is only virtual destructors, no constructors. Why?  2
What is friend function? Wipro3
Name an advantage of array over linked list? IBM11
Should you protect the global data in threads? Why or why not? IBM1
In the following declaration of main, "int main(int argc, char *argv[])", to what does argv[0] usually correspond? 1) The first argument passed into the program 2) The program name 3) You can't define main like that  4
How would you stop a class from class from being derived or inherited. Ness-Technologies7
Write a macro for swapping integers  3
What is abstraction?  5
What do you mean by public, private, protected and friendly?  1
What do you mean by inline function?  1
how can we design a magic square in c++?or suggest me the basic idea of it.  1
What is an orthogonal base class?  1
how to swap to variables without using thrid variable in java?  3
What is the difference between and interface and an abstract class ? Ness-Technologies2
what are the disadvantages of C++? ATS2
 
For more OOPS Interview Questions Click Here 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com