Palindrome or not using C
Write a C program to find number is Palindrome or not
A palindrome number is a number that is given the same number after reverse. In C programs to check if the input number is palindrome or not. We are using while loop and else if statement in C Program.
- A number is 123321 .If you read number “123321” from reverse order, it is same as “123321”.
In that number is a palindrome.
- A number is 12121. If we read number “12121” from reverse order ,it is same as 12121. It is also a palindrome number
Step 1.Take the number which you have to reverse and find palindrome as the input variable says number.
Step 2.Number is stores in his duplicity value as a duplicate variable (n1).
Step 3.Obtain its quotient and remainder.
Step 4.Multiply the separate variable with 10 and add the obtained remainder to it.
Step 5.Do step 2 again for the quotient and step 3 for the remainder obtained in step 4.
Step 6.Then we check if reverse is equal to a number.
Step 7.Its true display number is palindrome
Step 8.It is false display number is not a palindrome.
//Initialization of variables where rev='reverse=0'
int number, rev = 0,store, n1,left;
//input a numbers for user
printf("Enter the number\n");
//for duplicacy of number
//use this loop for check true condition
while (number > 0)
//left is for remider are left
//for reverse of no.
rev = rev * 10 + left;
//number /= 10;
//To check reverse no is a Palindrome
printf("Number %d is Palindrome number",n1);
printf("it is not a Palindrome number");
Enter the number
Number 121121 is Palindrome number.