C program to check palindrome number or not

Check Palindrome Number

C program to check palindrome number or not

A number can be called as a palindrome only if the reverse of that number is equal to the original one.
Here, we will learn to check whether the number entered by the user is a palindrome or not.

#include <stdio.h>
#include<conio.h>
void main() {
    int num, revNum = 0, rem, origNum;
    //clrscr();
//printf("\n...Welcome To EduNews.Tech... ");
    printf("\n\nEnter an integer: ");
    scanf("%d", &num);
    origNum = num;
    // reversed integer is stored in revNum
    while (num != 0) {
    rem = num % 10;
    revNum = revNum * 10 + rem;
    num /= 10;
    }
    // palindrome if origNum and revNum are equal
    if (origNum == revNum)
    printf("%d is a palindrome.", origNum);
    else
    printf("%d is not a palindrome.", origNum);
  printf("\n\n\n\n\t\t\tThankyou for Joining Us !");
  printf("\n\t\t\t!Regards EduNews !");
   
    getch();
}

Program Output:

palindrome Number

Here, the user is asked to enter an integer. The number is stored in variable num.
Then we assigned this number to another variable origNum. Then, the reverse of num is found and stored in revNum.
If origNum is equal to revNum, Then we can say that the number entered by the user is a palindrome.

I hope this post helps you to understand Palindrome number and its implementation in C programming language.

Keep coding 🙂

3 thoughts on “C program to check palindrome number or not”

Leave a Reply

Your email address will not be published. Required fields are marked *