From 2561c6543d427289634eb0603ffd9ebb9b3b9c5e Mon Sep 17 00:00:00 2001 From: Mayanksingla139 <55097726+Mayanksingla139@users.noreply.github.com> Date: Fri, 16 Oct 2020 00:20:05 +0530 Subject: [PATCH 1/3] Read me # To check whether a number is in palindrome or not --- C++/program-19 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 C++/program-19 diff --git a/C++/program-19 b/C++/program-19 new file mode 100644 index 00000000..a18f2dd0 --- /dev/null +++ b/C++/program-19 @@ -0,0 +1,23 @@ +#include +using namespace std; +int main() +{ + int num, temp, digit, rev = 0; + + cout << "Enter a positive number: "; + cin >> num; + temp = num; + while (num != 0){ + digit = num % 10; + rev = (rev * 10) + digit; + num = num / 10; + } + cout << "The reverse of the number is: " << rev << endl; + if (temp == rev){ + cout<<"The number is a palindrome."; + } + else{ + cout << "The number is not a palindrome."; + } + return 0; +} From cca9858568d4bb9932479613bebfce8f5c6fca09 Mon Sep 17 00:00:00 2001 From: Mayanksingla139 <55097726+Mayanksingla139@users.noreply.github.com> Date: Fri, 16 Oct 2020 00:24:12 +0530 Subject: [PATCH 2/3] Delete program-19 --- C++/program-19 | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 C++/program-19 diff --git a/C++/program-19 b/C++/program-19 deleted file mode 100644 index a18f2dd0..00000000 --- a/C++/program-19 +++ /dev/null @@ -1,23 +0,0 @@ -#include -using namespace std; -int main() -{ - int num, temp, digit, rev = 0; - - cout << "Enter a positive number: "; - cin >> num; - temp = num; - while (num != 0){ - digit = num % 10; - rev = (rev * 10) + digit; - num = num / 10; - } - cout << "The reverse of the number is: " << rev << endl; - if (temp == rev){ - cout<<"The number is a palindrome."; - } - else{ - cout << "The number is not a palindrome."; - } - return 0; -} From 3dec8861c9de008814e2746d78d11b201cf559f5 Mon Sep 17 00:00:00 2001 From: Mayanksingla139 Date: Fri, 16 Oct 2020 10:16:34 +0530 Subject: [PATCH 3/3] To check whether a number is in palindrome or not --- C++/README.md | 1 + C++/program-19/Read me.md | 1 + C++/program-19/palindrome.cpp | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 C++/program-19/Read me.md create mode 100644 C++/program-19/palindrome.cpp diff --git a/C++/README.md b/C++/README.md index 6c2a8fec..4ffbcb51 100644 --- a/C++/README.md +++ b/C++/README.md @@ -15,3 +15,4 @@ | Program-10 | Program to find the missing number in a Sorted Array. | Program-15 | Program to find modular exponentiation. +| Program-19| To check whether a number is in palindrome or not \ No newline at end of file diff --git a/C++/program-19/Read me.md b/C++/program-19/Read me.md new file mode 100644 index 00000000..a952e91a --- /dev/null +++ b/C++/program-19/Read me.md @@ -0,0 +1 @@ +# To check whether a number is in palindrome or not \ No newline at end of file diff --git a/C++/program-19/palindrome.cpp b/C++/program-19/palindrome.cpp new file mode 100644 index 00000000..a18f2dd0 --- /dev/null +++ b/C++/program-19/palindrome.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +int main() +{ + int num, temp, digit, rev = 0; + + cout << "Enter a positive number: "; + cin >> num; + temp = num; + while (num != 0){ + digit = num % 10; + rev = (rev * 10) + digit; + num = num / 10; + } + cout << "The reverse of the number is: " << rev << endl; + if (temp == rev){ + cout<<"The number is a palindrome."; + } + else{ + cout << "The number is not a palindrome."; + } + return 0; +}