Thursday, December 28, 2017

Check Whether Enter Number Is Palindrome Or Not

Hello Friends My Name Is Viraj,Today I Will  Check Whether Enter Number Is Palindrome Or Not On Your Web Page. Check Whether a Number is Palindrome or Not. This program reverses an integer (entered by the user) using while loop. Then, if statement is used to check whether the reversed number is equal to the originalnumber or not.This program reverses an integer (entered by the user) using while loop. Then, if statement is used to check whether the reversed number is equal to the original number or not.Write a C program to input number from user and check number is palindrome or not using loop. How to check whether a number is palindrome or not using loop in C programming. Logic to check palindrome number in C programming.Let the given number be num. A simple method for this problem is to first reverse digits of num, then compare the reverse of num with num. If both are same, then return true, else false.Following is an interesting method inspired from method#2 of this post. The idea is to create a copy of num and recursively pass the copy by reference, and pass num by value. In the recursive calls, divide num by 10 while moving down the recursion tree. While moving up the recursion tree, divide the copy by 10. When they meet in a function for which all child calls are over, the last digit of num will be ith digit from the beginning and the last digit of copy will be ith digit from the end.Here In This Html Tutorial We Will Check Whether Enter Number Is Palindrome Or Not.


Here Is An Example Related To Topic Are....

Step 1 :

<html>
<head>
<body>
enter number<input type="text" id="num11">
<button onclick="data()">click</button>
<script>
function data()
{
var rev=0,rem=0,num2=0,num1;
num1=parseInt(num11.value);
num2=num1;
while(num1>0)
{
rem=num1%10;
rev=rev*10+rem;
num1=parseInt(num1/10);
}
if(rev==num2)
{
document.write("It is a palindrome");
}
else
{
document.write("It is not a palindrome");
}
}
</script>
</body>
</head>
</html>

Output :




3 comments:

How To Create Image Gallery In Html

Hello Friend My Name Is Viraj,Today I Will Create Image Gallery And Display On A Webpage.The emergence of CSS3 technology has enabled web d...