write a script to check whether user enter a value is a
leap year or not?

Answer Posted / subhash chandran

#The logic is that the year is either divisible by both
100 and 4 , OR its only divisible by 4 not by hundred
if($Year%400 == 0 || ($Year%100 != 0 && $Year%4 == 0))
{
print "Leap year \n";
}
else
{
print "Not Leap \n";
}

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I sort a hash by the hash key?

654


Explain splicing of arrays?

601


What are the logical operators used for small scale operations?

627


How can I implement the function overloading in Perl ? I read about the operator overloading, I do not know how to implement the function overloading. Thanks in advance ?

2579


For a situation in programming, how can you determine that Perl is a suitable?

555






How can information be put into hashes?

607


Explain the functioning of conditional structures in perl.

536


Explain the difference between "my" and "local" variable scope declarations. ?

637


What happens to objects lost in "unreachable" memory, such as the object returned by Ob->new() in `{ my $ap; $ap = [ Ob->new(), $ap ]; }' ?

628


Enlist the advantages of using c over perl?

582


Explain gmtime() function in perl?

639


How to read a file into a hash array?

638


You want to download the contents of a url with perl. How would you do that?

573


How do I send e-mail from a Perl/CGI program on a Unix system?

654


Explain ivalue?

615