Palindrome Program in C | Palindrome String Program in C
1. Palindrome program Using while loop
In this program we will ask user to input a number which user wants to check whether the given number is palindrome or not.
Output:

Here the user enters the number and the number is stored in the variable n. Then the number is assigned to the variable originalN and the reverse variable is stored in the reversedN.
If the reversedN is equal to originalN then the given number is Palindrome otherwise, the number is not Palindrome.
2. Program to check given String is Palindrome
In this program we will put some string in the function then the program will check whether the string is Palindrome or not.
Output:

3. Check Palindrome Using Recursion
In this program we will check whether the given number is palindrome or not in C using Recursion Concept.
Output:

In recursion the function calls itself again and again.In above program while executing when the compiler will reach to the Reverse_Integer, then the compiler will jump to Reverse_Integer function.
If(Number>0) checks whether the number is 0 or not.It is essential to declare before recursive function otherwise the program will start executing infinite number of times.
4. Recursion Using For loop
In this program we will use for loop instead of while loop. Don’t be afraid the logic is same only the loop is changed.
Output:

In above program when the user enters the number, the program first reverse the number and then check whether the number is palindrome or not.
5. Palindrome Using Functions
In this program we will use function to check whether the entered number is Palindrome or not.The function Reverse_Integer is used for checking.
Output:

6. Program to find Palindrome numbers between 1 to 1000
This program is very excellent. In this program we have to enter the minimum and maximum three digit number. Then, the program will print all the palindrome numbers between minimum and maximum number.
Output:

In this program the for loop restrict the compiler to repeat the iterations between maximum and minimum number. And thus prints all the Palindrome number between them. Only if Number==Reverse
Post a Comment