Thursday, July 4, 2019

palindrome or not....in c language

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

No comments:

Post a Comment

python class topic video