C Program to Check Given Number is Palindrome or Not

C Program to Check Given Number is Palindrome or Not

Write a Program to Check Given Number is Palindrome or Not

// C Program to Check Given Number is Palindrome or Not

#include <stdio.h>

int palindrome(int n)
{
	static int ans=0;
	if(n <= 0)
	{
		return ans;
	}

	int remainder = n % 10;
	ans = ans * 10 + remainder;

	palindrome(n / 10);
	return ans;

}
int main()
{
	int n;
	printf("Enter Number :--> ");
	scanf("%d", &n);

	int temp = palindrome(n);

	if(temp == n)
	{
		printf("Number is Palindrome");
	}
	else
		printf("Number is not Palindrome");

	return 0;
}

Output:

Run 1:
Enter Number :--> 121
Number is Palindrome

Run 2:
Enter Number :--> 1234
Number is not Palindrome