Write a Program to check a number Palindrome or not by using while and if Statement

Engg.... | 06:31 | | Best Blogger Tips
Palindrome Number

Palindrome Number:
  • Palindrome Number is a Symmetrical Number.
  • In simple words, Palindrome Number is a number that remains the same when its digits are Reversed.
  • Examples: 101, 141, 16461, 121 etc.
Statement of C program: Enter a number and check it is palindrome or not:

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d;
clrscr();
printf(" Enter a three digit number\n");
scanf("%d" , &a);
c=0;
d=a;
while(a>0)
{
b=a%10 ;
c=(c*10)+b ;
a=a/10;
}
if(c==d)                                                /*  == Equality Operator  */
{
printf(" Number Is palindrome ");
}
else
{
printf(" Number is not palindrome ");
}
getch();
}

 Output1:
 Enter a three digit number
 121
 Number is palindrome

 Output2:
 Enter a three digit number
 456
 Number is not palindrome


Please Share it! :)
Do you like this Story?

Get Free Email Updates Daily!

Follow us!

1 comment: