Write a program to accept a no. from user and check whether Palindrome or not.
<HTML>
<HEAD><title>Palindrome by kbkashid</title>
<script language='JavaScript'>
function chkpalindrome()
{
var temp,rev=0
var no=parseInt(frm.t1.value)
temp=no
while(no>0)
{
rev=(rev*10)+(no%10)
no=Math.floor(no/10)
}
if(rev==temp)
alert(temp +" Is Palindrome")
else
alert(temp + " Is Not Palindrome")
}
</script>
</HEAD>
<BODY><form name=frm>
Enter A Number:<input type=text name=t1 /><input type=button value='Is Palindrome' onclick="chkpalindrome();">
</form>
</BODY>
</HTML>
thanx
ReplyDeleteis it possible to check the number is palindrome or not without math.floor.my code is some thing like this
ReplyDeletetry no = no.split('').reverse().join();
ReplyDeleteif true than it is palidrome