#include <iostream>
#include <math.h>
using namespace std;
int checkSize(int palindrome){
int size = 1;
int multiplier = 10;
while(true){
if(palindrome/(1*multiplier) == 0){return size;}
multiplier*=10;
size+=1;
}
}
bool palindromeCheck(int intArray[], int palindrome){
int size = checkSize(palindrome);
cout<<"SIZE:"<< size<<endl;
for(int i = 0; i < size ; i++){
intArray[i] = (palindrome/pow(10, i)%10; //<-- here is your problem, you're missing a closeing parentheses
cout<<intArray[i]<<endl; // i don't know where you want it to be, after the pow() or after
} // the %10
for(int x = 0; intArray[x] > intArray[size-x];){
if(intArray[0 + x] != intArray[size - x]) return 1;
else{x++;}
}
return 0;
}
int main(){
int palindrome;
//int numbersize; //these two declaractions
//bool isPalindrome = false; //are redundant
while(true){
cerr<<"Enter a number to check\n";
cin>>palindrome;
int palindromeArray[checkSize(palindrome)]; //am i the only one who has an issue with this declaration?
if(palindromeCheck(palindromeArray, palindrome)){ cout<<palindrome<<" is a palindrome!\n";}
else{cout<<palindrome<<" is NOT a palindrome.\n";}
}
}
int reverse(int num) {
int sign = num < 0;
if (sign) num = -num;
int rev = 0;
while (num > 0) {
rev = rev * 10 + num % 10;
num /= 10; }
if (sign) rev = -rev;
return rev; }
int is_palindrome(int num) {
return num == reverse(num); }
void prelude() {
puts("Palindrome - Check if a number is palindromic.");
puts(""); }
void report(int num, int yn) {
if (yn) {
puts("Palindromic"); }
else {
puts("Not"); } }
void run() {
int num;
int yn;
prelude();
puts("Enter number at the prompt");
loop {
num = query_num();
yn = is_palindrome(num);
report(num, yn); } }