Computer Science, asked by Anonymous, 1 year ago

write a program to input a number and checking whether it is a palindrome no or not

Answers

Answered by siddhartharao77
33

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!


siddhartharao77: ok
Answered by BarshitSahuJi
2

Answer:

This is the simple Java program.

Attachments:
Similar questions