how to print in java using a do while loop to print palindrome no.
Answers
Answered by
3
Answer:
import java.util.*;
class palindrome
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n,rev=0,sum=0,m;
System.out.println("Enter a number");
n=sc.nextInt();
m=n;
while(n>0)
{
rev=n%10;
sum=sum*10+rev;
n=n/10;
}
if(n==m)
System.out.println("Palindrome number");
else
System.out.println("Non-palindrome number");
}
}
Explanation:
Similar questions