0% found this document useful (0 votes)
2 views

Operator

The document provides examples of various types of operators in JavaScript, including arithmetic, comparison, logical, and bitwise operators. Each section includes HTML and JavaScript code snippets that prompt the user for input and display the results of the operations. The document illustrates how to perform basic mathematical and logical operations using user-provided numbers.

Uploaded by

snehatumaskar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Operator

The document provides examples of various types of operators in JavaScript, including arithmetic, comparison, logical, and bitwise operators. Each section includes HTML and JavaScript code snippets that prompt the user for input and display the results of the operations. The document illustrates how to perform basic mathematical and logical operations using user-provided numbers.

Uploaded by

snehatumaskar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

• Arithmatic 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 :

You might also like