Computer Science, asked by raza3547, 1 year ago

Determine whether an integer is a palindrome. do this without extra space.

Answers

Answered by nitish8089
0

import java.util.Scanner;

public class Program

{

   public static void main(String[] args) {

       Scanner sc=new Scanner(System.in);

       int a=sc.nextInt();

       int temp=a;

       int place=-1;

       while(temp>0){

           place++;

           temp/=10;

       }

       temp=a;

       int reverse_number=0;

       do{

           int x=temp%10;

           reverse_number+=(x*(int)Math.pow(10, place));

           temp/=10;

           place--;

       }while(temp>0);

       if(reverse_number==a)

       System.out.println(a +" is a palindromic number ");

       else{

       System.out.println(a +" is not a palindromic number ");}

   }

}

Similar questions