Write a program to check whether a given number is a
palindrome or not?

Answers were Sorted based on User's Feedback



Write a program to check whether a given number is a palindrome or not?..

Answer / upendar

This Script checks the given number as well as string is palindrome or not


<html>
<body>
<script type="text/javascript">
function checkPalindrome() {
var revStr = "";
var str = document.getElementById("str").value;
var i = str.length;
for(var j=i; j>=0; j--) {
revStr = revStr+str.charAt(j);
}
if(str == revStr) {
alert(str+" -is Palindrome");
} else {
alert(str+" -is not a Palindrome");
}
}
</script>
<form >
Enter a String/Number: <input type="text" id="str" name="string" /><br />
<input type="submit" value="Check" onclick="checkPalindrome();"/>
</form>
</body>
</html>

Is This Answer Correct ?    437 Yes 107 No

Write a program to check whether a given number is a palindrome or not?..

Answer / srikanth

malayalam

Is This Answer Correct ?    119 Yes 45 No

Write a program to check whether a given number is a palindrome or not?..

Answer / riddhi

<html>
<head>
<script language="Javascript">
var a;
</script>
<title> Number Palindrom </title>
</head>
<body>
<script Language="Javascript">
var rno=0;
var r=0;
var no = prompt("Enter First no: ","10");
var ono = parseInt(no);
while (no>0)
{
r = parseInt(no%10);
rno = parseInt((rno*10)+r);
no = parseInt(no/10);
}
document.write(rno);
if(rno == ono)
{
document.write(ono+" is palindrom number..");
}
else
{
document.write(ono +" is not palindrom number..");
}
</script>
</body>
</html>

Is This Answer Correct ?    72 Yes 39 No

Write a program to check whether a given number is a palindrome or not?..

Answer / dk

<html>
<body>
<script type="text/javascript">
var n,n1,s,d;
n=prompt('Enter a Number.');
n1=n;
s=0;
while(n!=0)
{
d=n%10;
n=(n-d)/10;
s=(10*s)+d;
}
if(s==n1)
document.write(n1+" is a palindrome");
else
document.write(n1+" is not a palindrome");
</script
</body>
</html>

Is This Answer Correct ?    36 Yes 8 No

Write a program to check whether a given number is a palindrome or not?..

Answer / praveen

12121

Is This Answer Correct ?    21 Yes 4 No

Write a program to check whether a given number is a palindrome or not?..

Answer / ss

1221

Is This Answer Correct ?    28 Yes 13 No

Write a program to check whether a given number is a palindrome or not?..

Answer / sharma v

num=InputBox ("Enter a number")
z=num
r=0
While(num>0)
rem1=num mod 10
num=num\10
r=(r*10) + rem1

Wend

If (r=z)Then
Msgbox "Given no is palindrome"
else
Msgbox "Given no. is not palindrome"

End If

Is This Answer Correct ?    23 Yes 17 No

Write a program to check whether a given number is a palindrome or not?..

Answer / ankita

//Program to check the given number is palindrome or not//


<html>
<head>
<script language="javascript">
var num,n,rev=0,r;
num=prompt("Enter the number");
n=num;
while(parseInt(num)>0)
{
r=parseInt(num)%10;
rev=parseInt(rev)*10+parseInt(r);
num=parseInt(num)/10;
}
if(rev==parseInt(n))
document.write(n+ " is a palindrome number");
else
document.write(n+ " is not a palindrome number");
</script>
</head>
<body>
</body>
</html>

Is This Answer Correct ?    8 Yes 2 No

Write a program to check whether a given number is a palindrome or not?..

Answer / renuga devi

mam,16061

Is This Answer Correct ?    6 Yes 3 No

Write a program to check whether a given number is a palindrome or not?..

Answer / kamal kumar

<script>
function bon()
{
var y="";
var j= document.getElementById("ty").value;
var k = j.split('');
for(var l= k.length; l>0; l--)
{
y+=k[l-1];
}
if(j==y)
{
alert("This is Palidrome");
}
else
{
alert("This not Palidromn");
}
}
</script>
<body>
<input type="number" id="ty">
<button onclick=" bon()"> Come On!</button>
</body>

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More JavaScript Interview Questions

How you will write a java script function that display an alert on the screen?

1 Answers   Cap Gemini,


wap to accept an int array frm the user and print the lucky nos.

0 Answers  


What is external javascript?

0 Answers  


What is a function object?

0 Answers  


how to hide alphabets in java as password '*'

0 Answers  






How host objects are different from native objects in javascript?

0 Answers  


What is the naming conventions for the variables in javascript?

0 Answers  


What is a name function in javascript & how to define it?

0 Answers  


What is new keyword in javascript?

0 Answers  


How to call a function in every x seconds in javascript?

0 Answers  


Is javascript case sensitive?

0 Answers  


Why do you need javascript?

0 Answers  


Categories