JavaScript
Cookies in JavaScript: Set, Get & Delete Example
What are Cookies? A cookie is a piece of data that is stored on your computer to be accessed by...
A Palindrome Number is a number that even when reversed is same as original number
Examples of Palindrome Number
121, 393, 34043, 111, 555, 48084
Examples of Palindrome Number
LOL, MADAMProgram Logic
package com.gtupapers;
public class PalindromeNum {
public static void main(String[] args)
{
int lastDigit,sum=0,a;
int inputNumber=171; //It is the number to be checked for palindrome
a=inputNumber;
// Code to reverse a number
while(a>0)
{ System.out.println("Input Number "+a);
lastDigit=a%10; //getting remainder
System.out.println("Last Digit "+lastDigit);
System.out.println("Digit "+lastDigit+ " was added to sum "+(sum*10));
sum=(sum*10)+lastDigit;
a=a/10;
}
// if given number equal to sum than number is palindrome otherwise not palindrome
if(sum==inputNumber)
System.out.println("Number is palindrome ");
else
System.out.println("Number is not palindrome");
}
}
Input Number 171 Last Digit 1 Digit 1 was added to sum 0 Input Number 17 Last Digit 7 Digit 7 was added to sum 10 Input Number 1 Last Digit 1 Digit 1 was added to sum 170 Number is palindrome
What are Cookies? A cookie is a piece of data that is stored on your computer to be accessed by...
How to read a file in Java? Java provides several mechanisms to read from File. The most useful...
What is ArrayList in Java? ArrayList in Java is a data structure that can be stretched to...
What is Reflection in Java? Java Reflection is the process of analyzing and modifying all the...
JavaScript is the most popular client-side scripting language supported by all browsers. It is...
What is JDK? JDK is a software development environment used for making applets and Java...