WAP to check if 997 is a palindrome number or not
Answers
Answered by
2
This is the answer, hope it helps
Attachments:
Answered by
1
Answer:
import java.util.*;
class Palindrome
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter a number");
int num=sc.nextInt();
int reversedno = 0, remainder, originalno;
originalno = num;
while( num != 0 )
{
remainder = num % 10;
reversedno = reversedno * 10 + remainder;
num /= 10;
}
if (originalno == reversedno)
System.out.println(originalno + " is a palindrome.");
else
System.out.println(originalno + " is not a palindrome.");
}
}
Explanation:
Similar questions