From 59e725994fb0ba91692b7cba0b86902a53d86008 Mon Sep 17 00:00:00 2001 From: ishitavarshney Date: Sun, 7 Oct 2018 23:40:31 +0530 Subject: [PATCH] added a c++ program for palindrome to 'code' folder --- code/palindrome.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 code/palindrome.cpp diff --git a/code/palindrome.cpp b/code/palindrome.cpp new file mode 100644 index 0000000..c851f55 --- /dev/null +++ b/code/palindrome.cpp @@ -0,0 +1,22 @@ +#include + +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; +}