Tuesday, April 23, 2013

Function: Check Palindrom number or Not by using function in C

Write a C program to  Check Palindrom number or Not by using function in C

#include<stdio.h>
#include<conio.h>
int rev_check(int n)
{
int rev,temp=0,a=10;
while(n>0)
{
rev=n%a;
n=n/a;
temp=temp*a+rev;
}
return(temp);
}
main()
{
int n;
printf("\nEnter the number: ");
scanf("%d",&n);
if(rev_check(n)==n)
printf("\nThe given number is a palindrome\n");
else
printf("\nthe given number is not a palindrome\n");
}

No comments:

Post a Comment