Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Odd & Even Number.

Posted on 2000-05-04
Medium Priority
399 Views
hi,

How to detect the input number is odd or even number?
0
Question by:zamirjalil
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 6

Accepted Solution

setiawan earned 4 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

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

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

## Featured Post

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
###### Suggested Courses
Course of the Month10 days, 23 hours left to enroll