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

What is the difference between perl array and perl hash?

1 Answers  


What are perl variables?

1 Answers  


Mention the difference between die and exit in Perl?

1 Answers  


Write a cgi program to show the header part?

1 Answers  


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

3 Answers   Oracle, Persistent, ViPrak,


Can we load binary extension dynamically?

1 Answers  


How to convert strings into an array in perl?

1 Answers  


What is perl? What is the basic command to print a string in perl?

0 Answers  


What is the usage of -i and 0s options?

1 Answers  


List the prefix dereferencer in Perl.

1 Answers  


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

1 Answers  


What does file test operators do in perl?

1 Answers  


Categories