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 |
I have created a CGI-based page,after entering all the values in to the fields, How to get the output on the web browser using Perl
You want to print the contents of an entire array. How would you do that?
Explain join function in perl?
How can you use Perl warnings and what is the importance to use them?
Explain chomp?
What does 'do' statement do in perl?
How to print escaping characters inside a string in perl?
How do I sort a hash by the hash value?
How do I pass a command line argument in perl?
There are some duplicate entries in an array and you want to remove them. How would you do that?
How to create a directory in perl?
Explain what is perl language?