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
Why -w argument is used with perl programs?
How can you call a subroutine and identify a subroutine?
what are the steps involved in reading a cgi script on the server?
How to copy a file in perl?
Explain what is lvalue?
Explain the difference between declarations of 'my' and 'local' variable scope in perl?
What is the use of -n and -p options?
Why do you use Perl?
Why is it hard to call this function: sub y { "because" } ?
How will you access an element of a perl array?
You want to print the contents of an entire array. How would you do that?
There are two types of eval statements i.e. Eval expr and eval block. Explain them.
List the prefix dereferencer in Perl.
What are some common methods to all handles in perl?
What is the use of -w, -t and strict in Perl?