top of page

A Java program that will check if a number is palindrome or not

  • Writer: Nelson John
    Nelson John
  • Nov 27, 2017
  • 1 min read

import java.util.Scanner;

public class JavaProgram

{

public static void main(String args[])

{

int num, rem, orig, rev=0;

Scanner scan = new Scanner(System.in);

System.out.print("Enter a Number : ");

num = scan.nextInt();

orig = num;

while(num != 0)

{

rem = num%10;

rev = rev*10 + rem;

num = num/10;

}

// check if the original number is equal to its reverse

if(rev==orig)

{

System.out.print("This is a Palindrome Number");

}

else

{

System.out.print("This is not a Palindrome Number");

}

}

}

Facebook: ayamnelrodinho1@gmail.com

Yahoo: talk2nelsonjohn2dat@yahoo.com

Whatsapp: +2349034595610

PLEASE KINDLY SHARE WITH FELLOW PROGRAMMERS AND ALSO SUBSCRIBE TO MY BLOGs PAGE FOR MORE FEEDS.


 
 
 

Comentarios


bottom of page