belongs to collection: Java Basic Solved Programs
A Palindrome number is a number that remains the same when its digits are reversed.
Like 12321, for example: we take 121 and reverse it, after revers it is same as original number.
SOURCE CODE :
import java.util.Scanner; class Palindrome { public static void main(String[] args) { int a,no,b,temp=0; Scanner s=new Scanner(System.in); System.out.println("Enter any num: "); no=s.nextInt(); b=no; while(no>0) { a=no%10; no=no/10; temp=temp*10+a; } if(temp==b) { System.out.println("Palindrome"); } else { System.out.println("not Palindrome"); } } }
OUTPUT ::
Enter any num: 1221 Palindrome
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
SOURCE CODE :
OUTPUT ::
need an explanation for this answer? contact us directly to get an explanation for this answer