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

Answers were Sorted based on User's Feedback



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

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

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

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

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

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

Post New Answer

More CGI Perl Interview Questions

Which feature of Perl provides code reusability ? Give any example of that feature.

1 Answers  


You want to connect to sql server through perl. How would you do that?

0 Answers  


What can be done for efficient parameter passing in perl? Explain.

0 Answers  


What are the steps involved in configuring a server using cgi programming?

0 Answers  


How to close a directory in perl?

0 Answers  






How do you set environment variables in perl?

0 Answers  


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

0 Answers  


How do I generate a list of all .html files in a directory?

0 Answers  


How many types of primary data structures in Perl and what do they mean?

0 Answers  


What purpose does each of the following serve: -w, strict, - T ?

2 Answers  


Write a program to download the contents from www.perlinterview.com/answers.php website in Perl.

0 Answers  


How to convert arrays into a string in perl?

0 Answers  


Categories