Showing posts with label odd and even numbers in javascript. Show all posts
Showing posts with label odd and even numbers in javascript. Show all posts

Sunday, December 11, 2016

Odd and Even Number Checker in JavaScript

Here is a program that I wrote using JS or JavaScript to ask the user to give a number then our program will check and determine if the given number is ODD and EVEN number.  

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

<html>
<body bgcolor="gray">

<script type="text/javascript">
  function odd_even() {
   
   var val = document.getElementById("num").value;
     n = parseInt(val);
if (isNaN(n))
{
alert("Please Enter a Number");
}
else if (n == 0)
{
alert("The number is zero");
}
else if (n%2)
{
alert("The number is odd");
}
else
{
alert("The number is even");
}
}
</script>
<font color="white" size="6">
 <center>
Odd And Even Number Checker 1.0 <br>
<font size="3">
Created By <br>
Mr. Jake R. Pomperada, MAED-IT
</center>
 <br>
</font>

<form >
<font color="white" size="4">
  Please Enter a Number <input type="text" id="num" name="number" /><br />
  <br>
  <input type="submit" value="Check Number" onclick="odd_even();"/>
</font>
</form>

</body>
</html>