Computer Science, asked by heet2910, 1 year ago

write a java program to find palindrome number.

Answers

Answered by superboy123
6
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    


ohmico: Good answer
superboy123: thank you
superboy123: plrase follow me
Answered by nishanth69
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