Write a program to check whether given number is palindrome or not. EX: N= 121, Reverse of N is also 121 so N is Palindrome
Answers
Answered by
1
Answer:
Output
121 is a palindrome number
Explanation:
public class Palindrome {
public static void main(String[] args) {
int num = 121, reversedInteger = 0, remainder, originalInteger;
originalInteger = num;
// reversed integer is stored in variable
while( num != 0 )
{
remainder = num % 10;
reversedInteger = reversedInteger * 10 + remainder;
num /= 10;
}
// palindrome if orignalInteger and reversedInteger are equal
if (originalInteger == reversedInteger)
System.out.println(originalInteger + " is a palindrome.");
else
System.out.println(originalInteger + " is not a palindrome.");
}
}
Similar questions
Computer Science,
2 months ago
English,
2 months ago
English,
2 months ago
Math,
4 months ago
Social Sciences,
4 months ago
Physics,
10 months ago
English,
10 months ago