mirror of
https://github.com/c0de-archive/hacktoberfest-2018.git
synced 2024-12-22 05:12:40 +00:00
added a c++ program for palindrome to 'code' folder
This commit is contained in:
parent
790ad0b3f2
commit
59e725994f
22
code/palindrome.cpp
Normal file
22
code/palindrome.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
long a,rev,b;
|
||||
cout<<"\nenter the number :";
|
||||
cin>>a;
|
||||
b=a;
|
||||
rev=0;
|
||||
while(b)
|
||||
{
|
||||
rev=(rev*10)+(b%10);
|
||||
b=b/10;
|
||||
}
|
||||
if(a==rev)
|
||||
cout<<"\n the number IS a palindrome.";
|
||||
else
|
||||
cout<<"\n the number IS NOT a palindrome.";
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user