Home >>c programs >Palindrome program in C

Palindrome program in C

Palindrome program in C

A Palindrome numberis a number that resembles as same while reading them from backward also are called palindrome . It is a number that is remains the same on reverse.

If you want to know that a number is palindrome or not then, we reverse it and compare it with the original number, if both the numbers are same after reverse, it’s a palindrome.

For example- 121, 3773, level, etc. Let's take an example of Palindrome Number:

#include<stdio.h&t;  
int main()    
{    
	int num,rem,sum=0,temp;    
	printf("Enter Your number=");    
	scanf("%d",&num);    
	temp=num;    
	while(num>0)    
	{    
	rem=num%10;    
	sum=(sum*10)+rem;    
	num=num/10;    
	}    

	if(temp==sum)    
	{
	printf("Given Number is Palindrome "); 
	}   
	else
	{    
	printf("Given Number is not Palindrome");   
	}
	return 0;  
}   
Output :
Enter Your number=123
Given Number is not Palindrome
Output :
Enter Your number=121
Given Number is Palindrome

No Sidebar ads