write a script to check whether user enter a value is a
leap year or not?
Answers were Sorted based on User's Feedback
Answer / sourisengupta
#call this function by passing the year....
sub isLeapyear
{
$year=shift;
if($year%4==0){
if($year%100==0){
if($year%400==0)
return 1;
return 0;
}
return 1;
}
}
| Is This Answer Correct ? | 14 Yes | 2 No |
Answer / 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 |
Answer / sourisengupta
#call this function by passing the year....
sub isLeapyear
{
$year=shift;
if($year%4==0){
if($year%100==0){
if($year%400==0)
return 1;
return 0;
}
return 1;
}
}
| Is This Answer Correct ? | 7 Yes | 2 No |
What is the use of strict?
Distinguish my and local?
What is a hash?
6 Answers Photon, Satyam, Wipro,
What is use of ‘->’ symbol?
Explain cpan?
How to check the status of airplane mode (enable/disable) in perl for Android mobile?
what is perl language?
How do I sort a hash by the hash key?
What does this symbol mean '->'?
What is the use of now constructor in perl?
Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?
How to do comment in perl?