write a Java Program to check whether it is a palindrome number or not through for loop
Answers
Answered by
0
pls refer the attachment
Attachments:
Answered by
0
\\ java program to find the number is palindrome or not
import java.util.*;
public class Palindrome
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int n,num,ri=0,r=0;
System.out.println("Enter the number:");
n=in.nextInt();
num=n;
for (;num!=0;)
{
r=num%10;
ri *= 10+r;
n=n/10;
}
System.out.println("Reversed number=" +ri);
if (num==ri)
{
System.out.println(num+ " is a palindrome number.");
}
else
{
System.out.println(num+ "is not a palindrome number");
}
}
}
hope it's helpful to you :)
--------Miss Solitary-------
Similar questions