Sunday 2 April 2017

PROGREM TO CHECK WHETHER THE GIVEN NUMBER IS PALINDROME OR NOT

The below is the sample program to check if the given number is Palindrome or not.

#include<stdio.h>
int main()
{
int num,ornum;
printf("Enter a number");
scanf("%d",&num);
ornum=num;
while(num!=0)
{
rem=num%10;
rev=rev*10+num;
num=num/10;
}
if(rev==ornum)
{
printf("The number is palindrome");
}
else if(rev!=ornum)
{
printf("The number is not palindrome");
}
}

The above program uses while loop too compute the expression and to find out whether the number entered is palindrome or not.

No comments:

Post a Comment