write a program to swap Two numbers without using temp variable.

Answer Posted / ramprasad

class Swap
{
static int iValue,jValue,tot;
public static int swap(int A, int B){
tot = A+B;
iValue = tot-B;
jValue = tot-iValue;
return iValue;
//return jValue;
}
public static void main(String[] args)
{
System.out.println(Swap.swap(5,6));
}
}

Is This Answer Correct ?    23 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the ways to a null pointer can use in c programming language?

865


Explain what are header files and explain what are its uses in c programming?

870


What is strcpy() function?

861


Why is structure padding done in c?

881


What are identifiers and keywords in c?

765


What is the newline escape sequence?

829


What are qualifiers in c?

771


Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

801


What is scope of variable in c?

769


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

2951


Why do we use static in c?

825


Explain the array representation of a binary tree in C.

946


Is flag a keyword in c?

898


What is New modifiers?

882


What are the types of c language?

768