JavaScript program that demonstrates the use of +=,-=,*=,/= Operators.
JavaScript program that demonstrates the use of +=,-=,*=,/= Operators.
Example:-
var
a=10; // Initial value of the variable is a=10.
a+=10; // It increments the value of variable a=a+10
so the value a become 20.
a-=10;
// It increments the value of variable a=a-10 so the value a become 10.
a*=10;
// It increments the value of variable a=a*10 so the value a become 100.
a/=10;
// It increments the value of variable a=a/10 so the value a become 10.
<!--
Q-2 JavaScript program that demonstrates the use of +=,-=,*=,/= Operators.
-->
<html>
<head>
<title>
Session 3- 2nd program.
</title>
<script type="text/javascript">
var num1=parseInt(prompt("Enter First Number"));
var num2=parseInt(prompt("Enter Second Number"));
document.write("<br>First Number is : "+num1);
document.write("<br>Second Number is : "+num2);
document.write("<br>Adddition is : "+(num1+num2));
document.write("<br>Subtraction is : "+(num1-num2));
document.write("<br>Multiplication is : "+(num1*num2));
if(num2>0)
{
document.write("<br>Division is : "+(num1/num2));
}
else
{
document.write("<br>Division is not possible");
}
</script>
</head>
<body>
No comments:
Post a Comment