We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8871c6f commit f518d44Copy full SHA for f518d44
Palindrome.cpp
@@ -0,0 +1,28 @@
1
+#include <iostream>
2
+using namespace std;
3
+
4
+int main()
5
+{
6
+ int n, num, digit, rev = 0;
7
8
+ cout << "Enter a positive number: ";
9
+ cin >> num;
10
11
+ n = num;
12
13
+ do
14
+ {
15
+ digit = num % 10;
16
+ rev = (rev * 10) + digit;
17
+ num = num / 10;
18
+ } while (num != 0);
19
20
+ cout << " The reverse of the number is: " << rev << endl;
21
22
+ if (n == rev)
23
+ cout << " The number is a palindrome.";
24
+ else
25
+ cout << " The number is not a palindrome.";
26
27
+ return 0;
28
+}
0 commit comments