Palindrome Number


/* Reversing given number & checking palindrome – Example for ’while loop’*/

#include<stdio.h>

#include<conio.h>

void main()

{

int  rev=0,n,num,digit;

clrscr();

printf(“\n Enter the number:”);

scanf(“%d”,&n);

num=n;

while(n!=0)

{

digit=n%10;

rev=(rev*10)+digit;

n=n/10;

}

printf(“ \n The Reversed Number is %d “,rev);

if(rev = = num)

printf(“\n The Number is Palindrome “);

else

printf(“\n The Number is not a Palindrome “);

getch();

}

Advertisements