I'm writing a program using functions that takes an integer and determines whether or not it is prime and whether or not it is a palindrome. At the moment, I'm getting these errors:
1 2 3 4
lab9_functions.cpp: In function ‘int reverse(int*)’:
lab9_functions.cpp:45: error: invalid operands of types ‘int [10]’ and ‘int’ to binary ‘operator%’
lab9_functions.cpp:49: error: invalid operands of types ‘int [10]’ and ‘int’ to binary ‘operator/’
lab9_functions.cpp:50: error: invalid operands of types ‘int [10]’ and ‘int’ to binary ‘operator%’
If I make my variables arrays, the function that reversed the digits doesn't like it. But if they're not arrays, the function that compares them to determine whether or not they're palindromes doesn't like it.
Well you have to make up your mind. Either you're using an array or you're not.
It looks like you wrote half of this code as if you were using an array and the other half as if you weren't. So of course they're not going to work together.
On solution is to use both. Keep the number as a single integer in one variable, then split it into an array of digits in another variable.