Palindrome number using while loop
/* Palindrome number using while loop */
#include
int main()
{
int n, s = 0,t;
clrscr();
printf("Please Enter a number: ");
scanf("%d",&n);
t=n;
while (n > 0)
{
s = s * 10;
s = s + n%10;
n = n/10;
}
if(t==s)
printf("Number is Palindrome");
else
printf("Number is not Palindrome");
getch();
}
Output:
No comments:
Post a Comment