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

How to implement a stack in Perl?

0 Answers  


Explain different types of perl operators.

0 Answers  


What are the different instances used in cgi overhead?

0 Answers  


you are required to replace a char in a string and store the number of replacements. How would you do that?

0 Answers  


Explain what is the scalar data and scalar variables in Perl?

0 Answers  






How does polymorphism work in perl?

0 Answers  


How do I print the entire contents of an array with Perl?

0 Answers  


What does last statement do in perl?

0 Answers  


Explain the meaning of perl one-liner?

0 Answers  


What is the different between array and hash in perl programming?

0 Answers  


What are the different types of perl operators?

0 Answers  


Perl uses single or double quotes to surround a zero or more characters. Are the single(' ') or double quotes (" ") identical?

0 Answers  


Categories