Solved

Odd & Even Number.

Posted on 2000-05-04
3
394 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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 …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 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