Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

Develop a java program to find the reverse of a number and check whether the given number is palindrome or not

import java.util.*;
class Example
{
	public static void main(String[] args)
	{
		int n,rev=0;
		int num;
		int x;
		

		Scanner s=new Scanner(System.in);
		System.out.println("enter the number");
		n=s.nextInt();

		x=n;

		while(n!=0)
		{
			num=n%10;
			rev=rev*10+num;
			n=n/10;
		}

		System.out.println("the reverse is"+" "+rev);
		if(x==rev)
		{
			System.out.println("number is palindrome");
		}
		else
		{
			System.out.println("number is not palindrome");
		}
	}
}

Output

img

About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 Previous