Computer Science, asked by skluvyaffs, 5 months ago

Use the while loop to write a program to input a number from the user and
check if it is a palindrome number.(A palindrome number is a number that is
same after reverse. For example 545, 151, 34543, 343, 171, are the palindrome
numbers.)​

Answers

Answered by anirudhkp2004
3

Doubt:

Not sure which language you are asking but here is the Python Code <3

MyMethod:

#!/usr/bin/python3

user = input("enter the number:")

reverse = user[::-1]

if reverse = user:

    print(f"{reverse} is a palindrome number !")

else:

  print("Not a palindrome number")

------------------------------

NOTE: I didn't use a loop here as I think taking input as string and just reversing it with list slicing method is more efficient and easy to understand .

with while loop:

```

n=int(input("Enter number:"))

temp=n

rev=0

while(n>0):

   dig=n%10

   rev=rev*10+dig

   n=n//10

if(temp==rev):

   print("The number is a palindrome!")

else:

   print("The number isn't a palindrome!")

```

Always rely on easier one because understanding is important.

Thankyou ! Mark brainliest as well if you are satisfied with this answer !

Similar questions