Swapping with only two variables

<html>
<head>
<title>Swapping with only two variables
</title>
</head>
<body bgcolor=yellow text=white>
<script language=javascript>
document.write("<center>")
var no1,no2
no1=parseInt(prompt("Enter Number 1"))
no2=parseInt(prompt("Enter Number 2"))
document.write("<div style=background-color:brown;width:600px;height:400px>")
document.write("<br>")
document.write("<br>")
document.write("<h1>"+"Before swapping"+"<br>")
document.write("</h1>")
document.write("<h2>")
document.write("First number is "+no1+"<br>")
document.write("<br>")
document.write("Second number is "+no2+"<br>")
document.write("</h2>")
no1=no1+no2
no2=no1-no2
no1=no1-no2
document.write("<h1>"+"After swapping"+"<br>")
document.write("</h1>")
document.write("<h2>")
document.write("First number is "+no1+"<br>")
document.write("<br>")
document.write("Second number is "+no2+"<br>")
document.write("</h2>")
document.write("</div>")
document.write("</center>")
</script>
</body>
</html>

Comments

Popular posts from this blog

Use of CSS without frames

ASP.net code to display a report of client IP address,browser information etc.

Prime Number