answersLogoWhite

0


Best Answer

By using the algorithm of bitwise EORing (Exclusive ORing) the numbers together:

If the two numbers are X and Y, then to swap them:

X = X EOR Y

Y = Y EOR X

X =X EOR Y

will swap them.

With knowledge of that algorithm, one then uses the syntax of Javascript to implement it.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a javascript to swap two numbers without using third one?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write 3rd march 2011 without using numbers?

Third March, two thousand and eleven.


How do you call script code in javascript without using onclick?

function blahblah () { //do something } blahblah();


Is java script necessary for hacking?

No. There are many way of breaking into a system without using JavaScript.


What is program in c to swap entered two numbers without using third variable?

The required c program is given below /*Swapping(interchange) the two entered numbers*/ #include<stdio.h> main() { /*Without using third variable*/ int a,b,t; printf("Enter a:"); scanf("%d",&a); printf("Enter b:"); scanf("%d",&b); a=a+b; b=a-b; a=a-b; printf("\n After swapping without using third variable"); printf("\na=%d\nb=%d",a,b); }


How you add first 20 even numbers using javascript?

var sum = 0; for (var i = 0; i < 20; i++) { sum = sum + i * 2; }


How do you check length of password using javascript?

Use the length property of string in javascript.


How do you write third June 2011 in 5 letters without using numbers?

Just a guess: KEVIN (3rd June 2011 is Kevin's name day)


Can you get ipaddress by using javascript?

No, use asp


How do you show the text box output in the browser using Ajax code?

You can directly do that in the JavaScript. Just get the value of the input type in JavaScript using id and show it using .innerHTML.


What are the benefits of using JavaScript for forms?

JavaScript can help with dynamic retrieval of form data using AJAX and also the data can be checked and validated before sending it to the server. Apart from that you could add some animation and change views using javascript and jquery.


How can you close the iframe in calling page in php and javascript?

Using JavaScript, you can accomplish this by deleting the iframe node from the DOM.


What does a JavaScript certificate document?

A JavaScript certificate document is a document that proves you have all knowledge needed to master web development by using the Javascript and also HTML/DOM.