CPP
using namespace std;
int main()
{
int n, num, digit, rev = 0;
cout << "Enter a Number:\n ";
cin >> num;
n = num;
do
{
digit = num % 10;
rev = (rev * 10) + digit;
num = num / 10;
}
while (num != 0);
cout << " Reverse of the number is: \n" << rev<<"\n";
if (n == rev)
cout << "This is a Palindrome Number.";
else
cout << "This is not a Palindrome Number.";
return 0;
}
2. When number is not a palindrome number
Palindrome or not in C++
09 July
0
Write a program (WAP) in C++ to calculate number is Palindrome or not.
#include <iostream>using namespace std;
int main()
{
int n, num, digit, rev = 0;
cout << "Enter a Number:\n ";
cin >> num;
n = num;
do
{
digit = num % 10;
rev = (rev * 10) + digit;
num = num / 10;
}
while (num != 0);
cout << " Reverse of the number is: \n" << rev<<"\n";
if (n == rev)
cout << "This is a Palindrome Number.";
else
cout << "This is not a Palindrome Number.";
return 0;
}
Out Put :-
1. When number is Palindrome number2. When number is not a palindrome number
Must Read :-
Previous article
Next article
Leave Comments
Post a Comment