Palindrome Number Program in C

In this section you will learn how to make palindrome number program in c. We will use while loop condition to perform palindrome number check operation.

Palindrome Number Program

What is palindrome number?

A palindrome number is a number such that if you reverse it, it will not change. The number should be remain same. To check whether a number is palindrome or not first we reverse it and then compare the number obtained with the original, if both are same then number is palindrome otherwise not.

Example of palindrome number.

212, 121, 77077, 11611.

How program will work?

Program of palindrome number in c.


	#include<stdio.h>
	#include<conio.h>
		
	//PALINDROME NUMBER PROGRAM
	void main()
	{
		int n, reverse=0, temp;
		clrscr();
		printf("ENTER A NUMBER TO CHECK PALINDROME OR NOT:- ");
		scanf("%d",&n);
		temp = n;

		while (temp != 0)
		{
			reverse = reverse * 10;
			reverse = reverse + temp % 10;
			temp = temp / 10;
		}
		if (n == reverse)
		{
			printf("ENTER NUMBER IS PALINDROME.");
		}
		else
		{
			printf("ENTER NUMBER IS NOT PALINDROME.");            
		}
			
		getch();
	}
	

Output:


	ENTER A NUMBER TO CHECK PALINDROME OR NOT :- 777
	ENTER NUMBER IS PALINDROME.

Post Your Comment