Write a JavaScript program for swapping of two numbers

<html>
<head>
<title> swapping < /title>
<script language = “Javascript”>
var a, b;
 a = parseInt (window. prompt (“enter a value”, “0”));
 b = parseInt (window. prompt (“ enter b value”, “0”));
document.write (“ values before swapping a = “ + a + “ b = “+ b );
 a = a + b;                  
b = a – b;      
a = a – b;                    
document.write (“< h1 value after swapping a = “ + a+” b = “+b + “ < /h1>);
< /script>
< /head>
< body > < /body>
< /html>

(or)

<html>
<head>
<title> swapping < /title>
<script language = “Javascript”>
var a, b;
 a = parseInt (window. prompt (“enter a value”, “0”));
 b = parseInt (window. prompt (“ enter b value”, “0”));
document.write (“ values before swapping a = “ + a + “ b = “+ b );
a = a * b;
b = a/b;
a = a/b;
document.write (“< h1 value after swapping a = “ + a+” b = “+b + “ < /h1>);
< /script>
< /head>
< body > < /body>
< /html>

Related

Web Technology 4885271293850157354

Post a Comment

emo-but-icon

item