Question
the question was to write a program that prompts the user to enter a five-digit integer and determines whether it is a palindrome number. A
the question was to write a program that prompts the user to enter a five-digit integer and determines whether it is a palindrome number. A number is palindrome if it reads the same from right to left and from left to right.
#include
cout << " the ones digit is " << onesdigit << endl;
// extract the tens digit from any given number cout << " the tens digit is " << tensdigit << endl;
// extract the hundreds digit from any given number cout << " the hundreds digit is " << hundredsdigit << endl;
// extract the thousandsd digit from any given number cout << " the thousands digit is " << thousandsdigit << endl;
// extract the tenthousands digit from any given number cout << " the ten thousands digit is " << tenthousandsdigit << endl;
// to find out if a 5 digit number is a palindrome if (onesdigit == tensdigit == hundredsdigit == thousandsdigit == tenthousandsdigit) { cout << " you do have a palindrome " << endl;
} else { cout << " you do not have a palindrome " << endl; }
}
Whenever I run this program and I have a palindrome number the program is displaying I do not have a palindrome and vice versa. What did I do wrong? Why is it swapped? I am using c++ on visual studio.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started