Skip to content

Commit 9089652

Browse files
authored
Create check_if_number_is_palindrome_Scientist69.cpp
This program is to check whether a number is palindrome or not.
1 parent 5940bbb commit 9089652

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: check_if_number_is_palindrome_Scientist69.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)