Write a program in C to check whether the number is a Palindrome number or not

By | July 14, 2019

Here in this program, we will code to check whether an entered number is a palindrome number or not.

What is a Palindrome number?

A palindrome number is a special number because it remains the same when its digit gets reversed.

For example, 16461 is a palindrome number if you reverse this number still, we get 16461.

By default, all the 1-digit numbers are palindrome numbers.

Statements we will use in this program

  • While loop
  • % (arithmetic modules)
  • If…else statement

Logic

  • First, we will ask the user to enter a number
  • Then using a while loop we will try to reverse the entered number using % and other athematic operation
  • At last, we will compare the reversed number with the entered number
  • If the number match, we will print the number is a palindrome if not we print its not a palindrome number.

Palindrome Program in C

#include<stdio.h>
#include<conio.h>
void main()
{
int num,x, y=0,rev;
clrscr();
printf("Enter a Number: ");
scanf("%d",&num);
rev= num;
while(rev!=0)
  {
   x= rev%10;
   y=x+(y*10);
   rev=rev/10;
   }

if(num==y)
                printf("%d is a palindrome number",num);
else
                printf("%d is not a palindrome number",num);
getch();

}

Output:

Enter a Number: 14641
14641 is a palindrome number

People Also Looking For:

Category: C Program Tags:

About Paridhi Joshi

Paridhi Joshi is an expert web content manager with significant experience in content creation. Professionally she is dedicated to staying up to date with the latest trends and technologies in content writing and committed to bringing state-of-the-art web approaches to the workplace. She is an efficient multi-tasker who can complete multiple projects under strict deadlines.

Leave a Reply

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