Programs

Python Program for String Palindrome

When a number remains the same even after reversal, it is referred to as a palindrome. Some examples of palindromes include 656, 232, 46764, and the like. Palindromes can also exist as strings such as MADAM (Palindrome Program in Java – Javatpoint, n.d.). In Java, a basic algorithm may be applied to check whether a number is a palindrome. The basic steps included in the algorithm are summarized below:

  • Assign the number to a temporary variable
  • Obtain the reverse of the number
  • Compare the value of the number in the temporary variable with the reversed value
  • When there is no difference between the two values, print a message stating that it is a palindrome. Otherwise, print a message stating that the number is not a palindrome.

Check out our free technology courses to get an edge over the competition.

Several other approaches may be applied to check whether a given number or string is a palindrome. In the example below, two pointers are used to navigate from the beginning to the end of the input provided. The program confirms whether the supplied input is a palindrome (Java program to check whether a string is a Palindrome, 2019).

Learn Software Development Courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs or Masters Programs to fast-track your career.

Explore our Popular Software Engineering Courses

In-Demand Software Development Skills

Amid increased conversations around crypto and Blockchain technology, if you wish to educate yourself professionally on the topic, then upGrad’s Executive Post Graduate Programme in Software Development – Specialisation in Blockchain under IIIT- Bangalore is the right choice for you!

Read our Popular Articles related to Software Development

 

Want to share this article?

Plan your Software Development Career Now!

Leave a comment

Your email address will not be published. Required fields are marked *

Leave a comment

Your email address will not be published. Required fields are marked *

×
Get Free career counselling from upGrad experts!
Book a session with an industry professional today!
No Thanks
Let's do it
Get Free career counselling from upGrad experts!
Book a Session with an industry professional today!
Let's do it
No Thanks