Program to check Palindrome or not

0 Suresh Chand June 2, 2021

In this example, We will learn a program to check Palindrome. We will check a number whether it is palindrome or not.

Palindrome Number is a number whose inverse is equal to the original number. Below number is a palindrome number.

151, 232, 1221 are palindrome numbers.
Download Application: Learn C Programming with Live Compiler

To understand this example, You must have knowledge in following topics


The algorithm of program to check whether number is palindrome or not is given below

Step 1: Start

Step 2: Initialize the variables a, b, c, s = 0

Step 3: Take input from user and assign to a

Step 4: c = a

Step 5: Repeat this STEP if a > 0

           Step 5.1: b = a % 10

           Step 5.2: s = ( s * 10 ) + b

           Step 5.3: a = a / 10

Step 6: IF (s == c) THEN

           Step 6.1: Number is a palindrome

Step 7: ELSE

           Step 7.1: Number is not a palindrome

Step 8: End


The flowchart of program to check whether number is palindrome or not is given below

Flowchart : Program to check Palindrome or not

CODE: Program to Check Palindrome

Now, We will look on the code to check palindrome.


void main(){
    int a, b, c, s = 0;
    printf("Enter a number:\t");
    scanf("%d", &a);
    c = a;

    // the number is reversed inside the while loop.
    while(a > 0){
        b = a % 10;
        s = ( s * 10 ) + b;
        a = a / 10;

    // here the reversed number is compared with the given number.
    if(s == c)
        printf("%d is a palindrome", c);
        printf("%d is not a palindrome", c);

The output of above program is

Enter a number: 151
151 is a palindrome

Enter a number: 12
12 is not a palindrome
Notify of
Inline Feedbacks
View all comments

Join Our Newsletter Now

Get the latest tutorials, examples and projects updates.



Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Disable Ad Block

Want Same System