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

Explain the difference between use and require?

5 Answers   Aspire,


Write syntax to use grep function?

0 Answers  


What can be done for efficient parameter passing in perl?

0 Answers  


How the interpreter is used in Perl?

0 Answers  


How can you use Perl warnings and what is the importance to use them?

0 Answers  






Explain lists in perl?

0 Answers  


How do find the length of an array?

0 Answers  


Explain the execution of a program in perl.

0 Answers  


Where the command line arguments are stored and if you want to read command-line arguments with Perl, how would you do that?

0 Answers  


What are perl strings?

0 Answers  


Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.

0 Answers  


Explain arrays in perl.

0 Answers  


Categories