Sunday, September 4, 2016

Java Program To Check whether string is palindrome or not


import java.util.Scanner;

public class Palindrome {

public static void main(String[] args)
{

 System.out.println("Please Enter a number : ");

        int givennumber = new Scanner(System.in).nextInt();

        int number=givennumber;
        int reverse=0;

        while (number != 0) {

            int remainder = number % 10;
            reverse = reverse * 10 + remainder;
            number = number / 10;
        }            

 if(givennumber == reverse)
   System.out.println("Result:Palindrome");
    else
    System.out.println("Result:Not Palindrome");

    }
}

Bhanu Namikaze

Author & Editor

Bhanu Namikaze is an Ethical Hacker, Passionate Blogger, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors, Surfing and Social Networking. Feel Free To Contact Me @ Bhanu.

0 comments:

Post a Comment

Popular Posts

Copyrights @ Interview Questions.Me - Blogger Templates Designed by Templateism - Distributed By Protemplateslab

  • (91) 5544 654942
  • Bhanu@HackingDream.net
  • Interview Questions

Copyrights @ Interview Questions.Me -A Site By Bhanu In Association With Hacking Dream