Write A program to print Comparison Operator using Javascript (using variable).
Code : comparison-operator.html
<!-- write a java script program to use of Comperison operator -->
<html>
<head>
<style type="text/css">
.body
{
font-size:30;
color:red;
}
</style>
</head>
<body class="body">
<p align="center">Comparison Operators </p>
<script type="text/javascript">
var a=10;
var b=5;
var c="bca";
var d=5;
var e="10";
document.write(" 1) Equal Comparesion operator (10 == 5) : ");
document.write(a==b);
if(a == b)
{
document.write("<br> Both are Equal ");
}
else
{
document.write("<br> Both are not Equal");
}
document.write("<br> 2) Strick equal comparison operator (10 === 10) : ");
document.write(a===e);
document.write("<br> 3) Not Equal Comparesion operator (10 != 5) : ");
document.write(a!=b);
document.write("<br> 4) Strick not equal comparesion operator (10 !== bca) : ");
document.write(a!==c);
document.write("<br> 5) Less than comparesion operator (10 < 5) : ");
document.write(a<b);
document.write("<br> 6) Greater than compareison operator (10 > 5) : ");
document.write(a>b);
document.write("<br> 7) Less than or Equal to comparison operator (5 <= 5) : ");
document.write(b<=d);
if ( b <= d)
{
document.write("<br> b is less than or equal to d");
}
else
{
document.write("<br> b is not less then or equal to d");
}
document.write("<br> 8) Greater than or Equal to comparison operator (10 >= 5) : ");
document.write(a>=d);
</script>
</body>
</html>
No comments:
Post a Comment