- #1
mr.me
- 49
- 0
I had a homework assignment that wanted me to write a function that would determine whether a five digit integer was a palindrome or not
When I run the program I enter the palindrome there is no output for my if/else statement. What did I do wrong? Code Below
When I run the program I enter the palindrome there is no output for my if/else statement. What did I do wrong? Code Below
Code:
#include <iostream>
using std::endl;
using std::cout;
using std::cin;
main ()
{
int number;
int a,b,c,d,e;
cout<< "I will take a digit five digit interger and indentify whether or not it is palindrome...";
cout<< "Please enter the number you want to check!\n"endl;
cin>> number; // a = (number % 10);
b = (number % 100) / 10;
c = (number % 1000) / 100;
d = (number % 10000) / 1000;
e = (number % 100000) / 10000; //Compare a to e and b to d. You don't need c
if (a==e && b==d)
cout<<"The number is a palindrome!\n";
else
cout<< "The number is not a palindrome!\n";
return 0;
}
Last edited: