Write a C program to input number from user and check number is palindrome or not using while loop.
#include<stdio.h>
int main()
{
int number,r,sum=0,temp;
printf("Enter the number: ");
scanf("%d",&number);
temp=number;
while(number>0)
{
r=number%10;
sum=(sum*10)+r;
number=number/10;
}
if(temp==sum){
printf("The number is a palindrome");
}else{
printf("The number is NOT a palindrome");
}
getchar();
getchar();
return 0;
}
Comments
Leave a comment