pseudocode to check whether a number is a palindrome
Answers
Answered by
10
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!")
Program Explanation :
- User must first enter the value of the integer and store it in a variable.
- The value of the integer is then stored in another temporary variable.
- The while loop is used and the last digit of the number is obtained by using the modulus operator.
- The last digit is then stored at the one’s place, second last at the ten’s place and so on.
- The last digit is then removed by truly dividing the number with 10.
- This loop terminates when the value of the number is 0.
- The reverse of the number is then compared with the integer value stored in the temporary variable.
- If both are equal, the number is a palindrome.
- If both aren’t equal, the number isn’t a palindrome.
- The final result is then printed.
Hope it helps :)
Answered by
2
Answer:
❤ANSWER ❤
- Declare two variables: one stores the given number, and the other stores the reversed number.
- Run the do-while loop until the number of digits in the reversed number are equal to the number of digits in the given number. ...
- Check if the reversed number is equal to the given number.
Explanation:
It's Pandit Manish.... xd....
Similar questions
Social Sciences,
3 months ago
CBSE BOARD X,
3 months ago
English,
3 months ago
Social Sciences,
6 months ago
Computer Science,
6 months ago
Hindi,
11 months ago
Chemistry,
11 months ago