write a script to display mirror image of a entered value
and also check whether Palindrome
Answer Posted / narayan singh
print("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 Palindrome\n");
}
else
{
print("It is NOT a Palindrome\n");
}
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
how to extract pin_code,phone_number,year from text file using regular expressions in perl
Explain the execution of a program in perl.
Explain lists and ivalue?
What are the various uses of perl?
How can memory be managed in Perl?
What are the various perl data types based on the context?
How to renaming a file in perl programming?
what is the function of Return Value?
What is use of ‘->’ symbol?
What $! In perl?
How to connect to SQL server through Perl?
List the data types that Perl can handle?
Define print() function in perl?
Which has the highest precedence, List or Terms? Explain?
Explain different types of perl operators.