Palindrome Program in C++

Palindrome program in c++. This program will check the number is palindrome or not which is the number same after reversed in the c++ programming language. This program helps you to find the palindrome in the C++ language. Character-unit palindromes are the most well-known palindromes in English. Backward and forwards, the characters are the same. Redivider, deified, civic, radar, level, rotor, kayak, reviver, racecar, madam, and refer are some instances of palindromic terms.

#include <iostream>
using namespace std;
int main()
{
int n, num, count, rev = 0;
cout << "Enter the number";
cin >> num;
n = num;
do
{
count = num % 10;
rev = (rev * 10) + count;
num = num / 10;
} 
while (num != 0);
cout << "The reverse number is" << rev << endl;
if (n == rev)
cout << " The number is palindrome";
else
cout << " The number is not palindrome";
return 0;
}

 

Output:

Enter the number 4554

The reverse number is 4554

The number is palindrome

While Loop in C++

The while loop is a programming construct that repeats a portion of code an undetermined number of times until a condition is fulfilled. Let’s assume we want to know how many times we can divide a certain integer by 2 before it becomes less than or equal to 1.

If Else Statement in C++

The if block will be performed if the Boolean statement evaluates to true; else, the else block will be executed. Any non-zero and non-null values are presumed to be true in the c programming language, whereas zero and null values are believed to be false.

Return Statement in C++

A return statement terminates a function’s execution and returns control to the caller function. At the point immediately following the call, execution restarts in the caller function. A return statement can return a value to the function that called it.