Ticker

6/recent/ticker-posts

Javascript program to find number is odd or even.



Problem:- Is to find  number is even or odd.

Solution:-

  • First open notepad.
  • Then write code of even or odd using html and javascript.
  • Save file html extention.
  • Right click on file and open with browser(chromo).
  • Output show in the browser according to the code.

Program code using html and javascript



Output according to javascript and html code






In this program <script> tag is used to add javascript code into html file.variable is used to store the value that is enter by user.window.prompt method is used to get the value from the user.To convert that value into integer parseInt funcction is used that convert the input value into integer.Use decision making statement if else(beacause here two statement even or odd).if number divide by 2 and remainder is zero then number is even else odd. for example here number is 3 if divide that number with 2 get remainder one not zero so that number is odd . document.writeln is built in function or method that is used to print or display a message on the browser screen. Using this javascript method print that number is odd.finally script tag,head tag and html tag is closed. 

 

Post a Comment

0 Comments