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 do I do fill_in_the_blank for each file in a directory?
Explain 'grep' function.
Why should I use the -w argument with my Perl programs?
How to renaming a file in perl programming?
You want to open and read data files with perl. How would you do that?
What is perl programming?
How can I display all array element in which each element will display on next line in perl ?
How do you turn on the perl warnings?
Explain perl. When do you use perl for programming? What are the advantages of programming in perl?
what are the two ways to get private values inside a subroutine or block?
What are the arguements we normally use for perl interpreter?
List the data types that Perl can handle?
What is posix in perl?
What are arrays in perl?
Write a program that explains the symbolic table clearly.