Palindrome Number Program In JavaScript

Palindrome Number Program In JavaScript

Palindrome Number Program In JavaScript is the today topic of discussion in this tutorial.

Let’s say the number we want to check palindrome is 16461

There would be 5 iterations because the size of the number consists of 5 digits

Flowchart of Palindrome Number

flowchart of palindrom number javascript

Figure: Flowchart of palindrome number javascript

Begin

 

JavaScript Palindrome Number Program

Palindrome Javascript JS

End

After 5 iterations are completed the remainder is actually reversed number which is a palindrome.

Note that the negative numbers are not a palindrome. A single-digit is also a palindrome because when a digit is reversed it remains the same.

Program of Palindrome In JavaScript

Program of Palindrome In JavaScript is mentioned below.

Output

How to find palindrome JS

Pseudo Code of Palindrome Number Program In JavaScript

Display heading Enter a positive integer number
Display a text box
Display a Check button
When user click Check button call function CheckPalindrome()
In CheckPalindrome() function
Declare a variable inputNumber
Declare a variable holdNumber
Declare a variable reverseNumber
Declare a variable rem=0 for remainder initialized with value of 0
Assign value of textbox to inputNumber
Put inputNumber value in holdNumber
Run a for loop
for(;inputNumber != 0;)
{

reverseNumber = parseInt(inputNumber  % 10);

inputNumber = parseInt(inputNumber  / 10);

rem = rem * 10 + reverseNumber;

reverseNumber = rem;

}
if(holdNumber = = reverseNumber)

Display, Input Number Is Palindrome in a heading of html tag h3

else

Display, Input Number Is Not Palindrome in a heading of html tag h3

 

 

Latest posts by Prof. Fazal Rehman Shamil (see all)

Buy advertisement space on T4Tutorials

For more details email [email protected]