Solved

Odd & Even Number.

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now