To check whether the given number is palindrome or not

 Program:


#include<stdio.h>
#include<conio.h>
void main()
{
    int n, m, rev=0;
    printf("Enter any Number : ");
    scanf("%d", &n);
    m=n;
    while(m>0)
    {
        rev=(rev*10)+(m%10);
        m=m/10;
    }
    if(n==rev)
        printf("Given Number is Palindrome");
    else
        printf("Given Number is not Palindrome");
    getch();
}

Output:

Ex-1:
Enter any Number : 242
Given Number is Palindrome

Ex-2:
Enter any Number : 245
Given Number is not Palindrome

Ex-3:
Enter any Number : 42624
Given Number is Palindrome




Next Topic        :  

Previous Topic :

No comments:

Post a Comment