palindrome number in java explain??
Answers
Answered by
2
hey mate ur answer is
⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇
Palindrome number in java: A palindrome number is a number that is same after reverse. For example-:
input-121
output-121
PROGRAM
class PalindromeExample{
public static void main(String args[]){
int r,sum=0,temp;
int n=454;//It is the number variable to be checked for palindrome
temp=n;
while(n>0){
r=n%10; //getting remainder
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum)
System.out.println("palindrome number ");
else
System.out.println("not palindrome");
}
}
⬇⬇⬇⬇⬇⬇⬇⬇⬇⬇
Palindrome number in java: A palindrome number is a number that is same after reverse. For example-:
input-121
output-121
PROGRAM
class PalindromeExample{
public static void main(String args[]){
int r,sum=0,temp;
int n=454;//It is the number variable to be checked for palindrome
temp=n;
while(n>0){
r=n%10; //getting remainder
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum)
System.out.println("palindrome number ");
else
System.out.println("not palindrome");
}
}
Anonymous:
sorry i can't
Answered by
3
Palindrome number : If the numbers remains same even if we reverse its digits.
Ex: 121, 131, 111, .....
Sample program for palindrome number:
import java.util.*;
class Basic
{
public static void main(String[] args)
{
int a,b=0,c,d;
Scanner demo = new Scanner(System.in);
System.out.println("Enter a number: ");
a = demo.nextInt();
d = a;
while(a > 0)
{
c = a%10;
b = (b * 10) + c;
a = a/10;
}
if(d == b)
{
System.out.println("Entered number is a palindrome");
}
else
{
System.out.println("Entered number is not a palindrome");
}
}
}
Output:
Enter a number : 153
Entered number is not a palindrome.
Enter a number : 121
Entered number is a palindrome
Hope it helps!
Similar questions