Write a script to display mirror image of a entered value and also check whether Palindrome?
Submitted by: Administratorprint("Enter the no. to check for Palindrome : ");
$no = <STDIN>;
chop($no);
$i = 0;
# Store into a array
while($no != 0)
{
@array[$i] = $no % 10;
$no = int($no / 10);
$i++;
}
$i--;
$j=0;
$flag = "true";
# Check for Palindrome
while( ($flag eq "true" )&& ( $j < @array/2) ){
if (@array[$j] != @array[$i])
{
$flag = "false"
}
$i--;
$j++;
}
# Print the result
if( $flag eq "true")
{
print("It is a Palindromen");
}
else
{
print("It is NOT a Palindromen");
}
Submitted by: Administrator
$no = <STDIN>;
chop($no);
$i = 0;
# Store into a array
while($no != 0)
{
@array[$i] = $no % 10;
$no = int($no / 10);
$i++;
}
$i--;
$j=0;
$flag = "true";
# Check for Palindrome
while( ($flag eq "true" )&& ( $j < @array/2) ){
if (@array[$j] != @array[$i])
{
$flag = "false"
}
$i--;
$j++;
}
# Print the result
if( $flag eq "true")
{
print("It is a Palindromen");
}
else
{
print("It is NOT a Palindromen");
}
Submitted by: Administrator
Read Online CGI Perl Job Interview Questions And Answers
Top CGI Perl Questions
☺ | Difference between Perl and Mod_perl? |
☺ | Write a script to display mirror image of a entered value and also check whether Palindrome? |
☺ | Write an expression or Perl script to identify the entered IP address is valid or not? |
☺ | Write a script to generate n prime no.s? |
☺ | How to find a substring in a string without using substr built in functions, and print the substring found? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |