Saturday, March 9, 2024

Program 9 B.Sc Computer Science with Data analytics Linux and Shell Programming - Lab Bharathiar University - Write a shell script to check whether given string is palindrome or not.

 

B.Sc Computer Science  with Data analytics

Linux and Shell Programming - Lab  

Bharathiar University 

Program 9-  Write a shell script to check whether given string is palindrome or not. 


Source Code


# Main program starts here


# Prompt the user to enter the string

    echo "Enter the string: "

    read str

    reversed=$(echo "$str" | rev)

    if [ "$str" = "$reversed" ]; then

        echo "The string '$str' is a palindrome."

    else

        echo "The string '$str' is not a palindrome."

    fi



Sample OUTPUT:



No comments:

Post a Comment

Program 12 BCA Madras University BCA Object Oriented Programming using C++ Practical Madras University Program 12 Implement a telephone directory using files

  BCA Object Oriented Programming using C++ Practical Madras University  Program 12  Implement a telephone directory using files SOURCE CODE...