# Program to Display Palindrome

## Palindrome of Given Number

We will write a C program to display the palindrome of the given number and the number will be entered by the user. This will help to understand the basic structure of programming. In this program , we will display the palindrome number of given numbers easily by using proper syntax and algorithms. ## Working of Program :

In the program, we will require some numbers from the user to display the palindrome number of the given numbers.

### Important Note for Palindrome:

• In palindrome number, the number will always be same after reversing that numbers.
For example: 323, 4554, 989, 78987…

### Problem 1

Write a program to display that the given number is palindrome or not by using while() loop.

• Firstly, we have to enter the any number.
• Then print that number is  palindrome or not.

### Code

Run

```#include<stdio.h>
int main ()
{
int n, r, rev = 0, a;
printf ("Enter the numer = ");
scanf ("%d", &n);
a = n;
while (n > 0)

{
r = n % 10;
rev = (rev * 10) + r;
n = n / 10;
}
if (a == rev)
printf ("The number is a palindrome number. ");

else
printf ("The number is not a palindrome.");
return 0;
}

```

### Output

```Enter the numer = 454
The number is a palindrome number.
```

### Note:

In the following program we will display the palindrome of the given number using do-while() loop.

### Syntax for do – while() loop:

```do
{
// Statements
// Increment / Decrement
}
while(condition)
```
```Problem 2
```

Write a program to display that the given number is palindrome or not by using do – while() loop.

• Firstly, we have to enter the any number.
• Then print that number is  palindrome or not.

### Code

Run
```#include<stdio.h>
int main ()
{
int n, r, rev = 0, a;
printf ("Enter the numer = ");
scanf ("%d", &n);
a = n;
do
{
r = n % 10;
rev = (rev * 10) + r;
n = n / 10;
}
while (n > 0);
if (a == rev)
printf ("The number is a palindrome number. ");

else
printf ("The number is not a palindrome.");
return 0;
}
```

### Output

```Enter the numer = 1234
The number is not a palindrome.
```

### Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

## Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others