C++ Programming

Palindrome Number

C plus plus example for palindrome number using while loop

11/5/2019
0 views
palindrome-number.cppCPP
#include<iostream>
using namespace std;

int main() {
	int no, temp, palindrome = 0;
	cout << "Check the given number is Palindrome or not" << endl;
	cout << "Enter a Number:" << endl;
	cin >> no;
	temp = no;

	/* Loop the process using "While loop" */
	while(temp != 0) {
		palindrome = palindrome * 10;
		palindrome = palindrome + (temp % 10);
		temp = temp / 10;
	}

	if(no == palindrome)
		cout << "It's a Palindrome Number!" << endl;
	else
		cout << "It's not a Palindrome Number!" << endl;

	return 0;
}


/* Output */
Check the given number is Palindrome or not
Enter a number:
121

It's a Palindrome Number!


/* ---------------------------------- */


Check the given number is Palindrome or not
Enter a number:
128

It's not a Palindrome Number!
cpppalindrome numberwhile loop

Loading comments...

Related Examples

Deliver breaking news, insightful commentary, and exclusive reports.

Targeting readers who rely on our platform to stay ahead of the curve.

Contact Us: benzingaheadlines@gmail.com