Operator
Operator
<html>
<head>
<script>
var a,b,c;
var ch = parseInt(prompt(" Hello!! Please Select One Of The Operation You Want To Choose 1.Addition
2.Subtraction 3.Multiplication 4.Division 5.Module"));
a=parseInt(prompt("Enter First Number"));
b=parseInt(prompt("Enter Second Number"));
if(ch==1)
{
document.write("Addition of " + a + " + " + b + " is " +(a+b));
}
else if(ch==2)
{
document.write("Subtraction of " + a + " + " + b + " is " +(a-b));
}
else if(ch==3)
{
document.write("Multiplication of " + a + " + " + b + " is " +(a*b));
}
else if(ch==4)
{
document.write("Division of " + a + " + " + b + " is " +(a/b));
}
else if(ch==5)
{
document.write("Module of " + a + " + " + b + " is " +(a%b));
}
</script>
</head>
</html>
• Output :
• Comparision Operator :
<html>
<head>
<script>
var a , b ,c ;
a = parseInt(prompt("Enter First Number"));
b = parseInt(prompt("Enter Second Number"));
document.write("<br>" + a + " > " +b+ " : " +(a>b) +"<br>");
document.write("<br>" + a + " < " +b+ " : " +(a<b) +"<br>");
document.write("<br>" + a + " >= " +b+ " : " +(a>=b) +"<br>");
document.write("<br>" + a + " <= " +b+ " : " +(a<=b) +"<br>");
document.write("<br>" + a + " == " +b+ " : " +(a==b) +"<br>");
document.write("<br>" + a + " != " +b+ " : " +(a!=bn) +"<br>");
</script>
</head>
</html>
• Output :
• Logical Operator :
<html>
<head>
<title> Logical Operator</title>
<script>
var a , b , c ;
a = parseInt(prompt("Enter First Number"));
b = parseInt(prompt("Enter Second Number"));
c = parseInt(prompt("Enter Third Number"));
document.write("<br>" +((a>b)&&(a>c)) +"<br>");
document.write("<br>" +((b>a)&&(b>c)) +"<br>");
document.write("<br>" +((c>a)&&(c>b)) +"<br>");
document.write("<br>" +((a>b)||(a>c)) +"<br>");
document.write("<br>" +((b>a)||(b>c)) +"<br>");
document.write("<br>" +((c>a)||(c>b)) +"<br>");
</script>
</head>
</html>
• Output :
• Bitwise Operator :
<html>
<head>
<title> Bitwise Operator </title>
<script>
var a , b;
a = parseInt(prompt("Enter First Number"));
b = parseInt(prompt("Enter Second Number"));
document.write("<br> a & b " +(a&b));
document.write("<br> a | b " +(a|b));
document.write("<br> a ^ b " +(a^b));
document.write("<br> a << b " +(a<<1));
document.write("<br> a >> b " +(b<<1));
</script>
</head>
</html>
• Output :