- 3

C++

A palindromic number is a number (such as 626) that remains the same when its digits are reversed. Write a function that returns true if a given number is a palindrome, and false, if it is not. Complete the given function, so that the code in main works and results in the expected output.

7th May 2021, 3:40 AM
GOPI.S
GOPI.S - avatar
5 Answers
+ 2
🅰đŸ…č 🅐🅝🅐🅝🅣 sorry, it's the typing mistake.
7th May 2021, 5:07 AM
Akash Singh
Akash Singh - avatar
+ 1
Post your code first
7th May 2021, 3:46 AM
Atul [Inactive]
0
Akash Singh Do you think your code is right? Why there is Semicolon (;) in if statement?
7th May 2021, 5:01 AM
AÍąJ
AÍąJ - avatar
- 2
#include<iostream> using namespace std; bool palindrome(int n) { int temp,r,sum=0; temp=n; while(n>0) { r=n%10; sum=(sum*10)+r; n=n/10; if(temp==sum) return true; else return false; } void main() { int number; cin>>number; if(palindrome( number )==true) cout<<"The number is palindrome."; else cout<<"The number is not palindrome."; getch(); } This the answer for your question, but firstly you have to try it yourself. Don't ask the questions directly.
7th May 2021, 4:15 AM
Akash Singh
Akash Singh - avatar