Tuesday, March 5, 2024

16. Input a number and check it is palindrome or not :—


16. Input a number and check it is palindrome or not :—


#include<stdio.h>

int main()

{

    int r,n,k,rev;

    printf("enter a number ");

    scanf("%d",&n);

    k=n;

    rev=0;

    while(k>0)

    {

        r=k%10;

        k=k/10;

        rev=rev*10+r;

    }

    if(n==rev)

    {

        printf("%d is a palindrome",n);

    }

    else

    {

        printf("%d is not a palindrome",n);

    }

    return 0;

}


No comments:

Post a Comment