0
Can anyone help me here😑 im a begginer
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. Sample Input: 13431 Sample Output: 13431 is a palindrome
3 Antworten
+ 1
-make a copy of "input"
-reverse it
-compare with original
+ 1
#include <iostream>
using namespace std;
int main()
{
int n, num, digit, rev = 0;
cin >> num;
n = num;
do
{
digit = num % 10;
rev = (rev * 10) + digit;
num = num / 10;
} while (num != 0);
if (n == rev)
cout <<n<< " is a palindrome"<<endl;
else
cout <<n<< " is NOT a palindrome"<<endl;
return 0;
0
Question is pretty simple once Search on Google you can find easily