Solved

Odd & Even Number.

Posted on 2000-05-04
3
395 Views
Last Modified: 2011-09-20
hi,

How to detect the input number is odd or even number?
0
Comment
Question by:zamirjalil
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
setiawan earned 1 total points
ID: 2779242
Hi zamirjalil,

It is easy,

just mod the number with 2, if the result equal to zero then It is even others is odd

<% if (a mod 2) = 0 then
      response.write "Even"
   else
      response.write "Odd"  
   end if
%>
  danny
0
 

Author Comment

by:zamirjalil
ID: 2779263
Thanks danny,
BTW anything wrong with my code?

<%
if request("bdate")<> "" or request("bkod")<>"" or request("bjan")<>"" then

if Isdate(request("bdate")) then
 birthdate=request("bdate")
 age=datediff("yyyy",date(),birthdate)
else
birthdate=Cdate(mid(request"bdate"),3,2)&"/"&mid(request("bdate"),5,2)&"/"&left(request("bdate"),2))
age=datediff("yyyy",birthdate,date())
response.write "Your age now is:" & age & " years old."
end if

 if IsNumeric(request("bjan")) then
  inumur = request("bjan")
  if (inumur mod 2) = 0 then
   response.write inumur & "is an EVEN  number."
   response.write "You r a girl!"
  else
   response.write inumur & "is an ODD number."
   response.write "You r a man!"
  end if
end if %>
0
 

Author Comment

by:zamirjalil
ID: 2779274
sorry..a careless mistake...i found it. missing end if statement. Thanks everybody.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question