Palindrome number using function

Program:

#include<stdio.h>
int ispalindrome(int num);
int main()
{
int n;
printf("Enter Number: ");
scanf("%d",&n);
if(ispalindrome(n)==1)
{
printf("%d is palindrome",n);
}
else
{
    printf("%d is not palindrome",n);
}
    return 0;
}
int ispalindrome(int num)
{
    int rev=0,temp;
    temp=num;
while(num>0)
{
rev=rev*10+num%10;
num=num/10;
}
if(temp==rev)
{
return 1;
}
else
{
        return 0;
}
}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...