Friday, May 3, 2019

Write a Program in C to check whether the given number is a palindrome or not.

program:

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

    }
}

output:





No comments:

Post a Comment