Computer Science, asked by pratik7285, 1 year ago

write a program to check if the given number is a palindrome number​

Answers

Answered by ankury23
0
Program is in very simple way.
If like this answer tag to branliest answer
Attachments:
Answered by stylishtamilachee
2

Answer:

import java.util.Scanner ;

public class Palindrome

{

public statis void main (String args[ ] )

{

Scanner sc = new Scanner (System.in) ;

System.out.print("Enter a number to be checked : ") ;

int number = sc.nextInt( ) ;

int reversedNumber = 0, temp = 0, savedNumber ;

savedNumber = number;

do {

temp = number % 10 ;

number = number / 10 ;

reversedNumber = reversedNumber * 10 + temp ;

} while (number! = 0) ;

if ( reversedNumber = = savedNumber)

System.out.println(savedNumber + "is a palindrome") ;

else

System.out.println(savedNumber + "not a palindrome") ;

}

}

Ouput:

Enter a number to be checked : 1221

1221 is a palindrome

Palindrome:

A palindrome reads the same from both sides,

Eg: 1331 is a palindrome number

Similar questions