### error: expected identifier... / project euler 4

I am trying to do project euler # 4. My code gets an error: expected identifier before '(' token. This is on line 28.

I'm not sure if this works or not since it won't compile, but feel free to give any comments on the code etc. Thanks!
Last edited on
`if ((a == d) && (c == d))`

Also, this: `if (100 < z < 1000){`
does not do what you want. i expect you mean:
`if ((100 < z) && ( z < 1000)){`

Likewise the others.
Last edited on
Yes!!! Thanks! I also had to get rid of the break statements and add another && to the if statements. Should I post my code?
Yes please. I want to modify it so that it can find it for any length number.
As you wish.
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465`` ``````#include /* A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. Find the largest palindrome made from the product of two 3-digit numbers. */ using namespace std; int main() { int v = 0; int a, b, c, d, e, f; int x = 999; int y = 999; int z = a * x; while (y > 0){ if ((100 < z) && (z < 1000)){ a = z % 10; b = ((z % 100) - a) / 10; c = ((z % 1000) - a -(10 * b)) / 100; if ((a == c) && (z > v)){ v = z; } } if ((1000 < z) && (z < 10000)){ a = z % 10; b = ((z % 100) - a) / 10; c = ((z % 1000) - a -(10 * b)) / 100; d = ((z % 10000) - a - (10 * b) - (100 * c)) / 1000; if ((a == d) && (c == d) && (z > v)){ v = z; } } if ((10000 < z) && (z < 100000)){ a = z % 10; b = ((z % 100) - a) / 10; c = ((z % 1000) - a -(10 * b)) / 100; d = ((z % 10000) - a - (10 * b) - (100 * c)) / 1000; e = ((z % 100000) - a - (10 * b) - (100 * c) - (1000 * d)) / 10000; if ((a == e) && (b == d) && (z > v)){ v = z; } } if ((100000 < z) && (z < 1000000)) { a = z % 10; b = ((z % 100) - a) / 10; c = ((z % 1000) - a -(10 * b)) / 100; d = ((z % 10000) - a - (10 * b) - (100 * c)) / 1000; e = ((z % 100000) - a - (10 * b) - (100 * c) - (1000 * d)) / 10000; f = ((z % 1000000) - a - (10 * b) - (100 * c) - (1000 * d) - (10000 * e)) / 100000; if ((a == f) && (b == e) && (c == d)&& (z > v)){ v = z; } } x --; if (x == 1){ y --; x = 999; } z = y * x; } cout << v << endl; return 0; } ``````
Topic archived. No new replies allowed.