Java Program to check whether the Number is Palindrome or not2 min read

In this tutorial on Java Program to check whether the number is Palindrome or not, we will learn what is palindrome number is and its programming implementation with an explanation.

What is a palindrome number?

A number is said to be a Palindrome number if it remains the same when its digits are reversed or are the same as forward. It is also applied to the word, phrase or other sequences of symbols.

For example: 14141, 777, 272 are palindrome numbers as they remain the same even if reversed. If we take an example of ‘mam’ or ‘madam’, these are also palindrome words.


Explanation:
To check the palindrome number we use the logic to create a program. With the help of a while loop and arithmetic operators such as the remainder operator(%) and the division operator(/), we create a java program to check for palindrome numbers.

First, take the user input and run the while loop until the entered number(n) is not zero. Inside while loop, we take the remainder that returns the remainder in a division of n/10 that is remainder = n % 10;. Then inside rev variable put the following rev = rev * 10 + remainder;. At last, n is divided by 10 and returns the quotient.

After the end of the while loop, we check if the original number is equal to the reversed number. If true print accordingly as shown in the program.


Java Program to check whether the number is palindrome or not

Output:

Enter an integer: 383
383 is a palindrome.


MORE

Java Program to find the sum of the Largest Forward Diagonal

in this tutorial, we will write a java program to find the sum of the Largest Forward Diagonal in an Arraylist (matrix). Java Program to …

C Program to search an element in an array using Pointers

A separate function( search_function()) will be created where the array pointer will be declared and the searched element along with the size of an array …

C Program to find the sum of the digits of a number using recursion function

This C program calculates the sum of digits of a given number using recursion. Here’s a concise explanation: Function Definition: sumDigits(int n) This function calculates …

C program to find factorial of a numberĀ using Ternary operator with Recursion

Recursion refers to the function calling itself directly or in a cycle. Before we begin, you should have the knowledge of following in C Programming: …

C Program to Add Two Numbers Using Call by Reference

The program takes the two numbers from the user and passes the reference to the function where the sum is calculated. You may go through …

Find the output ab, cd, ef, g for the input a,b,c,d,e,f,g in Javascript and Python

In this tutorial, we will write a program to find a pairs of elements from an array such that for the input [a,b,c,d,e,f,g] we will …