Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Checking for odd/even number

by perlmonkey (Hermit)
on May 28, 2000 at 11:07 UTC ( [id://15187]=note: print w/replies, xml ) Need Help??


in reply to Checking for odd/even number

And you can inline the if/else using the ? : operators. print $_ % 2 ? "$_ is odd\n" : "$_ is even\n" for (1..5) Results:
1 is odd
2 is even
3 is odd
4 is even
5 is odd

Replies are listed 'Best First'.
Re: Re: Checking for odd/even number
by Anonymous Monk on Apr 13, 2003 at 16:42 UTC
    how u gonna write your source code if u have to print odd and even number for less than 50 only using while statement for odd and for statement for even number: Wondering.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://15187]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-18 18:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found