#include<stdio.h>
#include<conio.h>
/* Function Declaration
int pal(int x); */
/*Declaring Second Function*/
int rev(int x);
int main()
{
int a, b, c;
clrscr();
printf("Enter The Number Which You Want To Check Is Palindrome Or Not\n");
scanf("%d", &a);
b = rev(a);
printf("%d", b);
if(b == a) {
printf("%d Is A Palindrome Number", a);
} else {
printf("%d Isn't A Plaindrome Number", a);
}
getch();
return(0);
}
int rev(int x)
{
int d = 0;
while(x) {
d = d * 10 + x % 10;
x = x / 10;
}
return(d);
}
I didn't get the use of while(x)
statement. I mean, we attach some condition with while loop i.e. while(x!=0)
, so what does standalone while(x)
means.