The thread has not been reviewed by Editors yet. Readers are advised to use their best judgement before accessing this thread.

This thread will be reviewed shortly.

If you think this thread contain inappropriate content, please report to

webmaster.

Palindrome number is the number whose individual digits when separated and make cube of these individual digits. Afterwards when these cubes are added together and a number is formed and if this number is exactly equal with original number then we say that given number is palindrome number. 153 is a palindrome number. Let us check it's palindrome property.

153

=(1*1*1) + (5*5*5) +(3*3*3)

=1+125+27

=153

So 153 is a palindrome number.

Let us check it with number 152.

152

=(1*1*1)+(5*5*5)+(2*2*2)

=1+125+8

=134

So 152 and resultant 134 are not equal numbers. Hence 152 is not a palindrome number.

Following is the program to check whether given number is palindrome or not.

Please include stdio.h and conio.h header files before declaration of main function.

//PROGRAM TO CHECK WHETHER GIVEN NUMBER IS PALINDROME OR NOT.

#include

#include

void main(void)

{

int num,s=0,r,m;

clrscr();

printf("Enter any integer number to check palindrome property\n");

scanf("%d",&num);

m=num;

for(num=num;num>0;num=num/10)

{

r=num%10;

s=s+(r*r*r);

}

if(s==m)

{

printf("\nNumber %d is a palindrome number",m);

}

else

{

printf("\nNumber %d is not a palindrome number",m);

}

getch();

}

While checking whether given number is palindrome or not, we have to separate all its individual digits. For this purpose we use statement r=num%10 inside the for loop. This statement divides the num by 10 and give remainder. So in first iteration r=3. Then num=num/10 statement appears and it also divides num by 10 and assign the quotient to num itself. So when num is 153 then after num=num/10, new num is 15. The above procedure goes on till num is greater than zero. Once num becomes less than zero the loop get terminated.

Inside the loop we have added cube of separated individual digit with variable s whose initial value is zero.

We have use variable m to hold initial value of num in the beginning because at the end of the loop value of num becomes zero. For taking decision whether given variable num is palindrome or not we use if statement with variables s and m with comparison operator.